using System.ComponentModel; using System.Drawing; namespace DevComponents.DotNetBar.Charts.Style { /// /// Represents the visual style of a Chart Ticmark element. /// [TypeConverter(typeof(BlankExpandableObjectConverter))] public class ChartTickmarkVisualStyle : BaseVisualStyle { #region Private variables private int _TickmarkLength = -1; private int _TickmarkThickness = -1; private Color _TickmarkColor = Color.Empty; private LineAlignment _TickmarkAlignment = LineAlignment.NotSet; #endregion #region Public properties #region TickmarkAlignment /// /// Gets or sets the Tickmark alignment. /// [DefaultValue(LineAlignment.NotSet), Category("Appearance")] [Description("Indicates the Tickmark alignment.")] public LineAlignment TickmarkAlignment { get { return (_TickmarkAlignment); } set { if (value != _TickmarkAlignment) { _TickmarkAlignment = value; OnPropertyChangedEx("TickMarkAlignment", VisualChangeType.Layout); } } } #endregion #region TickmarkColor /// /// Gets or sets the Tickmark Color. /// [Category("Appearance")] [Description("Indicates the Tickmark Color.")] public Color TickmarkColor { get { return (_TickmarkColor); } set { if (value != _TickmarkColor) { _TickmarkColor = value; OnPropertyChangedEx("TickmarkColor", Style.VisualChangeType.Render); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] public bool ShouldSerializeTickmarkColor() { return (_TickmarkColor.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] public void ResetTickmarkColor() { TickmarkColor = Color.Empty; } #endregion #region TickmarkLength /// /// Gets or sets the Tickmark length. /// [DefaultValue(-1), Category("Appearance")] [Description("Indicates the Tickmark length.")] public int TickmarkLength { get { return (_TickmarkLength); } set { if (value != _TickmarkLength) { _TickmarkLength = value; OnPropertyChangedEx("TickmarkLength", VisualChangeType.Layout); } } } #endregion #region TickmarkThickness /// /// Gets or sets the Tickmark Thickness. /// [DefaultValue(-1), Category("Appearance")] [Description("Indicates the Tickmark Thickness.")] public int TickmarkThickness { get { return (_TickmarkThickness); } set { if (value != _TickmarkThickness) { _TickmarkThickness = value; OnPropertyChangedEx("TickmarkThickness", VisualChangeType.Layout); } } } #endregion #region IsEmpty /// /// Gets whether the style is logically Empty. /// [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Gets whether the style is logically Empty.")] public override bool IsEmpty { get { return ((_TickmarkAlignment == LineAlignment.NotSet) && (_TickmarkColor.IsEmpty == true) && (_TickmarkLength < 0) && (_TickmarkThickness < 0) && (base.IsEmpty == true)); } } #endregion #endregion #region ApplyStyle /// /// Applies the style to instance of this style. /// /// Style to apply. public void ApplyStyle(ChartTickmarkVisualStyle style) { if (style != null) { base.ApplyStyle(style); if (style.TickmarkAlignment != LineAlignment.NotSet) TickmarkAlignment = style.TickmarkAlignment; if (style.TickmarkColor.IsEmpty == false) TickmarkColor = style.TickmarkColor; if (style.TickmarkLength >= 0) TickmarkLength = style.TickmarkLength; if (style.TickmarkThickness >= 0) TickmarkThickness = style.TickmarkThickness; } } #endregion #region Copy /// /// Returns the copy of the style. /// /// Copy of the style. public new ChartTickmarkVisualStyle Copy() { ChartTickmarkVisualStyle style = new ChartTickmarkVisualStyle(); CopyTo(style); return (style); } #endregion #region CopyTo /// /// Returns the copy of the style. /// /// Copy of the style. public void CopyTo(ChartTickmarkVisualStyle style) { base.CopyTo(style); style.TickmarkAlignment = _TickmarkAlignment; style.TickmarkColor = _TickmarkColor; style.TickmarkLength = _TickmarkLength; style.TickmarkThickness = _TickmarkThickness; } #endregion #region GetSerialData internal override SerialElementCollection GetSerialData(string serialName) { SerialElementCollection sec = new SerialElementCollection(); if (serialName != null) { if (serialName.Equals("") == true) serialName = "ChartTickmarkVisualStyle"; sec.AddStartElement(serialName); } sec.AddValue("TickmarkAlignment", TickmarkAlignment, LineAlignment.NotSet); sec.AddValue("TickmarkColor", TickmarkColor, Color.Empty); sec.AddValue("TickmarkLength", TickmarkLength, -1); sec.AddValue("TickmarkThickness", TickmarkThickness, -1); sec.AddElement(base.GetSerialData(null)); if (serialName != null) sec.AddEndElement(serialName); return (sec); } #endregion #region PutSerialData #region ProcessValue internal override void ProcessValue(SerialElement se) { switch (se.Name) { case "TickmarkAlignment": TickmarkAlignment = (LineAlignment)se.GetValueEnum(typeof(LineAlignment)); break; case "TickmarkColor": TickmarkColor = se.GetValueColor(); break; case "TickmarkLength": TickmarkLength = int.Parse(se.StringValue); break; case "TickmarkThickness": TickmarkThickness = int.Parse(se.StringValue); break; default: base.ProcessValue(se); break; } } #endregion #endregion #region IDisposable /// /// Dispose /// public override void Dispose() { base.Dispose(); } #endregion } }