TextOutline.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. using System.Drawing;
  2. using System.Drawing.Drawing2D;
  3. using System.ComponentModel;
  4. using FastReport.Utils;
  5. using System.Drawing.Design;
  6. namespace FastReport
  7. {
  8. /// <summary>
  9. /// Represents text outline.
  10. /// </summary>
  11. [ToolboxItem(false)]
  12. [TypeConverter(typeof(FastReport.TypeConverters.FRExpandableObjectConverter))]
  13. public class TextOutline// : Component
  14. {
  15. #region Fields
  16. private bool enabled;
  17. private Color color;
  18. private float width;
  19. private DashStyle style;
  20. private bool drawbehind;
  21. #endregion // Fields
  22. #region Properties
  23. /// <summary>
  24. /// Gets or sets a value indicating that outline is enabled.
  25. /// </summary>
  26. [DefaultValue(false)]
  27. [Browsable(true)]
  28. public bool Enabled
  29. {
  30. get { return enabled; }
  31. set { enabled = value; }
  32. }
  33. /// <summary>
  34. /// Enable or disable draw the outline behind of text.
  35. /// </summary>
  36. [DefaultValue(false)]
  37. [Browsable(true)]
  38. public bool DrawBehind
  39. {
  40. get { return drawbehind; }
  41. set { drawbehind = value; }
  42. }
  43. /// <summary>
  44. /// Gets or sets the outline color.
  45. /// </summary>
  46. [Editor("FastReport.TypeEditors.ColorEditor, FastReport", typeof(UITypeEditor))]
  47. public Color Color
  48. {
  49. get { return color; }
  50. set { color = value; }
  51. }
  52. /// <summary>
  53. /// Gets or sets the outline width.
  54. /// </summary>
  55. [DefaultValue(1.0f)]
  56. [Browsable(true)]
  57. public float Width
  58. {
  59. get { return width; }
  60. set { width = value; }
  61. }
  62. /// <summary>
  63. /// Specifies the style of an outline.
  64. /// </summary>
  65. [DefaultValue(DashStyle.Solid)]
  66. [Browsable(true)]
  67. public DashStyle Style
  68. {
  69. get { return style; }
  70. set { style = value; }
  71. }
  72. #endregion // Properties
  73. #region Constructors
  74. /// <summary>
  75. /// Initializes a new instance of the <see cref="TextOutline"/> class.
  76. /// </summary>
  77. public TextOutline()
  78. {
  79. enabled = false;
  80. color = Color.Black;
  81. width = 1.0f;
  82. style = DashStyle.Solid;
  83. drawbehind = false;
  84. }
  85. /// <summary>
  86. /// Initializes a new instance of the <see cref="TextOutline"/> class with specified parameters.
  87. /// </summary>
  88. /// <param name="enabled">True if outline enabled.</param>
  89. /// <param name="color">Outline color.</param>
  90. /// <param name="width">Outline width.</param>
  91. /// <param name="style">Outline style.</param>
  92. /// <param name="drawbehind">True if outline should be drawn behind text.</param>
  93. public TextOutline(bool enabled, Color color, float width, DashStyle style, bool drawbehind)
  94. {
  95. this.enabled = enabled;
  96. this.color = color;
  97. this.width = width;
  98. this.style = style;
  99. this.drawbehind = drawbehind;
  100. }
  101. #endregion // Constructors
  102. #region Public Methods
  103. /// <summary>
  104. /// Copies the content of another TextOutline.
  105. /// </summary>
  106. /// <param name="src">The TextOutline instance to copy the contents from.</param>
  107. public void Assign(TextOutline src)
  108. {
  109. enabled = src.Enabled;
  110. color = src.Color;
  111. width = src.Width;
  112. style = src.Style;
  113. drawbehind = src.DrawBehind;
  114. }
  115. /// <summary>
  116. /// Creates the exact copy of this outline.
  117. /// </summary>
  118. /// <returns>Copy of this outline.</returns>
  119. public TextOutline Clone()
  120. {
  121. return new TextOutline(enabled, color, width, style, drawbehind);
  122. }
  123. /// <summary>
  124. /// Serializes the TextOutline.
  125. /// </summary>
  126. /// <param name="writer">Writer object.</param>
  127. /// <param name="prefix">TextOutline property name.</param>
  128. /// <param name="diff">Another TextOutline to compare with.</param>
  129. public void Serialize(FRWriter writer, string prefix, TextOutline diff)
  130. {
  131. if (enabled != diff.Enabled)
  132. {
  133. writer.WriteBool(prefix + ".Enabled", enabled);
  134. }
  135. if (color != diff.Color)
  136. {
  137. writer.WriteValue(prefix + ".Color", color);
  138. }
  139. if (width != diff.Width)
  140. {
  141. writer.WriteFloat(prefix + ".Width", width);
  142. }
  143. if (style != diff.Style)
  144. {
  145. writer.WriteValue(prefix + ".Style", style);
  146. }
  147. if (drawbehind != diff.DrawBehind)
  148. {
  149. writer.WriteBool(prefix + ".DrawBehind", drawbehind);
  150. }
  151. }
  152. #endregion // Public Methods
  153. }
  154. }