FastReport

Форк
0
/
TextOutline.cs 
173 строки · 5.0 Кб
1
using System.Drawing;
2
using System.Drawing.Drawing2D;
3
using System.ComponentModel;
4
using FastReport.Utils;
5
using System.Drawing.Design;
6

7
namespace FastReport
8
{
9
    /// <summary>
10
    /// Represents text outline.
11
    /// </summary>
12
    [ToolboxItem(false)]
13
    [TypeConverter(typeof(FastReport.TypeConverters.FRExpandableObjectConverter))]
14
    public class TextOutline// : Component
15
    {
16
        #region Fields
17

18
        private bool enabled;
19
        private Color color;
20
        private float width;
21
        private DashStyle style;
22
        private bool drawbehind;
23

24
        #endregion // Fields
25

26
        #region Properties
27

28
        /// <summary>
29
        /// Gets or sets a value indicating that outline is enabled.
30
        /// </summary>
31
        [DefaultValue(false)]
32
        [Browsable(true)]
33
        public bool Enabled
34
        {
35
            get { return enabled; }
36
            set { enabled = value; }
37
        }
38

39
        /// <summary>
40
        /// Enable or disable draw the outline behind of text.
41
        /// </summary>
42
        [DefaultValue(false)]
43
        [Browsable(true)]
44
        public bool DrawBehind
45
        {
46
            get { return drawbehind; }
47
            set { drawbehind = value; }
48
        }
49

50
        /// <summary>
51
        /// Gets or sets the outline color.
52
        /// </summary>
53
        [Editor("FastReport.TypeEditors.ColorEditor, FastReport", typeof(UITypeEditor))]
54
        public Color Color
55
        {
56
            get { return color; }
57
            set { color = value; }
58
        }
59

60
        /// <summary>
61
        /// Gets or sets the outline width.
62
        /// </summary>
63
        [DefaultValue(1.0f)]
64
        [Browsable(true)]
65
        public float Width
66
        {
67
            get { return width; }
68
            set { width = value; }
69
        }
70

71
        /// <summary>
72
        /// Specifies the style of an outline.
73
        /// </summary>
74
        [DefaultValue(DashStyle.Solid)]
75
        [Browsable(true)]
76
        public DashStyle Style
77
        {
78
            get { return style; }
79
            set { style = value; }
80
        }
81

82
        #endregion // Properties
83

84
        #region Constructors
85

86
        /// <summary>
87
        /// Initializes a new instance of the <see cref="TextOutline"/> class.
88
        /// </summary>
89
        public TextOutline()
90
        {
91
            enabled = false;
92
            color = Color.Black;
93
            width = 1.0f;
94
            style = DashStyle.Solid;
95
            drawbehind = false;
96
        }
97

98
        /// <summary>
99
        /// Initializes a new instance of the <see cref="TextOutline"/> class with specified parameters.
100
        /// </summary>
101
        /// <param name="enabled">True if outline enabled.</param>
102
        /// <param name="color">Outline color.</param>
103
        /// <param name="width">Outline width.</param>
104
        /// <param name="style">Outline style.</param>
105
        /// <param name="drawbehind">True if outline should be drawn behind text.</param>
106
        public TextOutline(bool enabled, Color color, float width, DashStyle style, bool drawbehind)
107
        {
108
            this.enabled = enabled;
109
            this.color = color;
110
            this.width = width;
111
            this.style = style;
112
            this.drawbehind = drawbehind;
113
        }
114

115
        #endregion // Constructors
116

117
        #region Public Methods
118

119
        /// <summary>
120
        /// Copies the content of another TextOutline.
121
        /// </summary>
122
        /// <param name="src">The TextOutline instance to copy the contents from.</param>
123
        public void Assign(TextOutline src)
124
        {
125
            enabled = src.Enabled;
126
            color = src.Color;
127
            width = src.Width;
128
            style = src.Style;
129
            drawbehind = src.DrawBehind;
130
        }
131

132
        /// <summary>
133
        /// Creates the exact copy of this outline.
134
        /// </summary>
135
        /// <returns>Copy of this outline.</returns>
136
        public TextOutline Clone()
137
        {
138
            return new TextOutline(enabled, color, width, style, drawbehind);
139
        }
140

141
        /// <summary>
142
        /// Serializes the TextOutline.
143
        /// </summary>
144
        /// <param name="writer">Writer object.</param>
145
        /// <param name="prefix">TextOutline property name.</param>
146
        /// <param name="diff">Another TextOutline to compare with.</param>
147
        public void Serialize(FRWriter writer, string prefix, TextOutline diff)
148
        {
149
            if (enabled != diff.Enabled)
150
            {
151
                writer.WriteBool(prefix + ".Enabled", enabled);
152
            }
153
            if (color != diff.Color)
154
            {
155
                writer.WriteValue(prefix + ".Color", color);
156
            }
157
            if (width != diff.Width)
158
            {
159
                writer.WriteFloat(prefix + ".Width", width);
160
            }
161
            if (style != diff.Style)
162
            {
163
                writer.WriteValue(prefix + ".Style", style);
164
            }
165
            if (drawbehind != diff.DrawBehind)
166
            {
167
                writer.WriteBool(prefix + ".DrawBehind", drawbehind);
168
            }
169
        }
170

171
        #endregion // Public Methods
172
    }
173
}
174

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.