Repository navigation
Expand file tree
/
Copy pathBooleanFormat.cs
More file actions
99 lines (88 loc) · 2.42 KB
/
Copy pathBooleanFormat.cs
File metadata and controls
99 lines (88 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;
using System.Collections.Generic;
using System.Text;
using FastReport.Utils;
namespace FastReport.Format
{
/// <summary>
/// Defines how boolean values are formatted and displayed.
/// </summary>
public class BooleanFormat : FormatBase
{
#region Fields
private string falseText;
private string trueText;
#endregion
#region Properties
/// <summary>
/// Gets or sets a string that will be displayed if value is <b>false</b>.
/// </summary>
public string FalseText
{
get { return falseText; }
set { falseText = value; }
}
/// <summary>
/// Gets or sets a string that will be displayed if value is <b>true</b>.
/// </summary>
public string TrueText
{
get { return trueText; }
set { trueText = value; }
}
#endregion
#region Public Methods
/// <inheritdoc/>
public override FormatBase Clone()
{
BooleanFormat result = new BooleanFormat();
result.FalseText = FalseText;
result.TrueText = TrueText;
return result;
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
BooleanFormat f = obj as BooleanFormat;
return f != null && FalseText == f.FalseText && TrueText == f.TrueText;
}
/// <inheritdoc/>
public override int GetHashCode()
{
return base.GetHashCode();
}
/// <inheritdoc/>
public override string FormatValue(object value)
{
if (value is Variant)
value = ((Variant)value).Value;
if (value is bool && (bool)value == false)
return FalseText;
if (value is bool && (bool)value == true)
return TrueText;
return value.ToString();
}
internal override string GetSampleValue()
{
return FormatValue(false);
}
internal override void Serialize(FRWriter writer, string prefix, FormatBase format)
{
base.Serialize(writer, prefix, format);
BooleanFormat c = format as BooleanFormat;
if (c == null || TrueText != c.TrueText)
writer.WriteStr(prefix + "TrueText", TrueText);
if (c == null || FalseText != c.FalseText)
writer.WriteStr(prefix + "FalseText", FalseText);
}
#endregion
/// <summary>
/// Initializes a new instance of the <b>BooleanFormat</b> class with default settings.
/// </summary>
public BooleanFormat()
{
FalseText = "False";
TrueText = "True";
}
}
}