389 lines
11 KiB
C#
389 lines
11 KiB
C#
using System.ComponentModel;
|
|
using System.Drawing.Design;
|
|
|
|
namespace DevComponents.DotNetBar.Charts.Style
|
|
{
|
|
/// <summary>
|
|
/// Represents the visual style of a Bar Series
|
|
/// </summary>
|
|
[ToolboxItem(false), DesignTimeVisible(false)]
|
|
[TypeConverter(typeof(VisualStylesConverter))]
|
|
public class ChartBarVisualStyle : BaseVisualStyle
|
|
{
|
|
#region Private variables
|
|
|
|
private ChartLineVisualStyle _Border;
|
|
private ChartLineVisualStyle _AlternateBorder;
|
|
|
|
private Background _Background;
|
|
private Background _AlternateBackground;
|
|
|
|
#endregion
|
|
|
|
#region Public properties
|
|
|
|
#region AlternateBackground
|
|
|
|
/// <summary>
|
|
/// Gets or sets the background for the bar, when it
|
|
/// extends to the alternate side of the bar origin.
|
|
/// </summary>
|
|
[Description("Indicates the background for the bar, when it extends to the alternate side of the bar origin.")]
|
|
public Background AlternateBackground
|
|
{
|
|
get
|
|
{
|
|
if (_AlternateBackground == null)
|
|
{
|
|
_AlternateBackground = Background.Empty;
|
|
|
|
UpdateChangeHandler(null, _AlternateBackground);
|
|
}
|
|
|
|
return (_AlternateBackground);
|
|
}
|
|
|
|
set
|
|
{
|
|
if (_AlternateBackground != value)
|
|
{
|
|
UpdateChangeHandler(_AlternateBackground, value);
|
|
|
|
_AlternateBackground = value;
|
|
|
|
OnPropertyChangedEx("AlternateBackground", VisualChangeType.Render);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets whether property should be serialized.
|
|
/// </summary>
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
private bool ShouldSerializeAlternateBackground()
|
|
{
|
|
return (_AlternateBackground != null && _AlternateBackground.IsEmpty == false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resets property to its default value.
|
|
/// </summary>
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
private void ResetAlternateBackground()
|
|
{
|
|
AlternateBackground = null;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region AlternateBorder
|
|
|
|
/// <summary>
|
|
/// Gets or sets the border style for the bar, when it
|
|
/// extends to the alternate side of the bar origin.
|
|
/// </summary>
|
|
[Category("Style")]
|
|
[Description("Indicates the border style for the bar, when it extends to the alternate side of the bar origin.")]
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
|
public ChartLineVisualStyle AlternateBorder
|
|
{
|
|
get
|
|
{
|
|
if (_AlternateBorder == null)
|
|
{
|
|
_AlternateBorder = new ChartLineVisualStyle();
|
|
|
|
UpdateChangeHandler(null, _AlternateBorder);
|
|
}
|
|
|
|
return (_AlternateBorder);
|
|
}
|
|
|
|
set
|
|
{
|
|
if (_AlternateBorder != value)
|
|
{
|
|
ChartLineVisualStyle oldValue = _AlternateBorder;
|
|
|
|
_AlternateBorder = value;
|
|
|
|
OnStyleChanged("AlternateBorder", oldValue, value);
|
|
|
|
if (oldValue != null)
|
|
oldValue.Dispose();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Background
|
|
|
|
/// <summary>
|
|
/// Gets or sets the background for the bar.
|
|
/// </summary>
|
|
[Description("Indicates the background for the bar.")]
|
|
public Background Background
|
|
{
|
|
get
|
|
{
|
|
if (_Background == null)
|
|
{
|
|
_Background = Background.Empty;
|
|
|
|
UpdateChangeHandler(null, _Background);
|
|
}
|
|
|
|
return (_Background);
|
|
}
|
|
|
|
set
|
|
{
|
|
if (_Background != value)
|
|
{
|
|
UpdateChangeHandler(_Background, value);
|
|
|
|
_Background = value;
|
|
|
|
OnPropertyChangedEx("Background", VisualChangeType.Render);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets whether property should be serialized.
|
|
/// </summary>
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
private bool ShouldSerializeBackground()
|
|
{
|
|
return (_Background != null && _Background.IsEmpty == false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resets property to its default value.
|
|
/// </summary>
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
private void ResetBackground()
|
|
{
|
|
Background = null;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Border
|
|
|
|
/// <summary>
|
|
/// Gets or sets the border style for the bar.
|
|
/// </summary>
|
|
[Category("Style")]
|
|
[Description("Indicates the border style for the bar.")]
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
|
public ChartLineVisualStyle Border
|
|
{
|
|
get
|
|
{
|
|
if (_Border == null)
|
|
{
|
|
_Border = new ChartLineVisualStyle();
|
|
|
|
UpdateChangeHandler(null, _Border);
|
|
}
|
|
|
|
return (_Border);
|
|
}
|
|
|
|
set
|
|
{
|
|
if (_Border != value)
|
|
{
|
|
ChartLineVisualStyle oldValue = _Border;
|
|
|
|
_Border = value;
|
|
|
|
OnStyleChanged("Border", oldValue, value);
|
|
|
|
if (oldValue != null)
|
|
oldValue.Dispose();
|
|
}
|
|
}
|
|
}
|
|
|
|
#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 ((_AlternateBackground == null || _AlternateBackground.IsEmpty == true) &&
|
|
(_AlternateBorder == null || _AlternateBorder.IsEmpty) &&
|
|
(_Background == null || _Background.IsEmpty) &&
|
|
(_Border == null || _Border.IsEmpty) &&
|
|
(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(ChartBarVisualStyle style)
|
|
{
|
|
if (style != null)
|
|
{
|
|
base.ApplyStyle(style);
|
|
|
|
if (style._AlternateBackground != null && style._AlternateBackground.IsEmpty == false)
|
|
AlternateBackground = style._AlternateBackground.Copy();
|
|
|
|
if (style._AlternateBorder != null && style._AlternateBorder.IsEmpty == false)
|
|
AlternateBorder.ApplyStyle(style._AlternateBorder);
|
|
|
|
if (style._Background != null && style._Background.IsEmpty == false)
|
|
Background = style._Background.Copy();
|
|
|
|
if (style._Border != null && style._Border.IsEmpty == false)
|
|
Border.ApplyStyle(style._Border);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Copy
|
|
|
|
/// <summary>
|
|
/// Returns the copy of the style.
|
|
/// </summary>
|
|
/// <returns>Copy of the style.</returns>
|
|
public new ChartBarVisualStyle Copy()
|
|
{
|
|
ChartBarVisualStyle style = new ChartBarVisualStyle();
|
|
|
|
CopyTo(style);
|
|
|
|
return (style);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CopyTo
|
|
|
|
/// <summary>
|
|
/// Returns the copy of the style.
|
|
/// </summary>
|
|
/// <returns>Copy of the style.</returns>
|
|
public void CopyTo(ChartBarVisualStyle style)
|
|
{
|
|
base.CopyTo(style);
|
|
|
|
style.AlternateBackground = (_AlternateBackground != null) ? _AlternateBackground.Copy() : null;
|
|
style.AlternateBorder = (_AlternateBorder != null) ? _AlternateBorder.Copy() : null;
|
|
style.Background = (_Background != null) ? _Background.Copy() : null;
|
|
style.Border = (_Border != null) ? _Border.Copy() : null;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GetSerialData
|
|
|
|
internal override SerialElementCollection GetSerialData(string serialName)
|
|
{
|
|
SerialElementCollection sec = new SerialElementCollection();
|
|
|
|
if (serialName != null)
|
|
{
|
|
if (serialName.Equals("") == true)
|
|
serialName = "ChartBarVisualStyle";
|
|
|
|
sec.AddStartElement(serialName);
|
|
}
|
|
|
|
if (_AlternateBackground != null && _AlternateBackground.IsEmpty == false)
|
|
sec.AddElement(_AlternateBackground.GetSerialData("AlternateBackground"));
|
|
|
|
if (_AlternateBorder != null && _AlternateBorder.IsEmpty == false)
|
|
sec.AddElement(_AlternateBorder.GetSerialData("AlternateBorder"));
|
|
|
|
if (_Background != null && _Background.IsEmpty == false)
|
|
sec.AddElement(_Background.GetSerialData("Background"));
|
|
|
|
if (_Border != null && _Border.IsEmpty == false)
|
|
sec.AddElement(_Border.GetSerialData("Border"));
|
|
|
|
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 "AlternateBackground":
|
|
sec.PutSerialData(AlternateBackground);
|
|
break;
|
|
|
|
case "AlternateBorder":
|
|
sec.PutSerialData(AlternateBorder);
|
|
break;
|
|
|
|
case "Background":
|
|
sec.PutSerialData(Background);
|
|
break;
|
|
|
|
case "Border":
|
|
sec.PutSerialData(Border);
|
|
break;
|
|
|
|
default:
|
|
base.ProcessCollection(se);
|
|
break;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region IDisposable
|
|
|
|
/// <summary>
|
|
/// Dispose
|
|
/// </summary>
|
|
public override void Dispose()
|
|
{
|
|
AlternateBackground = null;
|
|
Background = null;
|
|
Border = null;
|
|
|
|
base.Dispose();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|