using FastReport.Utils; using System; using System.ComponentModel; using System.Drawing; namespace FastReport.Gauge { /// /// Represents a label of a gauge. /// #if !DEBUG [DesignTimeVisible(false)] #endif public class GaugeLabel : Component { #region Private Fields private string text; private Font font; private Color color; private GaugeObject parent; #endregion //Private Fields #region Properties /// /// Gets or sets the label text /// public virtual string Text { get { return text; } set { if (value == null) throw new ArgumentNullException("Text"); text = value; } } /// /// Gets or sets the label font /// public Font Font { get { return font; } set { if (value == null) throw new ArgumentNullException("Font"); font = value; } } /// /// Gets or sets the label color /// public Color Color { get { return color; } set { color = value; } } /// /// Gets or sets the label parent /// [Browsable(false)] public GaugeObject Parent { get { return parent; } set { parent = value; } } #endregion //Properties #region Constractors /// /// Initializes a new instance of the class. /// public GaugeLabel(GaugeObject parent) { Text = ""; Color = Color.Black; Font = parent.Scale.Font; this.parent = parent; } /// /// Initializes a new instance of the class. /// /// Label text /// Label font /// Label color /// Label parent public GaugeLabel(GaugeObject parent, string text, Font font, Color color) { Text = text; Font = font; Color = color; this.parent = parent; } #endregion Constructors #region Public Methods /// /// Copies the contents of another GaugeLabel. /// /// The GaugeLabel instance to copy the contents from. public virtual void Assign(GaugeLabel src) { Text = src.Text; Font = src.Font; Color = src.Color; } /// /// Draws the gauge label. /// /// Draw event arguments. public virtual void Draw(FRPaintEventArgs e) { } /// /// Serializes the gauge label. /// /// Writer object. /// Gauge label property name. /// Another GaugeLabel to compare with. /// /// This method is for internal use only. /// public virtual void Serialize(FRWriter writer, string prefix, GaugeLabel diff) { if (Text != diff.Text) { writer.WriteStr(prefix + ".Text", Text); } if ((writer.SerializeTo != SerializeTo.Preview || !Font.Equals(diff.Font)) && writer.ItemName != "inherited") { writer.WriteValue(prefix + ".Font", Font); } if (Color != diff.Color) { writer.WriteValue(prefix + ".Color", Color); } } #endregion // Public Methods } }