399 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			399 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.ComponentModel;
 | 
						|
using System.Drawing;
 | 
						|
 | 
						|
namespace DevComponents.DotNetBar.Charts.Style
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    /// Represents the visual style of an XY Chart element.
 | 
						|
    /// </summary>
 | 
						|
    [TypeConverter(typeof(BlankExpandableObjectConverter))]
 | 
						|
    public class ChartXyVisualStyle : ContainerVisualStyle
 | 
						|
    {
 | 
						|
        #region Private variables
 | 
						|
 | 
						|
        private ScrollBarVisualStyles _HScrollBarVisualStyles;
 | 
						|
        private ScrollBarVisualStyles _VScrollBarVisualStyles;
 | 
						|
 | 
						|
        private int _InterSeriesGap = -1;
 | 
						|
        private int _IntraSeriesGap = -1;
 | 
						|
 | 
						|
        private Tbool _AutoExpandIntraSeriesGap = Tbool.NotSet;
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Public properties
 | 
						|
 | 
						|
        #region AutoExpandIntraSeriesGap
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets whether to auto adjust the IntraSeriesGap when space permits.
 | 
						|
        /// </summary>
 | 
						|
        [Description("Indicates whether to auto adjust the IntraSeriesGap when space permits.")]
 | 
						|
        [DefaultValue(Tbool.NotSet)]
 | 
						|
        public Tbool AutoExpandIntraSeriesGap
 | 
						|
        {
 | 
						|
            get { return (_AutoExpandIntraSeriesGap); }
 | 
						|
 | 
						|
            set
 | 
						|
            {
 | 
						|
                if (value != _AutoExpandIntraSeriesGap)
 | 
						|
                {
 | 
						|
                    _AutoExpandIntraSeriesGap = value;
 | 
						|
 | 
						|
                    OnPropertyChangedEx("AutoExpandIntraSeriesGap", VisualChangeType.Layout);
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region HScrollBarVisualStyles
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets the visual styles to be used for Horizontal ScrollBar elements 
 | 
						|
        /// </summary>
 | 
						|
        [Category("Style")]
 | 
						|
        [Description("Indicates visual styles to be used for Horizontal ScrollBar elements ")]
 | 
						|
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
 | 
						|
        public ScrollBarVisualStyles HScrollBarVisualStyles
 | 
						|
        {
 | 
						|
            get
 | 
						|
            {
 | 
						|
                if (_HScrollBarVisualStyles == null)
 | 
						|
                {
 | 
						|
                    _HScrollBarVisualStyles = new ScrollBarVisualStyles();
 | 
						|
 | 
						|
                    UpdateChangeHandler(null, _HScrollBarVisualStyles);
 | 
						|
                }
 | 
						|
 | 
						|
                return (_HScrollBarVisualStyles);
 | 
						|
            }
 | 
						|
 | 
						|
            set
 | 
						|
            {
 | 
						|
                if (_HScrollBarVisualStyles != value)
 | 
						|
                {
 | 
						|
                    ScrollBarVisualStyles oldValue = _HScrollBarVisualStyles;
 | 
						|
                    _HScrollBarVisualStyles = value;
 | 
						|
 | 
						|
                    OnStyleChanged("HScrollBarVisualStyles", oldValue, value);
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region InterSeriesGap
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets the pixel gap between grouped, qualitative series.
 | 
						|
        /// </summary>
 | 
						|
        [Description("Indicates the pixel gap between grouped, qualitative series.")]
 | 
						|
        [DefaultValue(-1)]
 | 
						|
        public int InterSeriesGap
 | 
						|
        {
 | 
						|
            get { return (_InterSeriesGap); }
 | 
						|
 | 
						|
            set
 | 
						|
            {
 | 
						|
                if (value != _InterSeriesGap)
 | 
						|
                {
 | 
						|
                    _InterSeriesGap = value;
 | 
						|
 | 
						|
                    OnPropertyChangedEx("InterSeriesGap", VisualChangeType.Layout);
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region IntraSeriesGap
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets the pixel gap between each series in a set of grouped, qualitative series.
 | 
						|
        /// </summary>
 | 
						|
        [Description("Indicates the pixel gap between each series in a set of grouped, qualitative series.")]
 | 
						|
        [DefaultValue(-1)]
 | 
						|
        public int IntraSeriesGap
 | 
						|
        {
 | 
						|
            get { return (_IntraSeriesGap); }
 | 
						|
 | 
						|
            set
 | 
						|
            {
 | 
						|
                if (value != _IntraSeriesGap)
 | 
						|
                {
 | 
						|
                    _IntraSeriesGap = value;
 | 
						|
 | 
						|
                    OnPropertyChangedEx("IntraSeriesGap", VisualChangeType.Layout);
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region VScrollBarVisualStyles
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Gets or sets the visual styles to be used for Vertical ScrollBar elements 
 | 
						|
        /// </summary>
 | 
						|
        [Category("Style")]
 | 
						|
        [Description("Indicates visual styles to be used for Vertical ScrollBar elements ")]
 | 
						|
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
 | 
						|
        public ScrollBarVisualStyles VScrollBarVisualStyles
 | 
						|
        {
 | 
						|
            get
 | 
						|
            {
 | 
						|
                if (_VScrollBarVisualStyles == null)
 | 
						|
                {
 | 
						|
                    _VScrollBarVisualStyles = new ScrollBarVisualStyles();
 | 
						|
 | 
						|
                    UpdateChangeHandler(null, _VScrollBarVisualStyles);
 | 
						|
                }
 | 
						|
 | 
						|
                return (_VScrollBarVisualStyles);
 | 
						|
            }
 | 
						|
 | 
						|
            set
 | 
						|
            {
 | 
						|
                if (_VScrollBarVisualStyles != value)
 | 
						|
                {
 | 
						|
                    ScrollBarVisualStyles oldValue = _VScrollBarVisualStyles;
 | 
						|
                    _VScrollBarVisualStyles = value;
 | 
						|
 | 
						|
                    OnStyleChanged("VScrollBarVisualStyles", oldValue, value);
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #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 ((_InterSeriesGap < 0) &&
 | 
						|
                    (_IntraSeriesGap < 0) &&
 | 
						|
                    (_VScrollBarVisualStyles == null) &&
 | 
						|
                    (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(ChartXyVisualStyle style)
 | 
						|
        {
 | 
						|
            if (style != null)
 | 
						|
            {
 | 
						|
                base.ApplyStyle(style);
 | 
						|
 | 
						|
                if (style.AutoExpandIntraSeriesGap != Tbool.NotSet)
 | 
						|
                    _AutoExpandIntraSeriesGap = style.AutoExpandIntraSeriesGap;
 | 
						|
 | 
						|
                if (style.InterSeriesGap >= 0)
 | 
						|
                    _InterSeriesGap = style.InterSeriesGap;
 | 
						|
 | 
						|
                if (style.IntraSeriesGap >= 0)
 | 
						|
                    _IntraSeriesGap = style.IntraSeriesGap;
 | 
						|
 | 
						|
                if (style.HScrollBarVisualStyles != null)
 | 
						|
                {
 | 
						|
                    for (int i = 0; i < style.HScrollBarVisualStyles.Styles.Length; i++)
 | 
						|
                    {
 | 
						|
                        if (style.HScrollBarVisualStyles.Styles[i] != null)
 | 
						|
                            HScrollBarVisualStyles.GetStyle(i).ApplyStyle(style.HScrollBarVisualStyles.Styles[i]);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
 | 
						|
                if (style.VScrollBarVisualStyles != null)
 | 
						|
                {
 | 
						|
                    for (int i = 0; i < style.VScrollBarVisualStyles.Styles.Length; i++)
 | 
						|
                    {
 | 
						|
                        if (style.VScrollBarVisualStyles.Styles[i] != null)
 | 
						|
                            VScrollBarVisualStyles.GetStyle(i).ApplyStyle(style.VScrollBarVisualStyles.Styles[i]);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region ApplyDefaults
 | 
						|
 | 
						|
        public override void ApplyDefaults()
 | 
						|
        {
 | 
						|
            if (BorderPattern == null)
 | 
						|
                BorderPattern = new BorderPattern(LinePattern.Solid);
 | 
						|
 | 
						|
            if (InterSeriesGap < 0)
 | 
						|
                InterSeriesGap = 2;
 | 
						|
 | 
						|
            if (IntraSeriesGap < 0)
 | 
						|
                IntraSeriesGap = 2;
 | 
						|
 | 
						|
            if (AutoExpandIntraSeriesGap == Tbool.NotSet)
 | 
						|
                AutoExpandIntraSeriesGap = Tbool.True;
 | 
						|
 | 
						|
            if (DropShadow.Enabled == Tbool.NotSet)
 | 
						|
                DropShadow.Enabled = Tbool.False;
 | 
						|
 | 
						|
            base.ApplyDefaults();
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Copy
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Returns the copy of the style.
 | 
						|
        /// </summary>
 | 
						|
        /// <returns>Copy of the style.</returns>
 | 
						|
        public new ChartXyVisualStyle Copy()
 | 
						|
        {
 | 
						|
            ChartXyVisualStyle style = new ChartXyVisualStyle();
 | 
						|
 | 
						|
            CopyTo(style);
 | 
						|
 | 
						|
            return (style);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region CopyTo
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Returns the copy of the style.
 | 
						|
        /// </summary>
 | 
						|
        /// <returns>Copy of the style.</returns>
 | 
						|
        public void CopyTo(ChartXyVisualStyle style)
 | 
						|
        {
 | 
						|
            base.CopyTo(style);
 | 
						|
 | 
						|
            style.AutoExpandIntraSeriesGap = _AutoExpandIntraSeriesGap;
 | 
						|
            style.InterSeriesGap = _InterSeriesGap;
 | 
						|
            style.IntraSeriesGap = _IntraSeriesGap;
 | 
						|
 | 
						|
            style.HScrollBarVisualStyles = (_HScrollBarVisualStyles != null) ? _HScrollBarVisualStyles.Copy() : null;
 | 
						|
            style.VScrollBarVisualStyles = (_VScrollBarVisualStyles != null) ? _VScrollBarVisualStyles.Copy() : null;
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region GetSerialData
 | 
						|
 | 
						|
        internal override SerialElementCollection GetSerialData(string serialName)
 | 
						|
        {
 | 
						|
            SerialElementCollection sec = new SerialElementCollection();
 | 
						|
 | 
						|
            if (serialName != null)
 | 
						|
            {
 | 
						|
                if (serialName.Equals("") == true)
 | 
						|
                    serialName = "ChartXyVisualStyle";
 | 
						|
 | 
						|
                sec.AddStartElement(serialName);
 | 
						|
            }
 | 
						|
 | 
						|
            sec.AddValue("AutoExpandIntraSeriesGap", AutoExpandIntraSeriesGap, Tbool.NotSet);
 | 
						|
            sec.AddValue("InterSeriesGap", InterSeriesGap, -1);
 | 
						|
            sec.AddValue("IntraSeriesGap", IntraSeriesGap, -1);
 | 
						|
 | 
						|
            if (_HScrollBarVisualStyles != null && _HScrollBarVisualStyles.IsEmpty == false)
 | 
						|
                sec.AddElement(_HScrollBarVisualStyles.GetSerialData("HScrollBarVisualStyles"));
 | 
						|
 | 
						|
            if (_VScrollBarVisualStyles != null && _VScrollBarVisualStyles.IsEmpty == false)
 | 
						|
                sec.AddElement(_VScrollBarVisualStyles.GetSerialData("VScrollBarVisualStyles"));
 | 
						|
 | 
						|
            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 "AutoExpandIntraSeriesGap":
 | 
						|
                    AutoExpandIntraSeriesGap = (Tbool)se.GetValueEnum(typeof(Tbool));
 | 
						|
                    break;
 | 
						|
 | 
						|
                case "InterSeriesGap":
 | 
						|
                    InterSeriesGap = int.Parse(se.StringValue);
 | 
						|
                    break;
 | 
						|
 | 
						|
                case "IntraSeriesGap":
 | 
						|
                    IntraSeriesGap = int.Parse(se.StringValue);
 | 
						|
                    break;
 | 
						|
 | 
						|
                default:
 | 
						|
                    base.ProcessValue(se);
 | 
						|
                    break;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region ProcessCollection
 | 
						|
 | 
						|
        internal override void ProcessCollection(SerialElement se)
 | 
						|
        {
 | 
						|
            SerialElementCollection sec = se.Sec;
 | 
						|
 | 
						|
            switch (se.Name)
 | 
						|
            {
 | 
						|
                case "HScrollBarVisualStyles":
 | 
						|
                    sec.PutSerialData(HScrollBarVisualStyles);
 | 
						|
                    break;
 | 
						|
 | 
						|
                case "VScrollBarVisualStyles":
 | 
						|
                    sec.PutSerialData(HScrollBarVisualStyles);
 | 
						|
                    break;
 | 
						|
 | 
						|
                default:
 | 
						|
                    base.ProcessCollection(se);
 | 
						|
                    break;
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region IDisposable
 | 
						|
 | 
						|
        public override void Dispose()
 | 
						|
        {
 | 
						|
            HScrollBarVisualStyles = null;
 | 
						|
            VScrollBarVisualStyles = null;
 | 
						|
 | 
						|
            base.Dispose();
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
}
 |