using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace DevComponents.DotNetBar.Charts.Style { /// /// Represents the visual style of an element. /// [TypeConverter(typeof(VisualStylesConverter))] public class CrosshairValueVisualStyle : VisualStyle { #region Private variables private string _TextFormat; private DropShadowVisualStyle _DropShadow; #endregion #region Public properties #region DropShadow /// /// Gets or sets the visual style for the DropShadow. /// [Category("Style")] [Description("Indicates the visual style for the DropShadow.")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public DropShadowVisualStyle DropShadow { get { if (_DropShadow == null) { _DropShadow = new DropShadowVisualStyle(); UpdateChangeHandler(null, _DropShadow); } return (_DropShadow); } set { if (_DropShadow != value) { DropShadowVisualStyle oldValue = _DropShadow; _DropShadow = value; OnStyleChanged("DropShadow", oldValue, value); if (oldValue != null) oldValue.Dispose(); } } } #endregion #region TextFormat /// /// Gets or sets the Text Format specifier /// [DefaultValue(null)] [Description("Indicates the Text Format specifier")] public string TextFormat { get { return (_TextFormat); } set { if (_TextFormat != value) { _TextFormat = value; OnPropertyChangedEx("TextFormat", VisualChangeType.Render); } } } #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 ((_DropShadow == null || _DropShadow.IsEmpty) && (string.IsNullOrEmpty(_TextFormat) == true) && (base.IsEmpty == true)); } } #endregion #endregion #region ApplyStyle /// /// Applies the style to instance of this style. /// /// Style to apply. public void ApplyStyle(CrosshairValueVisualStyle style) { if (style != null) { base.ApplyStyle(style); if (style._DropShadow != null && style.DropShadow.IsEmpty == false) DropShadow.ApplyStyle(style.DropShadow); if (string.IsNullOrEmpty(style.TextFormat) == false) _TextFormat = style.TextFormat; } } #endregion #region ApplyDefaults public override void ApplyDefaults() { if (Background.IsEmpty == true) Background = new Background(ControlPaint.LightLight(Color.Fuchsia)); if (BorderColor.IsEmpty == true) BorderColor = new BorderColor(Color.Black); if (BorderPattern.IsEmpty == true) BorderPattern = new BorderPattern(LinePattern.Solid); if (BorderThickness.IsEmpty == true) BorderThickness = new Thickness(1); base.ApplyDefaults(); } #endregion #region Copy /// /// Returns the copy of the style. /// /// Copy of the style. public new CrosshairValueVisualStyle Copy() { CrosshairValueVisualStyle style = new CrosshairValueVisualStyle(); CopyTo(style); return (style); } #endregion #region CopyTo /// /// Returns the copy of the style. /// /// Copy of the style. public void CopyTo(CrosshairValueVisualStyle style) { base.CopyTo(style); style.DropShadow = (_DropShadow != null) ? DropShadow.Copy() : null; style.TextFormat = _TextFormat; } #endregion #region GetSerialData internal override SerialElementCollection GetSerialData(string serialName) { SerialElementCollection sec = new SerialElementCollection(); if (serialName != null) { if (serialName.Equals("") == true) serialName = "CrosshairValueVisualStyle"; sec.AddStartElement(serialName); } if (_DropShadow != null && _DropShadow.IsEmpty == false) sec.AddElement(_DropShadow.GetSerialData("DropShadow")); sec.AddValue("TextFormat", TextFormat, null); 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 "TextFormat": TextFormat = se.StringValue; break; default: base.ProcessValue(se); break; } } #endregion #region ProcessCollection internal override void ProcessCollection(SerialElement se) { SerialElementCollection sec = se.Sec; switch (se.Name) { case "DropShadow": sec.PutSerialData(DropShadow); break; default: base.ProcessCollection(se); break; } } #endregion #endregion #region IDisposable /// /// Dispose /// public override void Dispose() { DropShadow = null; base.Dispose(); } #endregion } }