352 lines
		
	
	
		
			9.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			352 lines
		
	
	
		
			9.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System.ComponentModel;
 | 
						|
using System.Drawing;
 | 
						|
 | 
						|
namespace DevComponents.DotNetBar.Charts.Style
 | 
						|
{
 | 
						|
    ///<summary>
 | 
						|
    /// ChartLegendVisualStyles
 | 
						|
    ///</summary>
 | 
						|
    [TypeConverter(typeof(VisualStylesConverter))]
 | 
						|
    public class ChartLegendVisualStyles : VisualStyles<ChartLegendVisualStyle>
 | 
						|
    {
 | 
						|
        #region Copy
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Returns the copy of the style.
 | 
						|
        /// </summary>
 | 
						|
        /// <returns>Copy of the style.</returns>
 | 
						|
        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
 | 
						|
    }
 | 
						|
 | 
						|
    /// <summary>
 | 
						|
    /// Represents the visual style of a Legend element.
 | 
						|
    /// </summary>
 | 
						|
    [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
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets whether the items in the Legend are equally spaced.
 | 
						|
        /// </summary>
 | 
						|
        [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
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets the horizontal spacing of the legend items.
 | 
						|
        /// </summary>
 | 
						|
        [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
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets the vertical spacing of the legend items.
 | 
						|
        /// </summary>
 | 
						|
        [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
 | 
						|
 | 
						|
        /// <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 ((_EquallySpacedItems == Tbool.NotSet) &&
 | 
						|
                    (_HorizontalSpacing == -1) &&
 | 
						|
                    (_VerticalSpacing == -1) &&
 | 
						|
                    (base.IsEmpty == true));
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Hidden properties
 | 
						|
 | 
						|
        #region Alignment
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets the alignment of the text
 | 
						|
        /// </summary>
 | 
						|
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
 | 
						|
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 | 
						|
        public new Alignment Alignment
 | 
						|
        {
 | 
						|
            get { return (base.Alignment); }
 | 
						|
            set { base.Alignment = value; }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region AllowWrap
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets whether text wrapping is permitted
 | 
						|
        /// </summary>
 | 
						|
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
 | 
						|
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 | 
						|
        public new Tbool AllowWrap
 | 
						|
        {
 | 
						|
            get { return (base.AllowWrap); }
 | 
						|
            set { base.AllowWrap = value; }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Font
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets the style Font
 | 
						|
        /// </summary>
 | 
						|
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
 | 
						|
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 | 
						|
        public new Font Font
 | 
						|
        {
 | 
						|
            get { return (base.Font); }
 | 
						|
            set { base.Font = value; }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region TextColor
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets the Text color
 | 
						|
        /// </summary>
 | 
						|
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
 | 
						|
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 | 
						|
        public new Color TextColor
 | 
						|
        {
 | 
						|
            get { return (base.TextColor); }
 | 
						|
            set { base.TextColor = value; }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region ApplyStyle
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Applies the style to instance of this style.
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="style">Style to apply.</param>
 | 
						|
        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
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Returns the copy of the style.
 | 
						|
        /// </summary>
 | 
						|
        /// <returns>Copy of the style.</returns>
 | 
						|
        public new ChartLegendVisualStyle Copy()
 | 
						|
        {
 | 
						|
            ChartLegendVisualStyle style = new ChartLegendVisualStyle();
 | 
						|
 | 
						|
            CopyTo(style);
 | 
						|
 | 
						|
            return (style);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region CopyTo
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Returns the copy of the style.
 | 
						|
        /// </summary>
 | 
						|
        /// <returns>Copy of the style.</returns>
 | 
						|
        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
 | 
						|
    }
 | 
						|
}
 |