518 lines
12 KiB
C#
518 lines
12 KiB
C#
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Drawing.Design;
|
|
using System.Drawing.Drawing2D;
|
|
|
|
namespace DevComponents.DotNetBar.Charts.Style
|
|
{
|
|
/// <summary>
|
|
/// Represents the visual style of a Chart Line
|
|
/// </summary>
|
|
[ToolboxItem(false), DesignTimeVisible(false)]
|
|
[TypeConverter(typeof(BlankExpandableObjectConverter))]
|
|
public class ChartLineVisualStyle : BaseVisualStyle
|
|
{
|
|
#region Private variables
|
|
|
|
private Color _LineColor = Color.Empty;
|
|
private LinePattern _LinePattern = LinePattern.NotSet;
|
|
private int _LineWidth = -1;
|
|
|
|
#endregion
|
|
|
|
#region Public properties
|
|
|
|
#region LineColor
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Line color.
|
|
/// </summary>
|
|
[Description("Indicates the Line color.")]
|
|
public Color LineColor
|
|
{
|
|
get { return (_LineColor); }
|
|
|
|
set
|
|
{
|
|
if (_LineColor != value)
|
|
{
|
|
_LineColor = value;
|
|
|
|
OnPropertyChangedEx("LineColor", VisualChangeType.Render);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets whether property should be serialized.
|
|
/// </summary>
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
private bool ShouldSerializeLineColor()
|
|
{
|
|
return (_LineColor.IsEmpty == false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resets property to its default value.
|
|
/// </summary>
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
private void ResetLineColor()
|
|
{
|
|
LineColor = Color.Empty;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region LinePattern
|
|
|
|
/// <summary>
|
|
/// Gets or sets the LinePattern.
|
|
/// </summary>
|
|
[DefaultValue(LinePattern.NotSet)]
|
|
[Description("Indicates the LinePattern.")]
|
|
public LinePattern LinePattern
|
|
{
|
|
get { return (_LinePattern); }
|
|
|
|
set
|
|
{
|
|
if (_LinePattern != value)
|
|
{
|
|
_LinePattern = value;
|
|
|
|
OnPropertyChangedEx("LinePattern", VisualChangeType.Render);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region LineWidth
|
|
|
|
/// <summary>
|
|
/// Gets or sets the line width.
|
|
/// </summary>
|
|
[DefaultValue(-1)]
|
|
[Description("Indicates the line width")]
|
|
public int LineWidth
|
|
{
|
|
get { return (_LineWidth); }
|
|
|
|
set
|
|
{
|
|
if (_LineWidth != value)
|
|
{
|
|
_LineWidth = value;
|
|
|
|
OnPropertyChangedEx("LineWidth", 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 ((_LineColor.IsEmpty) &&
|
|
(_LinePattern == LinePattern.NotSet) &&
|
|
(_LineWidth < 0) &&
|
|
(base.IsEmpty == true));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Internal properties
|
|
|
|
internal bool IsDisplayable
|
|
{
|
|
get
|
|
{
|
|
return (LineColor.IsEmpty == false &&
|
|
LinePattern != LinePattern.None &&
|
|
LineWidth > 0);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ApplyStyle
|
|
|
|
/// <summary>
|
|
/// Applies the style to instance of this style.
|
|
/// </summary>
|
|
/// <param name="style">Style to apply.</param>
|
|
public void ApplyStyle(ChartLineVisualStyle style)
|
|
{
|
|
if (style != null)
|
|
{
|
|
base.ApplyStyle(style);
|
|
|
|
if (style.LineColor.IsEmpty == false)
|
|
LineColor = style.LineColor;
|
|
|
|
if (style.LinePattern != LinePattern.NotSet)
|
|
LinePattern = style.LinePattern;
|
|
|
|
if (style.LineWidth >= 0)
|
|
LineWidth = style.LineWidth;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ApplyDefaults
|
|
|
|
public override void ApplyDefaults()
|
|
{
|
|
if (LinePattern == LinePattern.NotSet)
|
|
LinePattern = LinePattern.Solid;
|
|
|
|
if (LineWidth < 0)
|
|
LineWidth = 1;
|
|
|
|
base.ApplyDefaults();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Copy
|
|
|
|
/// <summary>
|
|
/// Returns the copy of the style.
|
|
/// </summary>
|
|
/// <returns>Copy of the style.</returns>
|
|
public new ChartLineVisualStyle Copy()
|
|
{
|
|
ChartLineVisualStyle style = new ChartLineVisualStyle();
|
|
|
|
CopyTo(style);
|
|
|
|
return (style);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CopyTo
|
|
|
|
/// <summary>
|
|
/// Returns the copy of the style.
|
|
/// </summary>
|
|
/// <returns>Copy of the style.</returns>
|
|
public void CopyTo(ChartLineVisualStyle style)
|
|
{
|
|
base.CopyTo(style);
|
|
|
|
style.LineColor = _LineColor;
|
|
style.LinePattern = _LinePattern;
|
|
style.LineWidth = _LineWidth;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GetSerialData
|
|
|
|
internal override SerialElementCollection GetSerialData(string serialName)
|
|
{
|
|
SerialElementCollection sec = new SerialElementCollection();
|
|
|
|
if (serialName != null)
|
|
{
|
|
if (serialName.Equals("") == true)
|
|
serialName = "ChartLineVisualStyle";
|
|
|
|
sec.AddStartElement(serialName);
|
|
}
|
|
|
|
sec.AddValue("LineColor", LineColor, Color.Empty);
|
|
sec.AddValue("LinePattern", LinePattern, LinePattern.NotSet);
|
|
sec.AddValue("LineWidth", LineWidth, -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 "LineColor":
|
|
LineColor = se.GetValueColor();
|
|
break;
|
|
|
|
case "LinePattern":
|
|
LinePattern = (LinePattern)se.GetValueEnum(typeof(LinePattern));
|
|
break;
|
|
|
|
case "LineWidth":
|
|
LineWidth = int.Parse(se.StringValue);
|
|
break;
|
|
|
|
default:
|
|
base.ProcessValue(se);
|
|
break;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region IDisposable
|
|
|
|
/// <summary>
|
|
/// Dispose
|
|
/// </summary>
|
|
public override void Dispose()
|
|
{
|
|
base.Dispose();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// Represents the visual style of a Chart CapLine
|
|
/// </summary>
|
|
[ToolboxItem(false), DesignTimeVisible(false)]
|
|
[TypeConverter(typeof(BlankExpandableObjectConverter))]
|
|
public class ChartCapLineVisualStyle : ChartLineVisualStyle
|
|
{
|
|
#region Private variables
|
|
|
|
private ChartLineCap _EndCap = ChartLineCap.NotSet;
|
|
private ChartLineCap _StartCap = ChartLineCap.NotSet;
|
|
|
|
#endregion
|
|
|
|
#region Public properties
|
|
|
|
#region EndCap
|
|
|
|
/// <summary>
|
|
/// Gets or sets the line EndCap.
|
|
/// </summary>
|
|
[DefaultValue(ChartLineCap.NotSet)]
|
|
[Description("Indicates the line End Cap.")]
|
|
public ChartLineCap EndCap
|
|
{
|
|
get { return (_EndCap); }
|
|
|
|
set
|
|
{
|
|
if (_EndCap != value)
|
|
{
|
|
_EndCap = value;
|
|
|
|
OnPropertyChangedEx("EndCap", VisualChangeType.Render);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region StartCap
|
|
|
|
/// <summary>
|
|
/// Gets or sets the line StartCap.
|
|
/// </summary>
|
|
[DefaultValue(ChartLineCap.NotSet)]
|
|
[Description("Indicates the line Start Cap.")]
|
|
public ChartLineCap StartCap
|
|
{
|
|
get { return (_StartCap); }
|
|
|
|
set
|
|
{
|
|
if (_StartCap != value)
|
|
{
|
|
_StartCap = value;
|
|
|
|
OnPropertyChangedEx("StartCap", 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 ((_EndCap == ChartLineCap.NotSet) &&
|
|
(_StartCap == ChartLineCap.NotSet) &&
|
|
(base.IsEmpty == true));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region ApplyStyle
|
|
|
|
/// <summary>
|
|
/// Applies the style to instance of this style.
|
|
/// </summary>
|
|
/// <param name="style">Style to apply.</param>
|
|
public void ApplyStyle(ChartCapLineVisualStyle style)
|
|
{
|
|
if (style != null)
|
|
{
|
|
base.ApplyStyle(style);
|
|
|
|
if (style.EndCap != ChartLineCap.NotSet)
|
|
_EndCap = style.EndCap;
|
|
|
|
if (style.StartCap != ChartLineCap.NotSet)
|
|
_StartCap = style.StartCap;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ApplyDefaults
|
|
|
|
public override void ApplyDefaults()
|
|
{
|
|
if (EndCap == ChartLineCap.NotSet)
|
|
EndCap = ChartLineCap.NoAnchor;
|
|
|
|
if (StartCap == ChartLineCap.NotSet)
|
|
StartCap = ChartLineCap.NoAnchor;
|
|
|
|
base.ApplyDefaults();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Copy
|
|
|
|
/// <summary>
|
|
/// Returns the copy of the style.
|
|
/// </summary>
|
|
/// <returns>Copy of the style.</returns>
|
|
public new ChartCapLineVisualStyle Copy()
|
|
{
|
|
ChartCapLineVisualStyle style = new ChartCapLineVisualStyle();
|
|
|
|
CopyTo(style);
|
|
|
|
return (style);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CopyTo
|
|
|
|
/// <summary>
|
|
/// Returns the copy of the style.
|
|
/// </summary>
|
|
/// <returns>Copy of the style.</returns>
|
|
public void CopyTo(ChartCapLineVisualStyle style)
|
|
{
|
|
base.CopyTo(style);
|
|
|
|
style.EndCap = _EndCap;
|
|
style.StartCap = _StartCap;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GetSerialData
|
|
|
|
internal override SerialElementCollection GetSerialData(string serialName)
|
|
{
|
|
SerialElementCollection sec = new SerialElementCollection();
|
|
|
|
if (serialName != null)
|
|
{
|
|
if (serialName.Equals("") == true)
|
|
serialName = "ChartCapLineVisualStyle";
|
|
|
|
sec.AddStartElement(serialName);
|
|
}
|
|
|
|
sec.AddValue("EndCap", EndCap, ChartLineCap.NotSet);
|
|
sec.AddValue("StartCap", StartCap, ChartLineCap.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 "EndCap":
|
|
EndCap = (ChartLineCap)se.GetValueEnum(typeof(ChartLineCap));
|
|
break;
|
|
|
|
case "StartCap":
|
|
StartCap = (ChartLineCap)se.GetValueEnum(typeof(ChartLineCap));
|
|
break;
|
|
|
|
default:
|
|
base.ProcessValue(se);
|
|
break;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region IDisposable
|
|
|
|
/// <summary>
|
|
/// Dispose
|
|
/// </summary>
|
|
public override void Dispose()
|
|
{
|
|
base.Dispose();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|