using System.ComponentModel; namespace DevComponents.DotNetBar.Charts.Style { /// /// Represents HiLoBarSegment visual style. /// [ToolboxItem(false), DesignTimeVisible(false)] [TypeConverter(typeof(VisualStylesConverter))] public class HiLoBarSegmentStyle : BaseVisualStyle { #region Static data /// /// Returns Empty instance of HiLoBarSegmentStyle. /// public static HiLoBarSegmentStyle Empty { get { return (new HiLoBarSegmentStyle()); } } #endregion #region Private variables private ChartLineVisualStyle _Default; private ChartLineVisualStyle _OpenWhisker; private ChartLineVisualStyle _CloseWhisker; private ChartLineVisualStyle _CenterLine; private ChartLineVisualStyle _MedianLine; private ChartLineVisualStyle _HighWhisker; private ChartLineVisualStyle _LowWhisker; private ChartLineVisualStyle _HighWhiskerCap; private ChartLineVisualStyle _LowWhiskerCap; private Background _BoxBackground; private ChartLineVisualStyle _BoxBorder; #endregion #region Public properties #region BoxBackground /// /// Gets or sets the visual style for the Box Background (Box, Candle only). /// [Description("Indicates the the visual style for Box Background (Box, Candle only).")] public Background BoxBackground { get { if (_BoxBackground == null) { _BoxBackground = Background.Empty; UpdateChangeHandler(null, _BoxBackground); } return (_BoxBackground); } set { if (_BoxBackground != value) { Background oldValue = _BoxBackground; _BoxBackground = value; OnStyleChanged("BoxBackground", oldValue, value); } } } /// /// Gets whether property should be serialized. /// [EditorBrowsable(EditorBrowsableState.Never)] private bool ShouldSerializeBoxBackground() { return (_BoxBackground != null && _BoxBackground.IsEmpty == false); } /// /// Resets property to its default value. /// [EditorBrowsable(EditorBrowsableState.Never)] private void ResetBoxBackground() { BoxBackground = null; } #endregion #region BoxBorder /// /// Gets or sets the visual style for the Box Border (Box, Candle only). /// [Category("Style")] [Description("Indicates the visual style for the Box Border (Box, Candle only).")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ChartLineVisualStyle BoxBorder { get { if (_BoxBorder == null) { _BoxBorder = new ChartLineVisualStyle(); UpdateChangeHandler(null, _BoxBorder); } return (_BoxBorder); } set { if (_BoxBorder != value) { ChartLineVisualStyle oldValue = _BoxBorder; _BoxBorder = value; OnStyleChanged("BoxBorder", oldValue, value); if (oldValue != null) oldValue.Dispose(); } } } #endregion #region CenterLine /// /// Gets or sets the visual style for the Center Line segment. This is the /// style used for the center Hilo segment and the Box/Candle segment when /// no Open or Close values are specified. /// [Category("Style")] [Description("Indicates the visual style for the Center Line segment. This is the style used for the center Hilo segment and the Box/Candle segment when no Open or Close values are specified.")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ChartLineVisualStyle CenterLine { get { if (_CenterLine == null) { _CenterLine = new ChartLineVisualStyle(); UpdateChangeHandler(null, _CenterLine); } return (_CenterLine); } set { if (_CenterLine != value) { ChartLineVisualStyle oldValue = _CenterLine; _CenterLine = value; OnStyleChanged("CenterLine", oldValue, value); if (oldValue != null) oldValue.Dispose(); } } } #endregion #region CloseWhisker /// /// Gets or sets the visual style for the Close Whisker (Hilo only). /// [Category("Style")] [Description("Indicates the visual style for the Close Whisker (Hilo only).")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ChartLineVisualStyle CloseWhisker { get { if (_CloseWhisker == null) { _CloseWhisker = new ChartLineVisualStyle(); UpdateChangeHandler(null, _CloseWhisker); } return (_CloseWhisker); } set { if (_CloseWhisker != value) { ChartLineVisualStyle oldValue = _CloseWhisker; _CloseWhisker = value; OnStyleChanged("CloseWhisker", oldValue, value); if (oldValue != null) oldValue.Dispose(); } } } #endregion #region Default /// /// Gets or sets the visual style used as the Default when /// a segment style is not specified (ie BoxBorder, HighWhisker, etc). /// [Category("Style")] [Description("Indicates the visual style used as the Default when a segment style is not specified (ie BoxBorder, HighWhisker, etc).")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ChartLineVisualStyle Default { get { if (_Default == null) { _Default = new ChartLineVisualStyle(); UpdateChangeHandler(null, _Default); } return (_Default); } set { if (_Default != value) { ChartLineVisualStyle oldValue = _Default; _Default = value; OnStyleChanged("Default", oldValue, value); if (oldValue != null) oldValue.Dispose(); } } } #endregion #region HighWhisker /// /// Gets or sets the visual style for the High Whisker. /// [Category("Style")] [Description("Indicates the visual style for the High Whisker.")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ChartLineVisualStyle HighWhisker { get { if (_HighWhisker == null) { _HighWhisker = new ChartLineVisualStyle(); UpdateChangeHandler(null, _HighWhisker); } return (_HighWhisker); } set { if (_HighWhisker != value) { ChartLineVisualStyle oldValue = _HighWhisker; _HighWhisker = value; OnStyleChanged("HighWhisker", oldValue, value); if (oldValue != null) oldValue.Dispose(); } } } #endregion #region HighWhiskerCap /// /// Gets or sets the visual style for the High Whisker Cap. /// [Category("Style")] [Description("Indicates the visual style for the High Whisker Cap.")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ChartLineVisualStyle HighWhiskerCap { get { if (_HighWhiskerCap == null) { _HighWhiskerCap = new ChartLineVisualStyle(); UpdateChangeHandler(null, _HighWhiskerCap); } return (_HighWhiskerCap); } set { if (_HighWhiskerCap != value) { ChartLineVisualStyle oldValue = _HighWhiskerCap; _HighWhiskerCap = value; OnStyleChanged("HighWhiskerCap", oldValue, value); if (oldValue != null) oldValue.Dispose(); } } } #endregion #region LowWhisker /// /// Gets or sets the visual style for the Low Whisker. /// [Category("Style")] [Description("Indicates the visual style for the Low Whisker.")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ChartLineVisualStyle LowWhisker { get { if (_LowWhisker == null) { _LowWhisker = new ChartLineVisualStyle(); UpdateChangeHandler(null, _LowWhisker); } return (_LowWhisker); } set { if (_LowWhisker != value) { ChartLineVisualStyle oldValue = _LowWhisker; _LowWhisker = value; OnStyleChanged("LowWhisker", oldValue, value); if (oldValue != null) oldValue.Dispose(); } } } #endregion #region LowWhiskerCap /// /// Gets or sets the visual style for the Low Whisker Cap. /// [Category("Style")] [Description("Indicates the visual style for the Low Whisker Cap.")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ChartLineVisualStyle LowWhiskerCap { get { if (_LowWhiskerCap == null) { _LowWhiskerCap = new ChartLineVisualStyle(); UpdateChangeHandler(null, _LowWhiskerCap); } return (_LowWhiskerCap); } set { if (_LowWhiskerCap != value) { ChartLineVisualStyle oldValue = _LowWhiskerCap; _LowWhiskerCap = value; OnStyleChanged("LowWhiskerCap", oldValue, value); if (oldValue != null) oldValue.Dispose(); } } } #endregion #region MedianLine /// /// Gets or sets the visual style for the Median Line. /// [Category("Style")] [Description("Indicates the visual style for the Median Line.")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ChartLineVisualStyle MedianLine { get { if (_MedianLine == null) { _MedianLine = new ChartLineVisualStyle(); UpdateChangeHandler(null, _MedianLine); } return (_MedianLine); } set { if (_MedianLine != value) { ChartLineVisualStyle oldValue = _MedianLine; _MedianLine = value; OnStyleChanged("MedianLine", oldValue, value); if (oldValue != null) oldValue.Dispose(); } } } #endregion #region OpenWhisker /// /// Gets or sets the visual style for the Open Whisker (Hilo only). /// [Category("Style")] [Description("Indicates the visual style for the Open Whisker (Hilo only).")] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ChartLineVisualStyle OpenWhisker { get { if (_OpenWhisker == null) { _OpenWhisker = new ChartLineVisualStyle(); UpdateChangeHandler(null, _OpenWhisker); } return (_OpenWhisker); } set { if (_OpenWhisker != value) { ChartLineVisualStyle oldValue = _OpenWhisker; _OpenWhisker = value; OnStyleChanged("OpenWhisker", oldValue, value); if (oldValue != null) oldValue.Dispose(); } } } #endregion #region IsEmpty /// /// Gets whether both colors assigned are empty. /// [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public override bool IsEmpty { get { return ((_BoxBackground == null || _BoxBackground.IsEmpty) && (_BoxBorder == null || _BoxBorder.IsEmpty) && (_CenterLine == null || _CenterLine.IsEmpty) && (_CloseWhisker == null || _CloseWhisker.IsEmpty) && (_Default == null || _Default.IsEmpty) && (_HighWhisker == null || _HighWhisker.IsEmpty) && (_HighWhiskerCap == null || _HighWhiskerCap.IsEmpty) && (_LowWhisker == null || _LowWhisker.IsEmpty) && (_LowWhiskerCap == null || _LowWhiskerCap.IsEmpty) && (_OpenWhisker == null || _OpenWhisker.IsEmpty) && (_MedianLine == null || _MedianLine.IsEmpty) && (base.IsEmpty == true)); } } #endregion #endregion #region ApplyStyle /// /// Applies the style to instance of this style. /// /// Style to apply. public void ApplyStyle(HiLoBarSegmentStyle style) { if (style != null) { base.ApplyStyle(style); if (style._BoxBackground != null && style._BoxBackground.IsEmpty == false) BoxBackground = style._BoxBackground.Copy(); if (style._BoxBorder != null && style._BoxBorder.IsEmpty == false) BoxBorder.ApplyStyle(style._BoxBorder); if (style._CenterLine != null && style._CenterLine.IsEmpty == false) CenterLine.ApplyStyle(style._CenterLine); if (style._CloseWhisker != null && style._CloseWhisker.IsEmpty == false) CloseWhisker.ApplyStyle(style._CloseWhisker); if (style._Default != null && style._Default.IsEmpty == false) Default.ApplyStyle(style._Default); if (style._HighWhisker != null && style._HighWhisker.IsEmpty == false) HighWhisker.ApplyStyle(style._HighWhisker); if (style._HighWhiskerCap != null && style._HighWhiskerCap.IsEmpty == false) HighWhiskerCap.ApplyStyle(style._HighWhiskerCap); if (style._LowWhisker != null && style._LowWhisker.IsEmpty == false) LowWhisker.ApplyStyle(style._LowWhisker); if (style._LowWhiskerCap != null && style._LowWhiskerCap.IsEmpty == false) LowWhiskerCap.ApplyStyle(style._LowWhiskerCap); if (style._MedianLine != null && style._MedianLine.IsEmpty == false) MedianLine.ApplyStyle(style._MedianLine); if (style._OpenWhisker != null && style._OpenWhisker.IsEmpty == false) OpenWhisker.ApplyStyle(style._OpenWhisker); } } #endregion #region Copy /// /// Creates an exact copy of the OhlcBarSegmentStyle. /// /// Copy of the OhlcBarSegmentStyle. public new HiLoBarSegmentStyle Copy() { HiLoBarSegmentStyle style = new HiLoBarSegmentStyle(); CopyTo(style); return (style); } #endregion #region CopyTo /// /// Returns the copy of the style. /// /// Copy of the style. public void CopyTo(HiLoBarSegmentStyle style) { style.BoxBackground = (_BoxBackground != null) ? _BoxBackground.Copy() : null; style.BoxBorder = (_BoxBorder != null) ? _BoxBorder.Copy() : null; style.CenterLine = (_CenterLine != null) ? _CenterLine.Copy() : null; style.CloseWhisker = (_CloseWhisker != null) ? _CloseWhisker.Copy() : null; style.Default = (_Default != null) ? _Default.Copy() : null; style.HighWhisker = (_HighWhisker != null) ? _HighWhisker.Copy() : null; style.HighWhiskerCap = (_HighWhiskerCap != null) ? _HighWhiskerCap.Copy() : null; style.LowWhisker = (_LowWhisker != null) ? _LowWhisker.Copy() : null; style.LowWhiskerCap = (_LowWhiskerCap != null) ? _LowWhiskerCap.Copy() : null; style.MedianLine = (_MedianLine != null) ? _MedianLine.Copy() : null; style.OpenWhisker = (_OpenWhisker != null) ? _OpenWhisker.Copy() : null; } #endregion #region GetSerialData internal override SerialElementCollection GetSerialData(string serialName) { SerialElementCollection sec = new SerialElementCollection(); if (serialName != null) { if (serialName.Equals("") == true) serialName = "HiLoBarSegmentStyle"; sec.AddStartElement(serialName); } if (_BoxBackground != null && _BoxBackground.IsEmpty == false) sec.AddElement(_BoxBackground.GetSerialData("BoxBackground")); if (_BoxBorder != null && _BoxBorder.IsEmpty == false) sec.AddElement(_BoxBorder.GetSerialData("BoxBorder")); if (_CenterLine != null && _CenterLine.IsEmpty == false) sec.AddElement(_CenterLine.GetSerialData("CenterLine")); if (_CloseWhisker != null && _CloseWhisker.IsEmpty == false) sec.AddElement(_CloseWhisker.GetSerialData("CloseWhisker")); if (_Default != null && _Default.IsEmpty == false) sec.AddElement(_Default.GetSerialData("Default")); if (_HighWhisker != null && _HighWhisker.IsEmpty == false) sec.AddElement(_HighWhisker.GetSerialData("HighWhisker")); if (_HighWhiskerCap != null && _HighWhiskerCap.IsEmpty == false) sec.AddElement(_HighWhiskerCap.GetSerialData("HighWhiskerCap")); if (_LowWhisker != null && _LowWhisker.IsEmpty == false) sec.AddElement(_LowWhisker.GetSerialData("LowWhisker")); if (_LowWhiskerCap != null && _LowWhiskerCap.IsEmpty == false) sec.AddElement(_LowWhiskerCap.GetSerialData("LowWhiskerCap")); if (_MedianLine != null && _MedianLine.IsEmpty == false) sec.AddElement(_MedianLine.GetSerialData("MedianLine")); if (_OpenWhisker != null && _OpenWhisker.IsEmpty == false) sec.AddElement(_OpenWhisker.GetSerialData("OpenWhisker")); sec.AddElement(base.GetSerialData(null)); if (serialName != null) sec.AddEndElement(serialName); return (sec); } #endregion #region PutSerialData #region ProcessCollection internal override void ProcessCollection(SerialElement se) { SerialElementCollection sec = se.Sec; switch (se.Name) { case "BoxBackground": sec.PutSerialData(BoxBackground); break; case "BoxBorder": sec.PutSerialData(BoxBorder); break; case "CenterLine": sec.PutSerialData(CenterLine); break; case "CloseWhisker": sec.PutSerialData(CloseWhisker); break; case "Default": sec.PutSerialData(Default); break; case "HighWhisker": sec.PutSerialData(HighWhisker); break; case "HighWhiskerCap": sec.PutSerialData(HighWhiskerCap); break; case "LowWhisker": sec.PutSerialData(LowWhisker); break; case "LowWhiskerCap": sec.PutSerialData(LowWhiskerCap); break; case "MedianLine": sec.PutSerialData(MedianLine); break; case "OpenWhisker": sec.PutSerialData(OpenWhisker); break; default: base.ProcessCollection(se); break; } } #endregion #endregion #region IDisposable public override void Dispose() { BoxBorder = null; CenterLine = null; CloseWhisker = null; Default = null; HighWhisker = null; HighWhiskerCap = null; LowWhisker = null; LowWhiskerCap = null; MedianLine = null; OpenWhisker = null; base.Dispose(); } #endregion } }