using System.ComponentModel; using System.Drawing; namespace DevComponents.DotNetBar.Charts.Style { /// /// ChartLegendVisualStyles /// [TypeConverter(typeof(VisualStylesConverter))] public class ChartLegendVisualStyles : VisualStyles { #region Copy /// /// Returns the copy of the style. /// /// Copy of the style. public ChartLegendVisualStyles Copy() { ChartLegendVisualStyles styles = new ChartLegendVisualStyles(); for (int i = 0; i < Styles.Length; i++) { ChartLegendVisualStyle vstyle = Styles[i]; if (vstyle != null) styles.Styles[i] = vstyle.Copy(); } return (styles); } #endregion } /// /// Represents the visual style of a Legend element. /// [TypeConverter(typeof(VisualStylesConverter))] public class ChartLegendVisualStyle : ContainerVisualStyle { #region Private variables private Tbool _EquallySpacedItems = Tbool.NotSet; private int _HorizontalSpacing = -1; private int _VerticalSpacing = -1; #endregion #region Public properties #region EquallySpacedItems /// /// Gets or sets whether the items in the Legend are equally spaced. /// [DefaultValue(Tbool.NotSet), Category("Appearance")] [Description("Indicates whether the items in the Legend are equally spaced.")] public Tbool EquallySpacedItems { get { return (_EquallySpacedItems); } set { if (value != _EquallySpacedItems) { _EquallySpacedItems = value; OnPropertyChangedEx("EquallySpacedItems", VisualChangeType.Layout); } } } #endregion #region HorizontalSpacing /// /// Gets or sets the horizontal spacing of the legend items. /// [DefaultValue(-1), Category("Appearance")] [Description("Indicates the horizontal spacing of the legend items.")] public int HorizontalSpacing { get { return (_HorizontalSpacing); } set { if (value != _HorizontalSpacing) { _HorizontalSpacing = value; OnPropertyChangedEx("HorizontalSpacing", VisualChangeType.Layout); } } } #endregion #region VerticalSpacing /// /// Gets or sets the vertical spacing of the legend items. /// [DefaultValue(-1), Category("Appearance")] [Description("Indicates the vertical spacing of the legend items.")] public int VerticalSpacing { get { return (_VerticalSpacing); } set { if (value != _VerticalSpacing) { _VerticalSpacing = value; OnPropertyChangedEx("VerticalSpacing", VisualChangeType.Layout); } } } #endregion #region IsEmpty /// /// Gets whether the style is logically Empty. /// [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Gets whether the style is logically Empty.")] public override bool IsEmpty { get { return ((_EquallySpacedItems == Tbool.NotSet) && (_HorizontalSpacing == -1) && (_VerticalSpacing == -1) && (base.IsEmpty == true)); } } #endregion #endregion #region Hidden properties #region Alignment /// /// Gets or sets the alignment of the text /// [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new Alignment Alignment { get { return (base.Alignment); } set { base.Alignment = value; } } #endregion #region AllowWrap /// /// Gets or sets whether text wrapping is permitted /// [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new Tbool AllowWrap { get { return (base.AllowWrap); } set { base.AllowWrap = value; } } #endregion #region Font /// /// Gets or sets the style Font /// [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new Font Font { get { return (base.Font); } set { base.Font = value; } } #endregion #region TextColor /// /// Gets or sets the Text color /// [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new Color TextColor { get { return (base.TextColor); } set { base.TextColor = value; } } #endregion #endregion #region ApplyStyle /// /// Applies the style to instance of this style. /// /// Style to apply. public void ApplyStyle(ChartLegendVisualStyle style) { if (style != null) { base.ApplyStyle(style); if (style.EquallySpacedItems != Tbool.NotSet) EquallySpacedItems = style.EquallySpacedItems; if (style.HorizontalSpacing != -1) HorizontalSpacing = style.HorizontalSpacing; if (style.VerticalSpacing != -1) VerticalSpacing = style.VerticalSpacing; } } #endregion #region ApplyDefaults public override void ApplyDefaults() { base.ApplyDefaults(); if (VerticalSpacing < 0) VerticalSpacing = 2; if (HorizontalSpacing < 0) HorizontalSpacing = 2; if (BorderPattern == null) BorderPattern = new BorderPattern(LinePattern.Solid); if (DropShadow.Enabled == Tbool.NotSet) DropShadow.Enabled = Tbool.False; } #endregion #region Copy /// /// Returns the copy of the style. /// /// Copy of the style. public new ChartLegendVisualStyle Copy() { ChartLegendVisualStyle style = new ChartLegendVisualStyle(); CopyTo(style); return (style); } #endregion #region CopyTo /// /// Returns the copy of the style. /// /// Copy of the style. public void CopyTo(ChartLegendVisualStyle style) { base.CopyTo(style); style.HorizontalSpacing = _HorizontalSpacing; style.EquallySpacedItems = _EquallySpacedItems; style.VerticalSpacing = _VerticalSpacing; } #endregion #region GetSerialData internal override SerialElementCollection GetSerialData(string serialName) { SerialElementCollection sec = new SerialElementCollection(); if (serialName != null) { if (serialName.Equals("") == true) serialName = "ChartLegendVisualStyle"; sec.AddStartElement(serialName); } sec.AddValue("HorizontalSpacing", HorizontalSpacing, -1); sec.AddValue("EquallySpacedItems", EquallySpacedItems, Tbool.NotSet); sec.AddValue("VerticalSpacing", VerticalSpacing, -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 "HorizontalSpacing": HorizontalSpacing = int.Parse(se.StringValue); break; case "EquallySpacedItems": EquallySpacedItems = (Tbool)se.GetValueEnum(typeof(Tbool)); break; case "VerticalSpacing": VerticalSpacing = int.Parse(se.StringValue); break; default: base.ProcessValue(se); break; } } #endregion #endregion } }