301 lines
7.9 KiB
C#
301 lines
7.9 KiB
C#
using System.ComponentModel;
|
|
using System.Drawing;
|
|
|
|
namespace DevComponents.DotNetBar.Charts.Style
|
|
{
|
|
/// <summary>
|
|
/// Represents the visual style of a Chart Ticmark element.
|
|
/// </summary>
|
|
[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
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Tickmark alignment.
|
|
/// </summary>
|
|
[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
|
|
|
|
///<summary>
|
|
/// Gets or sets the Tickmark Color.
|
|
///</summary>
|
|
[Category("Appearance")]
|
|
[Description("Indicates the Tickmark Color.")]
|
|
public Color TickmarkColor
|
|
{
|
|
get { return (_TickmarkColor); }
|
|
|
|
set
|
|
{
|
|
if (value != _TickmarkColor)
|
|
{
|
|
_TickmarkColor = value;
|
|
|
|
OnPropertyChangedEx("TickmarkColor", Style.VisualChangeType.Render);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets whether property should be serialized.
|
|
/// </summary>
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
public bool ShouldSerializeTickmarkColor()
|
|
{
|
|
return (_TickmarkColor.IsEmpty == false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resets property to its default value.
|
|
/// </summary>
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
public void ResetTickmarkColor()
|
|
{
|
|
TickmarkColor = Color.Empty;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region TickmarkLength
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Tickmark length.
|
|
/// </summary>
|
|
[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
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Tickmark Thickness.
|
|
/// </summary>
|
|
[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
|
|
|
|
/// <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 ((_TickmarkAlignment == LineAlignment.NotSet) &&
|
|
(_TickmarkColor.IsEmpty == true) &&
|
|
(_TickmarkLength < 0) &&
|
|
(_TickmarkThickness < 0) &&
|
|
(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(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
|
|
|
|
/// <summary>
|
|
/// Returns the copy of the style.
|
|
/// </summary>
|
|
/// <returns>Copy of the style.</returns>
|
|
public new ChartTickmarkVisualStyle Copy()
|
|
{
|
|
ChartTickmarkVisualStyle style = new ChartTickmarkVisualStyle();
|
|
|
|
CopyTo(style);
|
|
|
|
return (style);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CopyTo
|
|
|
|
/// <summary>
|
|
/// Returns the copy of the style.
|
|
/// </summary>
|
|
/// <returns>Copy of the style.</returns>
|
|
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
|
|
|
|
/// <summary>
|
|
/// Dispose
|
|
/// </summary>
|
|
public override void Dispose()
|
|
{
|
|
base.Dispose();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|