GaugePointer.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using System.Drawing;
  2. using System.ComponentModel;
  3. using FastReport.Utils;
  4. using System.Drawing.Design;
  5. namespace FastReport.Gauge
  6. {
  7. /// <summary>
  8. /// Represents a pointer of gauge.
  9. /// </summary>
  10. #if !DEBUG
  11. [DesignTimeVisible(false)]
  12. #endif
  13. public class GaugePointer : Component
  14. {
  15. #region Fields
  16. private GaugeObject parent;
  17. private FillBase fill;
  18. private float borderWidth;
  19. private Color borderColor;
  20. #endregion // Fields
  21. #region Properties
  22. /// <summary>
  23. /// Gets or sets the parent gauge object.
  24. /// </summary>
  25. [Browsable(false)]
  26. public GaugeObject Parent
  27. {
  28. get { return parent; }
  29. set { parent = value; }
  30. }
  31. /// <summary>
  32. /// Gets or sets the color of a pointer.
  33. /// </summary>
  34. [Browsable(true)]
  35. [Editor("FastReport.TypeEditors.FillEditor, FastReport", typeof(UITypeEditor))]
  36. public FillBase Fill
  37. {
  38. get { return fill; }
  39. set { fill = value; }
  40. }
  41. /// <summary>
  42. /// Gets or sets the border width of a pointer.
  43. /// </summary>
  44. [Browsable(false)]
  45. public float BorderWidth
  46. {
  47. get { return borderWidth; }
  48. set { borderWidth = value; }
  49. }
  50. /// <summary>
  51. /// Gets or sets the border color of a pointer.
  52. /// </summary>
  53. [Browsable(true)]
  54. public Color BorderColor
  55. {
  56. get { return borderColor; }
  57. set { borderColor = value; }
  58. }
  59. #endregion // Properties
  60. #region Constructors
  61. /// <summary>
  62. /// Initializes a new instance of the <see cref="GaugePointer"/> class.
  63. /// </summary>
  64. /// <param name="parent">The parent gauge object.</param>
  65. public GaugePointer(GaugeObject parent)
  66. {
  67. fill = new SolidFill(Color.Orange);
  68. borderWidth = 1.0f;
  69. borderColor = Color.Black;
  70. this.parent = parent;
  71. }
  72. #endregion // Constructors
  73. #region Public Methods
  74. /// <summary>
  75. /// Copies the contents of another GaugePointer.
  76. /// </summary>
  77. /// <param name="src">The GaugePointer instance to copy the contents from.</param>
  78. public virtual void Assign(GaugePointer src)
  79. {
  80. Fill = src.Fill;
  81. BorderWidth = src.BorderWidth;
  82. BorderColor = src.BorderColor;
  83. }
  84. /// <summary>
  85. /// Draws the gauge pointer.
  86. /// </summary>
  87. /// <param name="e">Draw event arguments.</param>
  88. public virtual void Draw(FRPaintEventArgs e)
  89. {
  90. }
  91. /// <summary>
  92. /// Serializes the gauge pointer.
  93. /// </summary>
  94. /// <param name="writer">Writer object.</param>
  95. /// <param name="prefix">Gauge pointer property name.</param>
  96. /// <param name="diff">Another GaugePointer to compare with.</param>
  97. /// <remarks>
  98. /// This method is for internal use only.
  99. /// </remarks>
  100. public virtual void Serialize(FRWriter writer, string prefix, GaugePointer diff)
  101. {
  102. Fill.Serialize(writer, prefix + ".Fill", diff.Fill);
  103. if (BorderWidth != diff.BorderWidth)
  104. {
  105. writer.WriteFloat(prefix + ".BorderWidth", BorderWidth);
  106. }
  107. if (BorderColor != diff.BorderColor)
  108. {
  109. writer.WriteValue(prefix + ".BorderColor", BorderColor);
  110. }
  111. }
  112. #endregion // Public Methods
  113. }
  114. }