1481 lines
		
	
	
		
			38 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			1481 lines
		
	
	
		
			38 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.ComponentModel;
 | |
| using System.Drawing;
 | |
| using System.Drawing.Design;
 | |
| using System.Drawing.Drawing2D;
 | |
| using System.Windows.Forms;
 | |
| using DevComponents.DotNetBar.Charts.Style;
 | |
| 
 | |
| namespace DevComponents.DotNetBar.Charts
 | |
| {
 | |
|     /// <summary>
 | |
|     /// Represents the collection of ChartIndicators.
 | |
|     /// </summary>
 | |
|     [Editor("DevComponents.Charts.Design.IndicatorCollectionEditor, DevComponents.Charts.Design, " +
 | |
|         "Version=14.1.0.37, Culture=neutral,  PublicKeyToken=90f470f34c89ccaf", typeof(UITypeEditor))]
 | |
|     public class ChartIndicatorCollection : CustomNamedCollection<ChartIndicator>
 | |
|     {
 | |
|     }
 | |
| 
 | |
|     #region RegressionLine
 | |
| 
 | |
|     /// <summary>
 | |
|     /// Represents a Regression Line (a least-squares calculated series line).
 | |
|     /// </summary>
 | |
|     public class RegressionLine : ChartIndicator, IEffectiveStyle
 | |
|     {
 | |
|         #region Private variables
 | |
| 
 | |
|         private RegressionLineVisualStyle _RegressionLineVisualStyle;
 | |
|         private EffectiveStyle<RegressionLineVisualStyle> _EffectiveStyle;
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region Constructors
 | |
| 
 | |
|         public RegressionLine(string name)
 | |
|             : this()
 | |
|         {
 | |
|             Name = name;
 | |
|         }
 | |
| 
 | |
|         public RegressionLine()
 | |
|         {
 | |
|             InitDefaultStates();
 | |
| 
 | |
|             _EffectiveStyle = new EffectiveStyle<RegressionLineVisualStyle>(this);
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region InitDefaultStates
 | |
| 
 | |
|         private void InitDefaultStates()
 | |
|         {
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region Public properties
 | |
| 
 | |
|         #region EffectiveStyle
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets a reference to the RegressionLine's effective (cached, composite) style.
 | |
|         /// </summary>
 | |
|         [Browsable(false)]
 | |
|         [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 | |
|         public RegressionLineVisualStyle EffectiveStyle
 | |
|         {
 | |
|             get { return (_EffectiveStyle.Style); }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region IndicatorType
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets the RegressionLine's IndicatorType
 | |
|         /// </summary>
 | |
|         [Browsable(false)]
 | |
|         [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 | |
|         public override ChartIndicatorType IndicatorType
 | |
|         {
 | |
|             get { return (ChartIndicatorType.RegressionLine); }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region RegressionLineVisualStyle
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets or sets the visual style for the RegressionLine Indicator.
 | |
|         /// </summary>
 | |
|         [Category("Style")]
 | |
|         [Description("Indicates the visual style for the RegressionLine Indicator.")]
 | |
|         [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
 | |
|         public RegressionLineVisualStyle RegressionLineVisualStyle
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 if (_RegressionLineVisualStyle == null)
 | |
|                 {
 | |
|                     _RegressionLineVisualStyle = new RegressionLineVisualStyle();
 | |
| 
 | |
|                     StyleVisualChangeHandler(null, _RegressionLineVisualStyle);
 | |
|                 }
 | |
| 
 | |
|                 return (_RegressionLineVisualStyle);
 | |
|             }
 | |
| 
 | |
|             set
 | |
|             {
 | |
|                 if (_RegressionLineVisualStyle != value)
 | |
|                 {
 | |
|                     RegressionLineVisualStyle oldValue = _RegressionLineVisualStyle;
 | |
| 
 | |
|                     _RegressionLineVisualStyle = value;
 | |
| 
 | |
|                     OnStyleChanged("RegressionLineVisualStyle", oldValue, value);
 | |
| 
 | |
|                     if (oldValue != null)
 | |
|                         oldValue.Dispose();
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region Style support
 | |
| 
 | |
|         #region ApplyStyles
 | |
| 
 | |
|         public override void ApplyStyles(BaseVisualStyle style)
 | |
|         {
 | |
|             RegressionLineVisualStyle rstyle = style as RegressionLineVisualStyle;
 | |
| 
 | |
|             if (rstyle != null)
 | |
|             {
 | |
|                 ApplyParentStyles(rstyle, Parent as ChartContainer);
 | |
| 
 | |
|                 rstyle.ApplyStyle(RegressionLineVisualStyle);
 | |
| 
 | |
|                 if (rstyle.LineWidth < 0)
 | |
|                     rstyle.LineWidth = 1;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #region ApplyParentStyles
 | |
| 
 | |
|         private void ApplyParentStyles(
 | |
|             RegressionLineVisualStyle pstyle, ChartContainer item)
 | |
|         {
 | |
|             if (item != null)
 | |
|             {
 | |
|                 ApplyParentStyles(pstyle, item.Parent as ChartContainer);
 | |
| 
 | |
|                 ChartPanel panel = item as ChartPanel;
 | |
| 
 | |
|                 if (panel != null)
 | |
|                     pstyle.ApplyStyle(panel.DefaultVisualStyles.RegressionLineVisualStyle);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 pstyle.ApplyStyle(ChartControl.BaseVisualStyles.RegressionLineVisualStyle);
 | |
|                 pstyle.ApplyStyle(ChartControl.DefaultVisualStyles.RegressionLineVisualStyle);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region InvalidateStyle
 | |
| 
 | |
|         ///<summary>
 | |
|         ///Invalidate the cached Style
 | |
|         ///</summary>
 | |
|         public void InvalidateStyle()
 | |
|         {
 | |
|             ClearEffectiveStyles();
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ClearEffectiveStyles
 | |
| 
 | |
|         protected override void ClearEffectiveStyles()
 | |
|         {
 | |
|             base.ClearEffectiveStyles();
 | |
| 
 | |
|             if (LegendItem != null)
 | |
|                 LegendItem.EffectiveStyles.InvalidateStyles();
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region StyleChanged
 | |
| 
 | |
|         protected override void StyleChanged(object sender, PropertyChangedEventArgs e)
 | |
|         {
 | |
|             base.StyleChanged(sender, e);
 | |
| 
 | |
|             if (sender is ChartLegendItemVisualStyles && LegendItem != null)
 | |
|                 InvalidateRender(LegendItem.Bounds);
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ILegendItem
 | |
| 
 | |
|         #region GetLegendItemColorEx
 | |
| 
 | |
|         protected override Color GetLegendItemColorEx()
 | |
|         {
 | |
|             RegressionLineVisualStyle rstyle = EffectiveStyle;
 | |
| 
 | |
|             return (rstyle.LineColor);
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region RenderLegendItemMarkerEx
 | |
| 
 | |
|         protected override void RenderLegendItemMarkerEx(Graphics g,
 | |
|             ChartLegendItem litem, ChartLegendItemVisualStyle style)
 | |
|         {
 | |
|             RegressionLineVisualStyle rstyle = EffectiveStyle;
 | |
| 
 | |
|             if (rstyle.LinePattern != LinePattern.None)
 | |
|             {
 | |
|                 Rectangle bounds = litem.MarkerBounds;
 | |
| 
 | |
|                 int n = bounds.Height / 2;
 | |
| 
 | |
|                 int lineWidth = Math.Min(rstyle.LineWidth, bounds.Height);
 | |
| 
 | |
|                 using (Pen pen = new Pen(GetLegendItemColor(), lineWidth))
 | |
|                 {
 | |
|                     if (rstyle.LinePattern != LinePattern.NotSet)
 | |
|                         pen.DashStyle = (DashStyle)rstyle.LinePattern;
 | |
| 
 | |
|                     g.DrawLine(pen,
 | |
|                         new Point(bounds.X, bounds.Y + n),
 | |
|                         new Point(bounds.Right - 1, bounds.Y + n));
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region GetLegendItemTextEx
 | |
| 
 | |
|         protected override string GetLegendItemTextEx()
 | |
|         {
 | |
|             return ("(RegLine)");
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region Copy/CopyTo
 | |
| 
 | |
|         public override ChartVisualElement Copy()
 | |
|         {
 | |
|             RegressionLine copy = new RegressionLine();
 | |
| 
 | |
|             CopyTo(copy);
 | |
| 
 | |
|             return (copy);
 | |
|         }
 | |
| 
 | |
|         public override void CopyTo(ChartVisualElement copy)
 | |
|         {
 | |
|             RegressionLine c = copy as RegressionLine;
 | |
| 
 | |
|             if (c != null)
 | |
|             {
 | |
|                 base.CopyTo(c);
 | |
| 
 | |
|                 c.RegressionLineVisualStyle = 
 | |
|                     (_RegressionLineVisualStyle != null) ? RegressionLineVisualStyle.Copy() : null;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region GetSerialData
 | |
| 
 | |
|         internal override SerialElementCollection GetSerialData(string serialName)
 | |
|         {
 | |
|             SerialElementCollection sec = new SerialElementCollection();
 | |
| 
 | |
|             if (serialName != null)
 | |
|             {
 | |
|                 if (serialName.Equals("") == true)
 | |
|                     serialName = "RegressionLine";
 | |
| 
 | |
|                 sec.AddStartElement(serialName);
 | |
|             }
 | |
| 
 | |
|             if (_RegressionLineVisualStyle != null && _RegressionLineVisualStyle.IsEmpty == false)
 | |
|                 sec.AddElement(_RegressionLineVisualStyle.GetSerialData("RegressionLineVisualStyle"));
 | |
| 
 | |
|             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)
 | |
|             {
 | |
|                 default:
 | |
|                     base.ProcessValue(se);
 | |
|                     break;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ProcessCollection
 | |
| 
 | |
|         internal override void ProcessCollection(SerialElement se)
 | |
|         {
 | |
|             SerialElementCollection sec = se.Sec;
 | |
| 
 | |
|             switch (se.Name)
 | |
|             {
 | |
|                 case "RegressionLineVisualStyle":
 | |
|                     sec.PutSerialData(RegressionLineVisualStyle);
 | |
|                     break;
 | |
| 
 | |
|                 default:
 | |
|                     base.ProcessCollection(se);
 | |
|                     break;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region IDisposable
 | |
| 
 | |
|         public override void Dispose()
 | |
|         {
 | |
|             RegressionLineVisualStyle = null;
 | |
| 
 | |
|             base.Dispose();
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
|     }
 | |
| 
 | |
|     #endregion
 | |
| 
 | |
|     #region TrendLine
 | |
| 
 | |
|     /// <summary>
 | |
|     /// Represents a Trend Line (a line connecting any 2 defined SeriesPoints).
 | |
|     /// </summary>
 | |
|     public class TrendLine : ChartIndicator, IEffectiveStyle
 | |
|     {
 | |
|         #region Private variables
 | |
| 
 | |
|         private object _ValueX1;
 | |
|         private object _ValueX2;
 | |
| 
 | |
|         private TrendLineVisualStyle _TrendLineVisualStyle;
 | |
|         private EffectiveStyle<TrendLineVisualStyle> _EffectiveStyle;
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region Constructors
 | |
| 
 | |
|         /// <summary>
 | |
|         /// TrendLine
 | |
|         /// </summary>
 | |
|         public TrendLine()
 | |
|         {
 | |
|             InitDefaultStates();
 | |
| 
 | |
|             _EffectiveStyle = new EffectiveStyle<TrendLineVisualStyle>(this);
 | |
|         }
 | |
| 
 | |
|         #region Constructors
 | |
| 
 | |
|         /// <summary>
 | |
|         /// TrendLine
 | |
|         /// </summary>
 | |
|         /// <param name="name">Name</param>
 | |
|         public TrendLine(string name)
 | |
|             : this()
 | |
|         {
 | |
|             Name = name;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// TrendLine
 | |
|         /// </summary>
 | |
|         /// <param name="name">Name</param>
 | |
|         /// <param name="valuex1">Starting X-Axis value</param>
 | |
|         /// <param name="valuex2">Ending X-Axis value</param>
 | |
|         public TrendLine(string name, object valuex1, object valuex2)
 | |
|             : this(name)
 | |
|         {
 | |
|             ValueX1 = valuex1;
 | |
|             ValueX2 = valuex2;
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region InitDefaultStates
 | |
| 
 | |
|         private void InitDefaultStates()
 | |
|         {
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region Public properties
 | |
| 
 | |
|         #region EffectiveStyles
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets a reference to the TrendLine's effective (cached, composite) style.
 | |
|         /// </summary>
 | |
|         [Browsable(false)]
 | |
|         [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 | |
|         public TrendLineVisualStyle EffectiveStyle
 | |
|         {
 | |
|             get { return (_EffectiveStyle.Style); }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region IndicatorType
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets the TrendLine's IndicatorType
 | |
|         /// </summary>
 | |
|         [Browsable(false)]
 | |
|         [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 | |
|         public override ChartIndicatorType IndicatorType
 | |
|         {
 | |
|             get { return (ChartIndicatorType.TrendLine); }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region TrendLineVisualStyle
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets or sets the visual style for the TrendLine Indicator.
 | |
|         /// </summary>
 | |
|         [Category("Style")]
 | |
|         [Description("Indicates the visual style for the TrendLine Indicator.")]
 | |
|         [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
 | |
|         public TrendLineVisualStyle TrendLineVisualStyle
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 if (_TrendLineVisualStyle == null)
 | |
|                 {
 | |
|                     _TrendLineVisualStyle = new TrendLineVisualStyle();
 | |
| 
 | |
|                     StyleVisualChangeHandler(null, _TrendLineVisualStyle);
 | |
|                 }
 | |
| 
 | |
|                 return (_TrendLineVisualStyle);
 | |
|             }
 | |
| 
 | |
|             set
 | |
|             {
 | |
|                 if (_TrendLineVisualStyle != value)
 | |
|                 {
 | |
|                     TrendLineVisualStyle oldValue = _TrendLineVisualStyle;
 | |
| 
 | |
|                     _TrendLineVisualStyle = value;
 | |
| 
 | |
|                     OnStyleChanged("TrendLineVisualStyle", oldValue, value);
 | |
| 
 | |
|                     if (oldValue != null)
 | |
|                         oldValue.Dispose();
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ValueX1
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Trendline starting X value
 | |
|         /// </summary>
 | |
|         [Category("Data")]
 | |
|         [Description("Indicates the Trendline starting X value.")]
 | |
|         [TypeConverter("DevComponents.Charts.Design.PointValueConverter," +
 | |
|             "DevComponents.Charts.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
 | |
|         public object ValueX1
 | |
|         {
 | |
|             get { return (_ValueX1); }
 | |
|             set { _ValueX1 = value; }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ValueX2
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Trendline ending X value
 | |
|         /// </summary>
 | |
|         [Category("Data")]
 | |
|         [Description("Indicates the Trendline ending X value.")]
 | |
|         [TypeConverter("DevComponents.Charts.Design.PointValueConverter," +
 | |
|             "DevComponents.Charts.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")]
 | |
|         public object ValueX2
 | |
|         {
 | |
|             get { return (_ValueX2); }
 | |
|             set { _ValueX2 = value; }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region Style support
 | |
| 
 | |
|         #region ApplyStyles
 | |
| 
 | |
|         public override void ApplyStyles(BaseVisualStyle style)
 | |
|         {
 | |
|             TrendLineVisualStyle tstyle = style as TrendLineVisualStyle;
 | |
| 
 | |
|             if (tstyle != null)
 | |
|             {
 | |
|                 ApplyParentStyles(tstyle, Parent as ChartContainer);
 | |
| 
 | |
|                 tstyle.ApplyStyle(TrendLineVisualStyle);
 | |
| 
 | |
|                 if (tstyle.LineWidth < 0)
 | |
|                     tstyle.LineWidth = 1;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #region ApplyParentStyles
 | |
| 
 | |
|         private void ApplyParentStyles( TrendLineVisualStyle pstyle, ChartContainer item)
 | |
|         {
 | |
|             if (item != null)
 | |
|             {
 | |
|                 ApplyParentStyles(pstyle, item.Parent as ChartContainer);
 | |
| 
 | |
|                 if (item is ChartPanel)
 | |
|                     pstyle.ApplyStyle(((ChartPanel)item).DefaultVisualStyles.TrendLineVisualStyle);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 pstyle.ApplyStyle(ChartControl.BaseVisualStyles.TrendLineVisualStyle);
 | |
|                 pstyle.ApplyStyle(ChartControl.DefaultVisualStyles.TrendLineVisualStyle);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region InvalidateStyle
 | |
| 
 | |
|         ///<summary>
 | |
|         ///Invalidate the cached Style
 | |
|         ///</summary>
 | |
|         public void InvalidateStyle()
 | |
|         {
 | |
|             ClearEffectiveStyles();
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ClearEffectiveStyles
 | |
| 
 | |
|         protected override void ClearEffectiveStyles()
 | |
|         {
 | |
|             base.ClearEffectiveStyles();
 | |
| 
 | |
|             if (LegendItem != null)
 | |
|                 LegendItem.EffectiveStyles.InvalidateStyles();
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region StyleChanged
 | |
| 
 | |
|         protected override void StyleChanged(object sender, PropertyChangedEventArgs e)
 | |
|         {
 | |
|             base.StyleChanged(sender, e);
 | |
| 
 | |
|             if (sender is ChartLegendItemVisualStyles && LegendItem != null)
 | |
|                 InvalidateRender(LegendItem.Bounds);
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ILegendItem
 | |
| 
 | |
|         #region GetLegendItemColorEx
 | |
| 
 | |
|         protected override Color GetLegendItemColorEx()
 | |
|         {
 | |
|             TrendLineVisualStyle tstyle = EffectiveStyle;
 | |
| 
 | |
|             return (tstyle.LineColor);
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region RenderLegendItemMarkerEx
 | |
| 
 | |
|         protected override void RenderLegendItemMarkerEx(Graphics g,
 | |
|             ChartLegendItem litem, ChartLegendItemVisualStyle style)
 | |
|         {
 | |
|             TrendLineVisualStyle tstyle = EffectiveStyle;
 | |
| 
 | |
|             if (tstyle.LinePattern != LinePattern.None)
 | |
|             {
 | |
|                 Rectangle bounds = litem.MarkerBounds;
 | |
| 
 | |
|                 int n = bounds.Height / 2;
 | |
| 
 | |
|                 int lineWidth = Math.Min(tstyle.LineWidth, bounds.Height);
 | |
| 
 | |
|                 using (Pen pen = new Pen(GetLegendItemColor(), lineWidth))
 | |
|                 {
 | |
|                     if (tstyle.LinePattern != LinePattern.NotSet)
 | |
|                         pen.DashStyle = (DashStyle)tstyle.LinePattern;
 | |
| 
 | |
|                     g.DrawLine(pen,
 | |
|                         new Point(bounds.X, bounds.Y + n),
 | |
|                         new Point(bounds.Right - 1, bounds.Y + n));
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region GetLegendItemTextEx
 | |
| 
 | |
|         protected override string GetLegendItemTextEx()
 | |
|         {
 | |
|             return ("(TrendLine)");
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region Copy/CopyTo
 | |
| 
 | |
|         public override ChartVisualElement Copy()
 | |
|         {
 | |
|             TrendLine copy = new TrendLine();
 | |
| 
 | |
|             CopyTo(copy);
 | |
| 
 | |
|             return (copy);
 | |
|         }
 | |
| 
 | |
|         public override void CopyTo(ChartVisualElement copy)
 | |
|         {
 | |
|             TrendLine c = copy as TrendLine;
 | |
| 
 | |
|             if (c != null)
 | |
|             {
 | |
|                 base.CopyTo(c);
 | |
| 
 | |
|                 c.TrendLineVisualStyle =
 | |
|                     (_TrendLineVisualStyle != null) ? TrendLineVisualStyle.Copy() : null;
 | |
| 
 | |
|                 c.ValueX1 = ValueX1;
 | |
|                 c.ValueX2 = ValueX2;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region GetSerialData
 | |
| 
 | |
|         internal override SerialElementCollection GetSerialData(string serialName)
 | |
|         {
 | |
|             SerialElementCollection sec = new SerialElementCollection();
 | |
| 
 | |
|             if (serialName != null)
 | |
|             {
 | |
|                 if (serialName.Equals("") == true)
 | |
|                     serialName = "TrendLine";
 | |
| 
 | |
|                 sec.AddStartElement(serialName);
 | |
|             }
 | |
| 
 | |
|             if (_TrendLineVisualStyle != null && _TrendLineVisualStyle.IsEmpty == false)
 | |
|                 sec.AddElement(_TrendLineVisualStyle.GetSerialData("TrendLineVisualStyle"));
 | |
| 
 | |
|             sec.AddDataValue("ValueX1", ValueX1, null);
 | |
|             sec.AddDataValue("ValueX2", ValueX2, null);
 | |
| 
 | |
|             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 "ValueX1":
 | |
|                     ValueX1 = se.DataValue;
 | |
|                     break;
 | |
| 
 | |
|                 case "ValueX2":
 | |
|                     ValueX2 = se.DataValue;
 | |
|                     break;
 | |
| 
 | |
|                 default:
 | |
|                     base.ProcessValue(se);
 | |
|                     break;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ProcessCollection
 | |
| 
 | |
|         internal override void ProcessCollection(SerialElement se)
 | |
|         {
 | |
|             SerialElementCollection sec = se.Sec;
 | |
| 
 | |
|             switch (se.Name)
 | |
|             {
 | |
|                 case "TrendLineVisualStyle":
 | |
|                     sec.PutSerialData(TrendLineVisualStyle);
 | |
|                     break;
 | |
| 
 | |
|                 default:
 | |
|                     base.ProcessCollection(se);
 | |
|                     break;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region IDisposable
 | |
| 
 | |
|         public override void Dispose()
 | |
|         {
 | |
|             TrendLineVisualStyle = null;
 | |
| 
 | |
|             base.Dispose();
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
|     }
 | |
| 
 | |
|     #endregion
 | |
| 
 | |
|     public abstract class ChartIndicator : ChartVisualElement, ILegendItem
 | |
|     {
 | |
|         #region Private variables
 | |
| 
 | |
|         private States _States;
 | |
| 
 | |
|         private string _LegendText;
 | |
|         private ChartLegendItem _LegendItem;
 | |
|         private ChartLegendItemVisualStyles _ChartLegendItemVisualStyles;
 | |
| 
 | |
|         private int _ValueYIndex;
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         public ChartIndicator()
 | |
|         {
 | |
|             InitDefaultStates();
 | |
|         }
 | |
| 
 | |
|         #region InitDefaultStates
 | |
| 
 | |
|         private void InitDefaultStates()
 | |
|         {
 | |
|             SetState(States.CheckedInLegend, true);
 | |
|             SetState(States.ShowInLegend, true);
 | |
|             SetState(States.ShowInParentLegend, true);
 | |
|             SetState(States.ShowCheckBoxInLegend, true);
 | |
|             SetState(States.ShowMarkerInLegend, true);
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region Public properties
 | |
| 
 | |
|         #region DisplayOnTop
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets or sets whether Indicator is displayed on top of chart data.
 | |
|         /// </summary>
 | |
|         [DefaultValue(false), Category("Appearance")]
 | |
|         [Description("Indicates whether Indicator is displayed on top of chart data.")]
 | |
|         public bool DisplayOnTop
 | |
|         {
 | |
|             get { return (TestState(States.DisplayOnTop)); }
 | |
| 
 | |
|             set
 | |
|             {
 | |
|                 if (value != DisplayOnTop)
 | |
|                 {
 | |
|                     SetState(States.DisplayOnTop, value);
 | |
| 
 | |
|                     OnPropertyChangedEx("DisplayOnTop", VisualChangeType.Render);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region IndicatorType
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Indicator type
 | |
|         /// </summary>
 | |
|         public virtual ChartIndicatorType IndicatorType
 | |
|         {
 | |
|             get { throw new NotImplementedException(); }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region Intercept
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets the Indicator Line's Intercept (ie. the 'b' portion of 'y = mx + b').
 | |
|         /// </summary>
 | |
|         [Browsable(false)]
 | |
|         [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 | |
|         public double Intercept
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 ChartSeries series = Parent as ChartSeries;
 | |
| 
 | |
|                 if (series == null)
 | |
|                     throw new Exception("Indicator Line not associated with a ChartSeries.");
 | |
| 
 | |
|                 ChartXy chartXy = series.Parent as ChartXy;
 | |
| 
 | |
|                 if (chartXy == null)
 | |
|                     throw new Exception("Indicator Line not associated with a ChartXy.");
 | |
| 
 | |
|                 SortedSeriesPoints ssp = series.GetSortedSeriesPoints(chartXy);
 | |
| 
 | |
|                 ssp.SlopeIndex = ValueYIndex;
 | |
| 
 | |
|                 return (ssp.Intercept);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region IsDisplayed
 | |
| 
 | |
|         ///<summary>
 | |
|         /// Gets whether the Indicator is displayed.
 | |
|         ///</summary>
 | |
|         [Browsable(false)]
 | |
|         [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 | |
|         public bool IsDisplayed
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 return ((Visible == true) &&
 | |
|                         (ShowCheckBoxInLegend == false || CheckedInLegend == true));
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region Slope
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets the Indicator Line's Slope (ie. the 'm' portion of 'y = mx + b').
 | |
|         /// </summary>
 | |
|         [Browsable(false)]
 | |
|         [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 | |
|         public double Slope
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 ChartSeries series = Parent as ChartSeries;
 | |
| 
 | |
|                 if (series == null)
 | |
|                     throw new Exception("Indicator Line not associated with a ChartSeries.");
 | |
| 
 | |
|                 ChartXy chartXy = series.Parent as ChartXy;
 | |
| 
 | |
|                 if (chartXy == null)
 | |
|                     throw new Exception("Indicator Line not associated with a ChartXy.");
 | |
| 
 | |
|                 SortedSeriesPoints ssp = series.GetSortedSeriesPoints(chartXy);
 | |
| 
 | |
|                 ssp.SlopeIndex = ValueYIndex;
 | |
| 
 | |
|                 return (ssp.Slope);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ValueYIndex
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets or sets the ValueY index to use for the slope/intercept.
 | |
|         /// </summary>
 | |
|         [DefaultValue(0), Category("Appearance")]
 | |
|         [Description("Indicates the ValueY index to use for the slope/intercept.")]
 | |
|         public int ValueYIndex
 | |
|         {
 | |
|             get { return (_ValueYIndex); }
 | |
| 
 | |
|             set
 | |
|             {
 | |
|                 if (value != _ValueYIndex)
 | |
|                 {
 | |
|                     _ValueYIndex = value;
 | |
| 
 | |
|                     OnPropertyChangedEx("ValueYIndex", VisualChangeType.Layout);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ArrangeOverride
 | |
| 
 | |
|         protected override void ArrangeOverride(ChartLayoutInfo layoutInfo)
 | |
|         {
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region MeasureOverride
 | |
| 
 | |
|         protected override void MeasureOverride(ChartLayoutInfo layoutInfo)
 | |
|         {
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region RenderOverride
 | |
| 
 | |
|         protected override void RenderOverride(ChartRenderInfo renderInfo)
 | |
|         {
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ILegendItem
 | |
| 
 | |
|         #region ChartLegendItemVisualStyles
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets or sets the visual styles for the Legend item.
 | |
|         /// </summary>
 | |
|         [Category("Style")]
 | |
|         [Description("Indicates the visual styles for the Legend item.")]
 | |
|         [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
 | |
|         public ChartLegendItemVisualStyles ChartLegendItemVisualStyles
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 if (_ChartLegendItemVisualStyles == null)
 | |
|                 {
 | |
|                     _ChartLegendItemVisualStyles = new ChartLegendItemVisualStyles();
 | |
| 
 | |
|                     StyleVisualChangeHandler(null, _ChartLegendItemVisualStyles);
 | |
|                 }
 | |
| 
 | |
|                 return (_ChartLegendItemVisualStyles);
 | |
|             }
 | |
| 
 | |
|             set
 | |
|             {
 | |
|                 if (_ChartLegendItemVisualStyles != value)
 | |
|                 {
 | |
|                     ChartLegendItemVisualStyles oldValue = _ChartLegendItemVisualStyles;
 | |
| 
 | |
|                     _ChartLegendItemVisualStyles = value;
 | |
| 
 | |
|                     OnStyleChanged("ChartLegendItemVisualStyles", oldValue, value);
 | |
| 
 | |
|                     if (oldValue != null)
 | |
|                         oldValue.Dispose();
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region CheckedInLegend
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets or sets whether the Line is checked in the Legend.
 | |
|         /// </summary>
 | |
|         [DefaultValue(true), Category("Appearance")]
 | |
|         [Description("Indicates whether the Line is checked in the Legend.")]
 | |
|         public bool CheckedInLegend
 | |
|         {
 | |
|             get { return (TestState(States.CheckedInLegend)); }
 | |
| 
 | |
|             set
 | |
|             {
 | |
|                 if (value != CheckedInLegend)
 | |
|                 {
 | |
|                     SetState(States.CheckedInLegend, value);
 | |
| 
 | |
|                     if (LegendItem != null)
 | |
|                         LegendItem.UpdateCheckState();
 | |
| 
 | |
|                     OnPropertyChangedEx("CheckedInLegend", VisualChangeType.Render);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ShowCheckBoxInLegend
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets or sets whether a checkbox for the Line is shown in the Legend.
 | |
|         /// </summary>
 | |
|         [DefaultValue(true), Category("Appearance")]
 | |
|         [Description("Indicates whether a checkbox for the Line is shown in the Legend.")]
 | |
|         public bool ShowCheckBoxInLegend
 | |
|         {
 | |
|             get { return (TestState(States.ShowCheckBoxInLegend)); }
 | |
| 
 | |
|             set
 | |
|             {
 | |
|                 if (value != ShowCheckBoxInLegend)
 | |
|                 {
 | |
|                     SetState(States.ShowCheckBoxInLegend, value);
 | |
| 
 | |
|                     OnPropertyChangedEx("ShowCheckBoxInLegend", VisualChangeType.Layout);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ShowInLegend
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets or sets whether the Line is shown in the Legend.
 | |
|         /// </summary>
 | |
|         [DefaultValue(true), Category("Appearance")]
 | |
|         [Description("Indicates whether theLine is shown in the Legend.")]
 | |
|         public bool ShowInLegend
 | |
|         {
 | |
|             get { return (TestState(States.ShowInLegend)); }
 | |
| 
 | |
|             set
 | |
|             {
 | |
|                 if (value != ShowInLegend)
 | |
|                 {
 | |
|                     SetState(States.ShowInLegend, value);
 | |
| 
 | |
|                     OnPropertyChangedEx("ShowInLegend", VisualChangeType.Layout);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ShowInParentLegend
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets or sets whether the Line is shown in parent Legend(s).
 | |
|         /// </summary>
 | |
|         [DefaultValue(true), Category("Appearance")]
 | |
|         [Description("Indicates whether the Line is shown in parent Legend(s).")]
 | |
|         public bool ShowInParentLegend
 | |
|         {
 | |
|             get { return (TestState(States.ShowInParentLegend)); }
 | |
| 
 | |
|             set
 | |
|             {
 | |
|                 if (value != ShowInParentLegend)
 | |
|                 {
 | |
|                     SetState(States.ShowInParentLegend, value);
 | |
| 
 | |
|                     OnPropertyChangedEx("ShowInParentLegend", VisualChangeType.Layout);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region ShowMarkerInLegend
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Gets or sets whether the Line Marker is shown in the Legend.
 | |
|         /// </summary>
 | |
|         [DefaultValue(true), Category("Appearance")]
 | |
|         [Description("Indicates whether the Line Marker is shown in the Legend.")]
 | |
|         public bool ShowMarkerInLegend
 | |
|         {
 | |
|             get { return (TestState(States.ShowMarkerInLegend)); }
 | |
| 
 | |
|             set
 | |
|             {
 | |
|                 if (value != ShowMarkerInLegend)
 | |
|                 {
 | |
|                     SetState(States.ShowMarkerInLegend, value);
 | |
| 
 | |
|                     OnPropertyChangedEx("ShowMarkerInLegend", VisualChangeType.Layout);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region LegendItem
 | |
| 
 | |
|         ///<summary>
 | |
|         /// Gets the item's parent LegendItem.
 | |
|         ///</summary>
 | |
|         [Description("Indicates the item's parent LegendItem.")]
 | |
|         [Browsable(false)]
 | |
|         [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
 | |
|         public ChartLegendItem LegendItem
 | |
|         {
 | |
|             get { return (_LegendItem); }
 | |
| 
 | |
|             internal set
 | |
|             {
 | |
|                 if (_LegendItem != null)
 | |
|                     _LegendItem.Dispose();
 | |
| 
 | |
|                 _LegendItem = value;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region LegendText
 | |
| 
 | |
|         ///<summary>
 | |
|         /// Gets or sets the text to display in the legend.
 | |
|         ///</summary>
 | |
|         [DefaultValue(null), Category("DataLabel")]
 | |
|         [Description("Indicates the text to display in the legend.")]
 | |
|         public string LegendText
 | |
|         {
 | |
|             get { return (_LegendText); }
 | |
| 
 | |
|             set
 | |
|             {
 | |
|                 if (value != _LegendText)
 | |
|                 {
 | |
|                     _LegendText = value;
 | |
| 
 | |
|                     OnPropertyChangedEx("LegendText", Style.VisualChangeType.Layout);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region GetLegendItem
 | |
| 
 | |
|         public ChartLegendItem GetLegendItem()
 | |
|         {
 | |
|             LegendItem = null;
 | |
| 
 | |
|             if (ShowInLegend == true)
 | |
|             {
 | |
|                 LegendItem = new ChartLegendItem();
 | |
| 
 | |
|                 if (CheckedInLegend == true)
 | |
|                     _LegendItem.CheckState = CheckState.Checked;
 | |
| 
 | |
|                 _LegendItem.Name = Name;
 | |
|                 _LegendItem.ItemText = LegendText;
 | |
| 
 | |
|                 if (string.IsNullOrEmpty(Name) == true &&
 | |
|                     string.IsNullOrEmpty(_LegendItem.ItemText) == true)
 | |
|                 {
 | |
|                     _LegendItem.ItemText = GetLegendItemTextEx();
 | |
|                 }
 | |
| 
 | |
|                 _LegendItem.ChartItems.Add(this);
 | |
|             }
 | |
| 
 | |
|             return (_LegendItem);
 | |
|         }
 | |
| 
 | |
|         protected virtual string GetLegendItemTextEx()
 | |
|         {
 | |
|             return ("(IndLine)");
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region GetLegendItems
 | |
| 
 | |
|         public List<ChartLegendItem> GetLegendItems()
 | |
|         {
 | |
|             List<ChartLegendItem> list = new List<ChartLegendItem>(1);
 | |
| 
 | |
|             list.Add(GetLegendItem());
 | |
| 
 | |
|             return (list);
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region GetLegendItemColor
 | |
| 
 | |
|         public Color GetLegendItemColor()
 | |
|         {
 | |
|             Color color = GetLegendItemColorEx();
 | |
| 
 | |
|             if (color.IsEmpty == true)
 | |
|             {
 | |
|                 ChartSeries series = Parent as ChartSeries;
 | |
| 
 | |
|                 if (series != null)
 | |
|                     color = series.DefaultPaletteColor;
 | |
|             }
 | |
| 
 | |
|             return (color);
 | |
|         }
 | |
| 
 | |
|         protected virtual Color GetLegendItemColorEx()
 | |
|         {
 | |
|             return (Color.Empty);
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region RenderLegendItemMarker
 | |
| 
 | |
|         public void RenderLegendItemMarker(Graphics g,
 | |
|             ChartLegendItem litem, ChartLegendItemVisualStyle style)
 | |
|         {
 | |
|             RenderLegendItemMarkerEx(g, litem, style);
 | |
|         }
 | |
| 
 | |
|         protected virtual void RenderLegendItemMarkerEx(Graphics g,
 | |
|             ChartLegendItem litem, ChartLegendItemVisualStyle style)
 | |
|         {
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region CopyTo
 | |
| 
 | |
|         public override void CopyTo(ChartVisualElement copy)
 | |
|         {
 | |
|             ChartIndicator c = copy as ChartIndicator;
 | |
| 
 | |
|             if (c != null)
 | |
|             {
 | |
|                 base.CopyTo(c);
 | |
| 
 | |
|                 c.ChartLegendItemVisualStyles = 
 | |
|                     (_ChartLegendItemVisualStyles != null) ? ChartLegendItemVisualStyles.Copy() : null;
 | |
| 
 | |
|                 c.CheckedInLegend = CheckedInLegend;
 | |
|                 c.LegendText = LegendText;
 | |
|                 c.ShowCheckBoxInLegend = ShowCheckBoxInLegend;
 | |
|                 c.ShowInLegend = ShowInLegend;
 | |
|                 c.ShowInParentLegend = ShowInParentLegend;
 | |
|                 c.ShowMarkerInLegend = ShowMarkerInLegend;
 | |
|                 c.DisplayOnTop = DisplayOnTop;
 | |
|                 c.ValueYIndex = _ValueYIndex;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region GetSerialData
 | |
| 
 | |
|         internal override SerialElementCollection GetSerialData(string serialName)
 | |
|         {
 | |
|             SerialElementCollection sec = new SerialElementCollection();
 | |
| 
 | |
|             if (serialName != null)
 | |
|             {
 | |
|                 if (serialName.Equals("") == true)
 | |
|                     serialName = "ChartIndicator";
 | |
| 
 | |
|                 sec.AddStartElement(serialName);
 | |
|             }
 | |
| 
 | |
|             if (_ChartLegendItemVisualStyles != null)
 | |
|                 sec.AddElement(_ChartLegendItemVisualStyles.GetSerialData("ChartLegendItemVisualStyles"));
 | |
| 
 | |
|             sec.AddValue("DisplayOnTop", DisplayOnTop, false);
 | |
| 
 | |
|             sec.AddValue("CheckedInLegend", CheckedInLegend, true);
 | |
|             sec.AddValue("LegendText", LegendText, null);
 | |
|             sec.AddValue("ShowCheckBoxInLegend", ShowCheckBoxInLegend, true);
 | |
|             sec.AddValue("ShowInLegend", ShowInLegend, true);
 | |
|             sec.AddValue("ShowInParentLegend", ShowInParentLegend, true);
 | |
|             sec.AddValue("ShowMarkerInLegend", ShowMarkerInLegend, true);
 | |
| 
 | |
|             sec.AddValue("ValueYIndex", _ValueYIndex, 0);
 | |
| 
 | |
|             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 "CheckedInLegend":
 | |
|                     CheckedInLegend = bool.Parse(se.StringValue);
 | |
|                     break;
 | |
| 
 | |
|                 case "DisplayOnTop":
 | |
|                     DisplayOnTop = bool.Parse(se.StringValue);
 | |
|                     break;
 | |
| 
 | |
|                 case "LegendText":
 | |
|                     LegendText = se.StringValue;
 | |
|                     break;
 | |
| 
 | |
|                 case "ShowCheckBoxInLegend":
 | |
|                     ShowCheckBoxInLegend = bool.Parse(se.StringValue);
 | |
|                     break;
 | |
| 
 | |
|                 case "ShowInLegend":
 | |
|                     ShowInLegend = bool.Parse(se.StringValue);
 | |
|                     break;
 | |
| 
 | |
|                 case "ShowInParentLegend":
 | |
|                     ShowInParentLegend = bool.Parse(se.StringValue);
 | |
|                     break;
 | |
| 
 | |
|                 case "ShowMarkerInLegend":
 | |
|                     ShowMarkerInLegend = bool.Parse(se.StringValue);
 | |
|                     break;
 | |
| 
 | |
|                 case "ValueYIndex":
 | |
|                     ValueYIndex = 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 "ChartLegendItemVisualStyles":
 | |
|                     sec.PutSerialData(ChartLegendItemVisualStyles);
 | |
|                     break;
 | |
| 
 | |
|                 default:
 | |
|                     base.ProcessCollection(se);
 | |
|                     break;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region States
 | |
| 
 | |
|         [Flags]
 | |
|         private enum States : uint
 | |
|         {
 | |
|             CheckedInLegend = (1U << 1),
 | |
|             ShowCheckBoxInLegend = (1U << 2),
 | |
|             ShowInLegend = (1U << 3),
 | |
|             ShowInParentLegend = (1U << 4),
 | |
|             ShowMarkerInLegend = (1U << 5),
 | |
|             DisplayOnTop = (1U << 6),
 | |
|         }
 | |
| 
 | |
|         #region TestState
 | |
| 
 | |
|         private bool TestState(States state)
 | |
|         {
 | |
|             return ((_States & state) == state);
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #region SetState
 | |
| 
 | |
|         private void SetState(States state, bool value)
 | |
|         {
 | |
|             if (value == true)
 | |
|                 _States |= state;
 | |
|             else
 | |
|                 _States &= ~state;
 | |
|         }
 | |
| 
 | |
|         #endregion
 | |
| 
 | |
|         #endregion
 | |
|     }
 | |
| 
 | |
|     #region enums
 | |
| 
 | |
|     #region ChartIndicatorType
 | |
| 
 | |
|     public enum ChartIndicatorType
 | |
|     {
 | |
|         TrendLine,
 | |
|         RegressionLine,
 | |
|     }
 | |
| 
 | |
|     #endregion
 | |
| 
 | |
|     #endregion
 | |
| }
 |