FastReport
173 строки · 5.0 Кб
1using System.Drawing;2using System.Drawing.Drawing2D;3using System.ComponentModel;4using FastReport.Utils;5using System.Drawing.Design;6
7namespace FastReport8{
9/// <summary>10/// Represents text outline.11/// </summary>12[ToolboxItem(false)]13[TypeConverter(typeof(FastReport.TypeConverters.FRExpandableObjectConverter))]14public class TextOutline// : Component15{16#region Fields17
18private bool enabled;19private Color color;20private float width;21private DashStyle style;22private bool drawbehind;23
24#endregion // Fields25
26#region Properties27
28/// <summary>29/// Gets or sets a value indicating that outline is enabled.30/// </summary>31[DefaultValue(false)]32[Browsable(true)]33public bool Enabled34{35get { return enabled; }36set { enabled = value; }37}38
39/// <summary>40/// Enable or disable draw the outline behind of text.41/// </summary>42[DefaultValue(false)]43[Browsable(true)]44public bool DrawBehind45{46get { return drawbehind; }47set { drawbehind = value; }48}49
50/// <summary>51/// Gets or sets the outline color.52/// </summary>53[Editor("FastReport.TypeEditors.ColorEditor, FastReport", typeof(UITypeEditor))]54public Color Color55{56get { return color; }57set { color = value; }58}59
60/// <summary>61/// Gets or sets the outline width.62/// </summary>63[DefaultValue(1.0f)]64[Browsable(true)]65public float Width66{67get { return width; }68set { width = value; }69}70
71/// <summary>72/// Specifies the style of an outline.73/// </summary>74[DefaultValue(DashStyle.Solid)]75[Browsable(true)]76public DashStyle Style77{78get { return style; }79set { style = value; }80}81
82#endregion // Properties83
84#region Constructors85
86/// <summary>87/// Initializes a new instance of the <see cref="TextOutline"/> class.88/// </summary>89public TextOutline()90{91enabled = false;92color = Color.Black;93width = 1.0f;94style = DashStyle.Solid;95drawbehind = 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>106public TextOutline(bool enabled, Color color, float width, DashStyle style, bool drawbehind)107{108this.enabled = enabled;109this.color = color;110this.width = width;111this.style = style;112this.drawbehind = drawbehind;113}114
115#endregion // Constructors116
117#region Public Methods118
119/// <summary>120/// Copies the content of another TextOutline.121/// </summary>122/// <param name="src">The TextOutline instance to copy the contents from.</param>123public void Assign(TextOutline src)124{125enabled = src.Enabled;126color = src.Color;127width = src.Width;128style = src.Style;129drawbehind = src.DrawBehind;130}131
132/// <summary>133/// Creates the exact copy of this outline.134/// </summary>135/// <returns>Copy of this outline.</returns>136public TextOutline Clone()137{138return 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>147public void Serialize(FRWriter writer, string prefix, TextOutline diff)148{149if (enabled != diff.Enabled)150{151writer.WriteBool(prefix + ".Enabled", enabled);152}153if (color != diff.Color)154{155writer.WriteValue(prefix + ".Color", color);156}157if (width != diff.Width)158{159writer.WriteFloat(prefix + ".Width", width);160}161if (style != diff.Style)162{163writer.WriteValue(prefix + ".Style", style);164}165if (drawbehind != diff.DrawBehind)166{167writer.WriteBool(prefix + ".DrawBehind", drawbehind);168}169}170
171#endregion // Public Methods172}173}
174