331 lines
9.5 KiB
C#
331 lines
9.5 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Drawing.Design;
|
|
|
|
namespace DevComponents.DotNetBar.Charts.Style
|
|
{
|
|
/// <summary>
|
|
/// Represents the visual style of an Hilo Bar Series (OHLC)
|
|
/// </summary>
|
|
[ToolboxItem(false), DesignTimeVisible(false)]
|
|
[TypeConverter(typeof(VisualStylesConverter))]
|
|
public class ChartHiLoBarVisualStyle : BaseVisualStyle
|
|
{
|
|
#region Private variables
|
|
|
|
private HiLoBarSegmentStyle _DefaultSegmentStyle;
|
|
private HiLoBarSegmentStyle _AlternateSegmentStyle;
|
|
|
|
private Tbool _ShowWhiskerCaps = Tbool.NotSet;
|
|
private Tbool _UseAlternateSegmentStyle = Tbool.NotSet;
|
|
|
|
#endregion
|
|
|
|
#region Public properties
|
|
|
|
#region AlternateSegmentStyle
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Alternate Style for the Ohlc bar.
|
|
/// </summary>
|
|
[Description("Indicates the Alternate Style for the Ohlc bar.")]
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
|
public HiLoBarSegmentStyle AlternateSegmentStyle
|
|
{
|
|
get
|
|
{
|
|
if (_AlternateSegmentStyle == null)
|
|
{
|
|
_AlternateSegmentStyle = HiLoBarSegmentStyle.Empty;
|
|
|
|
UpdateChangeHandler(null, _AlternateSegmentStyle);
|
|
}
|
|
|
|
return (_AlternateSegmentStyle);
|
|
}
|
|
|
|
set
|
|
{
|
|
if (_AlternateSegmentStyle != value)
|
|
{
|
|
UpdateChangeHandler(_AlternateSegmentStyle, value);
|
|
|
|
_AlternateSegmentStyle = value;
|
|
|
|
OnPropertyChangedEx("AlternateSegmentStyle", VisualChangeType.Layout);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region DefaultSegmentStyle
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Default Style for the Ohlc bar.
|
|
/// </summary>
|
|
[Description("Indicates the Default Style for the Ohlc bar.")]
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
|
public HiLoBarSegmentStyle DefaultSegmentStyle
|
|
{
|
|
get
|
|
{
|
|
if (_DefaultSegmentStyle == null)
|
|
{
|
|
_DefaultSegmentStyle = HiLoBarSegmentStyle.Empty;
|
|
|
|
UpdateChangeHandler(null, _DefaultSegmentStyle);
|
|
}
|
|
|
|
return (_DefaultSegmentStyle);
|
|
}
|
|
|
|
set
|
|
{
|
|
if (_DefaultSegmentStyle != value)
|
|
{
|
|
UpdateChangeHandler(_DefaultSegmentStyle, value);
|
|
|
|
_DefaultSegmentStyle = value;
|
|
|
|
OnPropertyChangedEx("DefaultSegmentStyle", VisualChangeType.Layout);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ShowWhiskerCaps
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether Box/Candle whisker caps are displayed.
|
|
/// </summary>
|
|
[DefaultValue(Tbool.NotSet), Category("Appearance")]
|
|
[Description("Indicates whether Box/Candle whisker caps are displayed.")]
|
|
public Tbool ShowWhiskerCaps
|
|
{
|
|
get { return (_ShowWhiskerCaps); }
|
|
|
|
set
|
|
{
|
|
if (value != _ShowWhiskerCaps)
|
|
{
|
|
_ShowWhiskerCaps = value;
|
|
|
|
OnPropertyChangedEx("ShowWhiskerCaps", VisualChangeType.Render);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region UseAlternateSegmentStyle
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether Box/Candle whisker caps are displayed.
|
|
/// </summary>
|
|
[DefaultValue(Tbool.NotSet), Category("Appearance")]
|
|
[Description("Indicates whether Box/Candle whisker caps are displayed.")]
|
|
public Tbool UseAlternateSegmentStyle
|
|
{
|
|
get { return (_UseAlternateSegmentStyle); }
|
|
|
|
set
|
|
{
|
|
if (value != _UseAlternateSegmentStyle)
|
|
{
|
|
_UseAlternateSegmentStyle = value;
|
|
|
|
OnPropertyChangedEx("UseAlternateSegmentStyle", VisualChangeType.Render);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IsEmpty
|
|
|
|
/// <summary>
|
|
/// Gets whether the style is logically Empty.
|
|
/// </summary>
|
|
[Browsable(false)]
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
|
[Description("Gets whether the style is logically Empty.")]
|
|
public override bool IsEmpty
|
|
{
|
|
get
|
|
{
|
|
return ((_AlternateSegmentStyle == null || _AlternateSegmentStyle.IsEmpty == true) &&
|
|
(_DefaultSegmentStyle == null || _DefaultSegmentStyle.IsEmpty) &&
|
|
(_ShowWhiskerCaps == Tbool.NotSet));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region ApplyStyle
|
|
|
|
/// <summary>
|
|
/// Applies the style to instance of this style.
|
|
/// </summary>
|
|
/// <param name="style">Style to apply.</param>
|
|
public void ApplyStyle(ChartHiLoBarVisualStyle style)
|
|
{
|
|
if (style != null)
|
|
{
|
|
base.ApplyStyle(style);
|
|
|
|
if (style._AlternateSegmentStyle != null && style._AlternateSegmentStyle.IsEmpty == false)
|
|
AlternateSegmentStyle.ApplyStyle(style._AlternateSegmentStyle);
|
|
|
|
if (style._DefaultSegmentStyle != null && style._DefaultSegmentStyle.IsEmpty == false)
|
|
DefaultSegmentStyle.ApplyStyle(style._DefaultSegmentStyle);
|
|
|
|
if (style.ShowWhiskerCaps != Tbool.NotSet)
|
|
ShowWhiskerCaps = style.ShowWhiskerCaps;
|
|
|
|
if (style.UseAlternateSegmentStyle != Tbool.NotSet)
|
|
UseAlternateSegmentStyle = style.UseAlternateSegmentStyle;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Copy
|
|
|
|
/// <summary>
|
|
/// Returns the copy of the style.
|
|
/// </summary>
|
|
/// <returns>Copy of the style.</returns>
|
|
public new ChartHiLoBarVisualStyle Copy()
|
|
{
|
|
ChartHiLoBarVisualStyle style = new ChartHiLoBarVisualStyle();
|
|
|
|
CopyTo(style);
|
|
|
|
return (style);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CopyTo
|
|
|
|
/// <summary>
|
|
/// Returns the copy of the style.
|
|
/// </summary>
|
|
/// <returns>Copy of the style.</returns>
|
|
public void CopyTo(ChartHiLoBarVisualStyle style)
|
|
{
|
|
base.CopyTo(style);
|
|
|
|
style.AlternateSegmentStyle = (_AlternateSegmentStyle != null) ? _AlternateSegmentStyle.Copy() : null;
|
|
style.DefaultSegmentStyle = (_DefaultSegmentStyle != null) ? _DefaultSegmentStyle.Copy() : null;
|
|
|
|
style.ShowWhiskerCaps = _ShowWhiskerCaps;
|
|
style.UseAlternateSegmentStyle = _UseAlternateSegmentStyle;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GetSerialData
|
|
|
|
internal override SerialElementCollection GetSerialData(string serialName)
|
|
{
|
|
SerialElementCollection sec = new SerialElementCollection();
|
|
|
|
if (serialName != null)
|
|
{
|
|
if (serialName.Equals("") == true)
|
|
serialName = "ChartHiLoBarVisualStyle";
|
|
|
|
sec.AddStartElement(serialName);
|
|
}
|
|
|
|
if (_DefaultSegmentStyle != null && _DefaultSegmentStyle.IsEmpty == false)
|
|
sec.AddElement(_DefaultSegmentStyle.GetSerialData("DefaultSegmentStyle"));
|
|
|
|
if (_AlternateSegmentStyle != null && _AlternateSegmentStyle.IsEmpty == false)
|
|
sec.AddElement(_AlternateSegmentStyle.GetSerialData("AlternateSegmentStyle"));
|
|
|
|
sec.AddValue("ShowWhiskerCaps", ShowWhiskerCaps, Tbool.NotSet);
|
|
sec.AddValue("UseAlternateSegmentStyle", UseAlternateSegmentStyle, Tbool.NotSet);
|
|
|
|
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 "ShowWhiskerCaps":
|
|
ShowWhiskerCaps = (Tbool)se.GetValueEnum(typeof(Tbool));
|
|
break;
|
|
|
|
case "UseAlternateSegmentStyle":
|
|
UseAlternateSegmentStyle = (Tbool)se.GetValueEnum(typeof(Tbool));
|
|
break;
|
|
|
|
default:
|
|
base.ProcessValue(se);
|
|
break;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ProcessCollection
|
|
|
|
internal override void ProcessCollection(SerialElement se)
|
|
{
|
|
SerialElementCollection sec = se.Sec;
|
|
|
|
switch (se.Name)
|
|
{
|
|
case "DefaultSegmentStyle":
|
|
sec.PutSerialData(DefaultSegmentStyle);
|
|
break;
|
|
|
|
case "AlternateSegmentStyle":
|
|
sec.PutSerialData(AlternateSegmentStyle);
|
|
break;
|
|
|
|
default:
|
|
base.ProcessCollection(se);
|
|
break;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region IDisposable
|
|
|
|
/// <summary>
|
|
/// Dispose
|
|
/// </summary>
|
|
public override void Dispose()
|
|
{
|
|
AlternateSegmentStyle = null;
|
|
DefaultSegmentStyle = null;
|
|
|
|
base.Dispose();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|