using MuchInfo.Chart.Data.EnumTypes; using MuchInfo.Chart.Data.Interfaces; using MuchInfo.Chart.Data.Models; using MuchInfo.Chart.Infrastructure.Data; using MuchInfo.Chart.Infrastructure.EventArgs; using MuchInfo.Chart.Infrastructure.Helpers; using MuchInfo.Chart.Infrastructure.Utilities; using MuchInfo.Chart.Utilities.Enums; using MuchInfo.Chart.WPF.Helpers; using MuchInfo.Chart.WPF.Primitives.Interfaces; using System; using System.Collections.Generic; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Shapes; namespace MuchInfo.Chart.WPF.Primitives { #region Delegates public delegate void PlotStyleChangedEventHandler(); #endregion Delegates public class LinePlot : PlotBase { #region Fields protected Color mAreaFillColorDarkBG; protected Color mAreaFillColorLightBG; protected double mAreaFillOpacity; protected Color mPlotColorDarkBG; protected Color mPlotColorLightBG; protected Color mPlotNegColorDarkBG; protected Color mPlotNegColorLightBG; private readonly Color c_YestodayColor; private readonly Color c_TodayOpenColor; protected OutputDataWrapper mOutputData; //protected bool mPlotNegValsDiffColor; private DashStyleType _dashStyleType; private DoubleCollection _doubleCollection; private bool _isDark; private static Random _random = new Random(18000); // 没设置颜色时使用随机颜色, private double _lineThickness; #endregion Fields #region Constructors public LinePlot() { c_YestodayColor = Colors.Gold; c_TodayOpenColor = Colors.Chocolate; this.mPlotColorDarkBG = Colors.Cyan; this.mPlotColorLightBG = ColorHelper.DarkBlue; this.mPlotNegColorDarkBG = Colors.Red; this.mPlotNegColorLightBG = ColorHelper.DarkRed; //this.mPlotNegValsDiffColor = false; this._isDark = true; // this.mPlotType = LinePlotType.OHLC; this._dashStyleType = DashStyleType.Solid; this._lineThickness = 1.2; this.mAreaFillColorDarkBG = Colors.Gray; this.mAreaFillColorLightBG = ColorHelper.Gray; this.mAreaFillOpacity = 0.5; } public LinePlot(IndicatorModel indeicator, Chart chart) : base(indeicator, chart) { var OutputData = new OutputDataWrapper() { mDat = new ChartDataSet(indeicator.CalculateDataPoints), }; this.mOutputData = OutputData; c_YestodayColor = Colors.Gold; c_TodayOpenColor = Colors.Chocolate; this.mPlotColorDarkBG = Colors.Cyan; this.mPlotColorLightBG = ColorHelper.DarkBlue; this.mPlotNegColorDarkBG = Colors.Red; this.mPlotNegColorLightBG = ColorHelper.DarkRed; this._isDark = true; this._dashStyleType = DashStyleType.Solid; this._lineThickness = 1.2; this.mAreaFillColorDarkBG = Colors.Gray; this.mAreaFillColorLightBG = ColorHelper.Gray; this.mAreaFillOpacity = 0.5; this.Calculate(); InitAsNew(); } #endregion Constructors #region Events public event PlotStyleChangedEventHandler PlotStyleChanged; #endregion Events #region Properties #region Public Properties public DashStyleType DashStyle { get { return this._dashStyleType; } set { this._dashStyleType = value; switch (this._dashStyleType) { case DashStyleType.Solid: this._doubleCollection = null; break; case DashStyleType.Dashed: this._doubleCollection = new DoubleCollection { 10.0, 5.0 }; break; case DashStyleType.Dotted: this._doubleCollection = new DoubleCollection { 3.0, 3.0 }; break; case DashStyleType.LongDashes: this._doubleCollection = new DoubleCollection { 25.0, 10.0 }; break; } } } //public bool PlotNegValsDiffColor //{ // get // { // return this.mPlotNegValsDiffColor; // } // set // { // bool flag = value != this.mPlotNegValsDiffColor; // if (flag) // { // this.mPlotNegValsDiffColor = value; // flag = (this.mChart != null); // if (flag) // { // this.mChart.Refresh(); // } // } // } //} #endregion Public Properties #endregion Properties #region Methods #region Public Methods #region 获取公式中各个图的颜色 #endregion //public override void FromXML(XElement node) //{ // Color? color = default(Color?); // bool flag = node.Attribute("PlotColor") != null; // if (flag) // { // this.mPlotColorDarkBG = ColorHelper.ColorFromString(node.Attribute("PlotColor").Value); // } // flag = (node.Attribute("PlotColorL") != null); // if (flag) // { // color = ColorHelper.ColorFromString(node.Attribute("PlotColorL").Value); // } // flag = (node.Attribute("PlotNegValsDiffColor") != null); // if (flag) // { // this.mPlotNegValsDiffColor = bool.Parse(node.Attribute("PlotNegValsDiffColor").Value); // } // flag = (node.Attribute("NegPlotColor") != null); // if (flag) // { // this.mPlotNegColorDarkBG = ColorHelper.ColorFromString(node.Attribute("NegPlotColor").Value); // } // flag = (node.Attribute("NegPlotColorL") != null); // if (flag) // { // this.mPlotNegColorLightBG = ColorHelper.ColorFromString(node.Attribute("NegPlotColorL").Value); // } // flag = (node.Attribute("AreaColor") != null); // if (flag) // { // this.mAreaFillColorDarkBG = ColorHelper.ColorFromString(node.Attribute("AreaColor").Value); // } // flag = (node.Attribute("AreaColorL") != null); // if (flag) // { // this.mAreaFillColorLightBG = ColorHelper.ColorFromString(node.Attribute("AreaColorL").Value); // } // flag = (node.Attribute("Thickness") != null); // if (flag) // { // this.LinePlot_1593 = XmlHelper.ParseDouble(node.Attribute("Thickness").Value); // } // flag = (node.Attribute("DashPattern") != null); // if (flag) // { // string value = node.Attribute("DashPattern").Value; // string text = value; // flag = (Operators.CompareString(text, DashStyleType.Solid.ToString(), false) == 0); // if (flag) // { // this.DashStyle = DashStyleType.Solid; // } // else // { // flag = (Operators.CompareString(text, DashStyleType.Dashed.ToString(), false) == 0); // if (flag) // { // this.DashStyle = DashStyleType.Dashed; // } // else // { // flag = (Operators.CompareString(text, DashStyleType.Dotted.ToString(), false) == 0); // if (flag) // { // this.DashStyle = DashStyleType.Dotted; // } // else // { // flag = (Operators.CompareString(text, DashStyleType.LongDashes.ToString(), false) == 0); // if (flag) // { // this.DashStyle = DashStyleType.LongDashes; // } // } // } // } // } // flag = (node.Attribute("PlotStyle") != null); // if (flag) // { // string value2 = node.Attribute("PlotStyle").Value; // string text2 = value2.ToLower(); // flag = (Operators.CompareString(text2, "eline", false) == 0); // if (flag) // { // this.mPlotStyle = LinePlotType.Line; // } // else // { // flag = (Operators.CompareString(text2, "ehlc", false) == 0); // if (flag) // { // this.mPlotStyle = LinePlotType.HLC; // } // else // { // flag = (Operators.CompareString(text2, "eohlc", false) == 0); // if (flag) // { // this.mPlotStyle = LinePlotType.OHLC; // } // else // { // flag = (Operators.CompareString(text2, "ecandle", false) == 0); // if (flag) // { // this.mPlotStyle = LinePlotType.Candle; // } // else // { // flag = (Operators.CompareString(text2, "ebar", false) == 0); // if (flag) // { // this.mPlotStyle = LinePlotType.Bar; // } // else // { // flag = (Operators.CompareString(text2, "edot", false) == 0); // if (flag) // { // this.mPlotStyle = LinePlotType.Dot; // } // else // { // flag = (Operators.CompareString(text2, "earea", false) == 0); // if (flag) // { // this.mPlotStyle = LinePlotType.Area; // } // else // { // flag = (Operators.CompareString(text2, "eheikenashi", false) == 0); // if (flag) // { // this.mPlotStyle = LinePlotType.HeikenAshi; // } // } // } // } // } // } // } // } // } // flag = (node.Attribute("OutputDataGUID") != null); // if (flag) // { // OutputDataWrapper arg_501_0 = this.mOutputData; // Guid value3 = new Guid(node.Attribute("OutputDataGUID").Value); // arg_501_0.DataGUID = value3; // } // flag = (node.Attribute("SourceID") != null); // if (flag) // { // this.mPendingSourceUID = (string)node.Attribute("SourceID"); // } // try // { // IEnumerator enumerator = node.Elements().GetEnumerator(); // while (enumerator.MoveNext()) // { // XElement current = enumerator.Current; // flag = !(current.Name == "PLOTADDITIONS"); // if (flag) // { // var iXMLSavable = XmlTypeCreator.MakeElement(current); // flag = (iXMLSavable != null && iXMLSavable is ILineCalc); // if (flag) // { // this.mCalculation = (ILineCalc)iXMLSavable; // } // } // } // } // finally // { // //IEnumerator enumerator; // //flag = (enumerator != null); // //if (flag) // //{ // // enumerator.Dispose(); // //} // } // flag = !color.HasValue; // if (flag) // { // bool flag2 = this.mCalculation != null; // if (flag2) // { // this.mPlotColorLightBG = this.mCalculation.DefaultColorForLightBG(); // } // } // else // { // this.mPlotColorLightBG = color.Value; // } // base.ReadFromXML(node); //} //public override string GetXMLForDefault() //{ // List list = new List(); // list.Add("SAVEDEF"); // return this.ToXML(list).ToString(); //} public override void InitAsNew() { //this.mPlotType = ((ILineCalculation)this.PlotCalculation).DefaultPlotType; //this.mPlotColorDarkBG = this.PlotCalculation.DefaultColorForDarkBG(); //this.mPlotColorLightBG = this.PlotCalculation.DefaultColorForLightBG(); } public override void ReInstanceSources() { this.mOutputData.DataGUID = Guid.NewGuid(); } public override void SourceDataChange(object change) { bool flag = change is DataChangedArgs; if (flag) { var dChange = (DataChangedArgs)change; //flag = this.mOutputData != null && this.mOutputData.DataPoints != null && this.mOutputData.DataPoints.Any(); //if (flag) //{ // flag = mOutputData.IsIncludeOHLCDataPoint(dChange); // if (flag) // { // return; // } //} } //调用公司计算 this.Calculate(); } #endregion Public Methods #region Internal Methods internal override List BuildPlot(Chart owner, ScaleLayer aScale, IDateScaler dateScale, IValueScaler ValScale, Rect aRect) { //bool flag = this._isDark != owner.IsDarkBackground; //if (flag) //{ // this._isDark = owner.IsDarkBackground; // //flag = (this.PlotCalculation != null && this.PlotCalculation is IBackGroundAwareCalculation); // if (flag) // { // } //} this.mChart = owner; this.mScale = aScale; bool flag = false; // (this.mCalculation != null && this.mCalculation is ISelfPlottingLineCalc); var result = new List(); //创建指标图形 if (this.Indicator == null) return result; DashStyle = Indicator.DashStyleType; var painter = new PlotPainter(aRect, this._doubleCollection, Indicator.LineWidth); var eLinePlotType = Indicator.LinePlotType; switch (eLinePlotType) { case LinePlotType.Line: this.BuildAreaLine(painter, dateScale, ValScale, aRect, Indicator); break; case LinePlotType.HLC: flag = this.HasOHLC(); if (flag) { this.BuildHLCPoints(painter, dateScale, ValScale, aRect, Indicator); } else { this.BuildAreaLine(painter, dateScale, ValScale, aRect, Indicator); } break; case LinePlotType.OHLC: flag = this.HasOHLC(); if (flag) { this.BuildOHLCPoints(painter, dateScale, ValScale, aRect, Indicator); } else { this.BuildAreaLine(painter, dateScale, ValScale, aRect, Indicator); } break; case LinePlotType.Candlestick: flag = this.HasOHLC(); if (flag) { this.BuildCandlestickPoints(painter, dateScale, ValScale, aRect, Indicator); } else { this.BuildAreaLine(painter, dateScale, ValScale, aRect, Indicator); } break; case LinePlotType.Bar: this.BuildBarPoints(painter, dateScale, ValScale, aRect, Indicator); break; case LinePlotType.Dot: this.BuildDotPoints(painter, dateScale, ValScale, aRect, Indicator, true); break; case LinePlotType.CIRCLEDOT: this.BuildDotPoints(painter, dateScale, ValScale, aRect, Indicator, false); break; case LinePlotType.CROSSDOT: this.BuildCROSSDOTPoints(painter, dateScale, ValScale, aRect, Indicator); break; case LinePlotType.Area: this.BuildAreaLine(painter, dateScale, ValScale, aRect, Indicator); this.BuildAreaPolyLine(painter, dateScale, ValScale, aRect, Indicator); break; case LinePlotType.FillRGN: result.AddRange(this.BuildArea(dateScale, ValScale, aRect, Indicator)); break; //case LinePlotType.HeikenAshi: // flag = this.LinePlot_4886(); // if (flag) // { // this.LinePlot_4892(painter, dateScale, ValScale, aRect,indicatorModel); // } // else // { // this.LinePlot_4891(painter, dateScale, ValScale, aRect,indicatorModel); // } // break; } #region 暂时不使用 //flag = (this.Indicator.ParentFormula.IsMain && this.mChart != null && // this.mChart.CurrentTimeFrame.TotalDays < 1.0 && (this.Indicator.IsShowYestodayLines)); //if (flag) //{ // this.BuildYesterdaysCloseLine(painter, dateScale, ValScale, aRect, this.Indicator); //} //flag = (this.Indicator.ParentFormula.IsMain && this.mChart != null && this.mChart.CurrentTimeFrame.TotalDays < 1.0 ); //if (flag) //{ // this.BuildTodaysOpenLine(painter, dateScale, ValScale, aRect, this.Indicator); //} #endregion result.AddRange(painter.GetGraph()); try { List.Enumerator enumerator3 = result.GetEnumerator(); while (enumerator3.MoveNext()) { FrameworkElement current3 = enumerator3.Current; current3.IsHitTestVisible = (false); } } finally { //List.Enumerator enumerator3; //enumerator3.Dispose(); } return result; } /// /// Calculates this instance. /// internal override void Calculate() { // bool flag = this.PlotCalculation is IBackGroundAwareCalculation; // if (flag) // { // ((IBackGroundAwareCalculation)this.PlotCalculation).SetCurrentBackground(this._isDark); // } // //flag = (this.mCalculation != null && this.mCalculation is PriceHistoryCalculation); // //if (flag) // //{ // // ((PriceHistoryCalculation)this.mCalculation).isHeikenAshi = (this.mPlotType == LinePlotType.HeikenAshi); // //} // ////线状图设为一单色 // //var cal = this.mCalculation as PriceHistoryCalculation; // //if (cal != null && this.mChart != null) // //{ // // cal.ColorMode = this.mChart.LinePlotType == LinePlotType.Line || this.mChart.LinePlotType == LinePlotType.Area ? // // PriceColorType.OneColor : PriceColorType.CloseUpDown; // //} // this.mOutputData.OnDataSetDataChanged(((ILineCalculation)this.PlotCalculation).Calculate(this.mSource, this.CurrentPlotColor())); } internal override Color GetColor() { return this.CurrentPlotColor(); } /// /// 检测画图面板中的图例,并返回它们在aDate日期下的数据面板 /// /// /// /// /// internal override List GetControlPairs(DateTime aDate, bool isDarkBackground, bool isForex) { var digits = isForex ? 4 : 2; var list = GetControlPairs(aDate, isDarkBackground, digits); return list; } /// /// Gets the control pairs. /// /// A date. /// if set to true [is dark background]. /// The digits. /// List{ControlPair}. internal override List GetControlPairs(DateTime aDate, bool isDarkBackground, int digits) { var list = new List(); checked { bool flag2 = this.Indicator.ParentFormula.IsMain; #region 显示当前的主图数据到面板中 if (flag2) { if (this.OutputSource == null || this.OutputSource.CalculateDataPoints == null) return list; var datapoint = this.OutputSource.CalculateDataPoints.FirstOrDefault((point) => DateTime.Compare(point.Date, aDate) == 0); if (datapoint == null) return list; var iOHLCDataPoint = (IBarDataPoint)datapoint; list.Add( this.BuildQuoteControlPair( LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_Open), iOHLCDataPoint.Open, isDarkBackground, digits, false)); list.Add( this.BuildQuoteControlPair( LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_High), iOHLCDataPoint.High, isDarkBackground, digits, false)); list.Add( this.BuildQuoteControlPair( LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_Low), iOHLCDataPoint.Low, isDarkBackground, digits, false)); list.Add( this.BuildQuoteControlPair( LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_Close), iOHLCDataPoint.Close, isDarkBackground, digits, false)); var increase = GetIncrease(iOHLCDataPoint); list.Add( this.BuildQuoteControlPair( LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_Increase), increase.ToString("P2"), isDarkBackground)); var increaseValue = GetIncreaseValue(iOHLCDataPoint); list.Add(this.BuildQuoteControlPair(LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_AmountChanges), increaseValue, isDarkBackground, 2, true)); list.Add( this.BuildQuoteControlPair( LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_Turnover), iOHLCDataPoint.Turnover, isDarkBackground, 2, true)); //期货才有持仓量 if (this.mChart != null && this.mChart.CurrentGoods != null && mChart.CurrentGoods.GoodsType == GoodsType.Futures) { list.Add( this.BuildQuoteControlPair( LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_HoldVolume), iOHLCDataPoint.HoldVolume, isDarkBackground, 2, true)); } } #endregion else { if (this.Indicator.LinePlotType != LinePlotType.FillRGN && this.Indicator.LinePlotType != LinePlotType.Area) { list.AddRange(this.GetPointControlPairs(aDate, digits, true)); } } } return list; } /// /// Gets the increase. /// /// The data point. /// System.Single. private float GetIncrease(IBarDataPoint dataPoint) { if (mChart == null || mChart.DataSet == null || mChart.DataSet.DataPoints == null || dataPoint == null) return 0; var dataPoints = mChart.DataSet.DataPoints; var item = dataPoints.FirstOrDefault(z => z.Date == dataPoint.Date); if (item == null) return 0; var index = dataPoints.IndexOf(item); if (index == 0) { return dataPoint.Open.Equals(0) ? 0f : (dataPoint.Close - dataPoint.Open) / dataPoint.Open; } else { var last = dataPoints[index - 1] as IOHLCDataPoint; if (last == null || last.Close == 0) return dataPoint.Open.Equals(0) ? 0f : (dataPoint.Close - dataPoint.Open) / dataPoint.Open; return last.Close.Equals(0) ? 0f : (dataPoint.Close - last.Close) / last.Close; } return 0; } /// /// Gets the increase. /// /// The data point. /// System.Single. private float GetIncreaseValue(IBarDataPoint dataPoint) { if (mChart == null || mChart.DataSet == null || mChart.DataSet.DataPoints == null || dataPoint == null) return 0; var dataPoints = mChart.DataSet.DataPoints; var item = dataPoints.FirstOrDefault(z => z.Date == dataPoint.Date); if (item == null) return 0; var index = dataPoints.IndexOf(item); if (index == 0) { return dataPoint.Open.Equals(0) ? 0f : (dataPoint.Close - dataPoint.Open); } else { var last = dataPoints[index - 1] as IOHLCDataPoint; if (last == null || last.Close == 0) return dataPoint.Open.Equals(0) ? 0f : (dataPoint.Close - dataPoint.Open); return last.Close.Equals(0) ? 0f : (dataPoint.Close - last.Close); } return 0; } /// /// 应用公式计算的值 /// /// //internal ILineDataSet GetDataSet() //{ // // return this.mOutputData; // return this.OutputSource; //} internal ILineDataSetWithUid LinePlot_4866() { return this.mOutputData; } /// /// 应用公司计算的值 /// /// internal IndicatorModel GetDataSet() { // return this.mOutputData; return this.OutputSource; } /// /// Gets the color of the plot. /// /// Color. internal override Color GetPlotColor() { if (this.Indicator != null) return this.Indicator.UpBrush; return Colors.White; } internal override void ShowPlotEdit(FrameworkElement relativeTo) { bool flag = this.mChart == null; if (!flag) { //LinePlotEditor linePlotEditor = new LinePlotEditor(this, this.mChart); //linePlotEditor.Show(relativeTo); } } #endregion Internal Methods #region Protected Methods internal Color CurrentPlotColor() { return _isDark ? this.mPlotColorDarkBG : this.mPlotColorLightBG; } /// /// 04月08日 /// protected override void DeleteData() { //bool flag = this.mOutputData != null; //if (flag) //{ // this.mOutputData.OnDelete(); // //this.mOutputData.OnDataSetDataChanged(); //} } /// /// 添加其他指标数据到面板 /// private List GetPointControlPairs(DateTime aDate, bool isForex, bool allowAbbreviate) { var digits = isForex ? 4 : 2; return GetPointControlPairs(aDate, digits, allowAbbreviate); } /// /// 添加其他指标数据到面板 /// /// A date. /// The digits. /// if set to true [allow abbreviate]. /// List{ControlPair}. private List GetPointControlPairs(DateTime aDate, int digits, bool allowAbbreviate) { var pairList = new List(); if (this.Indicator == null || this.Indicator.CalculateDataPoints == null) return pairList; ILineDataPoint dataPoint = null; if (this.mChart != null && this.mChart.CycleType == CycleType.TimeSharing) { dataPoint = this.Indicator.CalculateDataPoints.FirstOrDefault(z => z.Date.Date == aDate.Date && z.Date.Hour == aDate.Hour && z.Date.Minute == aDate.Minute); } else { dataPoint = this.Indicator.CalculateDataPoints.FirstOrDefault( (point) => DateTime.Compare(point.Date, aDate) == 0); } if (dataPoint == null) return pairList; if (float.IsNaN(dataPoint.Value)) return pairList; var leftTextBlock = new TextBlock { Text = this.Indicator.LineName, Foreground = new SolidColorBrush(Indicator.UpBrush), Padding = new Thickness(10.0, 0.0, 10.0, 0.0), }; var rightTextBlock = new TextBlock { Text = TextFormatting.FormatNumber(dataPoint.Value, digits, allowAbbreviate), Foreground = leftTextBlock.Foreground, HorizontalAlignment = HorizontalAlignment.Right, Padding = new Thickness(5.0, 0.0, 0.0, 0.0) }; pairList.Add(new ControlPair { ControlLeft = leftTextBlock, ControlRight = rightTextBlock }); return pairList; } protected ControlPair GetPointerPair(string desc, Color descColor, float aVal, bool indent, bool isForex, bool allowAbbreviate) { var digits = isForex ? 4 : 2; return GetPointerPair(desc, descColor, aVal, indent, digits, allowAbbreviate); } protected ControlPair GetPointerPair(string desc, Color descColor, float aVal, bool indent, int digits, bool allowAbbreviate) { var foreground = new SolidColorBrush(descColor); var textBlock = new TextBlock { Text = desc, Foreground = (foreground), Margin = indent ? new Thickness(15.0, 3.0, 0.0, 0.0) : new Thickness(0.0, 3.0, 0.0, 0.0) }; var textBlock2 = new TextBlock { Text = TextFormatting.FormatNumber(aVal, digits, allowAbbreviate), Foreground = (foreground), HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(5.0, 3.0, 0.0, 0.0) }; return new ControlPair { ControlLeft = textBlock, ControlRight = textBlock2 }; } #endregion Protected Methods #region Private Methods private void BuildAreaLine(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel) { var list = indicatorModel.CalculateDataPoints; var upbrush = indicatorModel.UpBrush; bool flag = list != null; checked { if (flag) { bool flag2 = this.NotHasColoredDataPoint(); if (flag2) { int num = dateScale.FirstVisibleIndexFromData(list); num--; num = Math.Max(0, num); int upper = list.Count; for (int i = num; i < upper; i++) { if (dateScale.DateVisible(list[i].Date)) { float x = dateScale.XforDate(list[i].Date); if (!float.IsNaN(list[i].Value)) { var point = new Point((double)x, (double)valScale.ScaledY(list[i].Value, aRect)); painter.AddPoint(point, upbrush); } } } } else { int num = dateScale.FirstVisibleIndexFromData(list); //线从第2个点开始,第1个点忽略. num = Math.Max(1, num); var upper = list.Count; for (int i = num; i < upper; i++) { var start = list[i - 1]; var end = list[i]; flag2 = (dateScale.DateVisible(start.Date) || dateScale.DateVisible(end.Date)); if (flag2) { float startX = dateScale.XforDate(start.Date); float endX = dateScale.XforDate(end.Date); if (!float.IsNaN(startX) && float.IsNaN(endX)) { var lineGeometry = new LineGeometry() { StartPoint = new Point((double)startX, (double)valScale.ScaledY(start.Value, aRect)), EndPoint = new Point((double)endX, (double)valScale.ScaledY(end.Value, aRect)) }; painter.AddLine(lineGeometry, upbrush); } } } } } } } private void BuildAreaPolyLine(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel) { var list = indicatorModel.CalculateDataPoints; bool flag = list != null; checked { if (flag) { int num = dateScale.FirstVisibleIndexFromData(list); flag = (num < 0); if (flag) { num = 0; } int num2 = (int)Math.Round(unchecked(this.mAreaFillOpacity * 255.0)); flag = (num2 < 0); if (flag) { num2 = 0; } flag = (num2 > 255); if (flag) { num2 = 255; } var solidBrush = indicatorModel.AreaBrush; Color aColor = Colors.Transparent; if (!ColorHelper.IsEmptyColor(solidBrush)) { aColor = Color.FromArgb((byte)num2, solidBrush.R, solidBrush.G, solidBrush.B); } var pathGeometry = new PathGeometry(); var pathFigure = new PathFigure(); pathGeometry.Figures.Add(pathFigure); var arg_FC_0 = pathFigure; Point point = new Point(aRect.Left, (double)valScale.ScaledY(0f, aRect)); arg_FC_0.StartPoint = (point); var polyLineSegment = new PolyLineSegment(); pathFigure.Segments.Add(polyLineSegment); int arg_124_0 = num; int num3 = list.Count - 1; int num4 = arg_124_0; float num6 = 0f; while (true) { int arg_194_0 = num4; int num5 = num3; if (arg_194_0 > num5) { break; } flag = dateScale.DateVisible(list[num4].Date); if (flag) { num6 = dateScale.XforDate(list[num4].Date); var arg_17E_0 = polyLineSegment.Points; point = new Point((double)num6, (double)valScale.ScaledY(list[num4].Value, aRect)); arg_17E_0.Add(point); } num4++; } var arg_1B7_0 = polyLineSegment.Points; point = new Point((double)num6, (double)valScale.ScaledY(0f, aRect)); arg_1B7_0.Add(point); var arg_1E3_0 = polyLineSegment.Points; point = new Point(aRect.Left, (double)valScale.ScaledY(0f, aRect)); arg_1E3_0.Add(point); painter.AddShape(pathGeometry, aColor); } } } private void BuildBarPoints(PlotPainter Painter, IDateScaler dateScale, IValueScaler ValScale, Rect aRect, IndicatorModel indicatorModel) { var list = indicatorModel.CalculateDataPoints; var width = (float)checked((int)Math.Round((double)dateScale.DistanceBetweenDates()) - 4); bool flag = width > 10f; if (flag) { width -= 4f; } checked { var num2 = (int)Math.Round((double)(width / 2f)); flag = (list != null); if (flag) { int startIndex = dateScale.FirstVisibleIndexFromData(list); int endIndex = list.Count; for (int i = startIndex; i < endIndex; i++) { flag = dateScale.DateVisible(list[i].Date); if (flag) { Color aColor = Colors.White; if (indicatorModel.VolBar) { aColor = this.GetPointColor(list[i]); } else { var upColorBrush = indicatorModel.UpBrush; if (!ColorHelper.IsEmptyColor(upColorBrush)) { aColor = upColorBrush; } else { indicatorModel.UpBrush = (Colors.White); } } flag = (indicatorModel.PlotNegValsDiffColor && list[i].Value < 0f); if (flag) { var solidColorBrush = indicatorModel.DownBrush; if (!ColorHelper.IsEmptyColor(solidColorBrush)) { aColor = solidColorBrush; } } var num7 = (float)((int)Math.Round((double)dateScale.XforDate(list[i].Date))); flag = (width > 1f); unchecked { if (flag) { var rectangleGeometry = new RectangleGeometry(); Rect rect = default(Rect); double num8 = (double)ValScale.ScaledY(list[i].Value, aRect) - 0.5; double num9 = (double)ValScale.ScaledY(0f, aRect) - 0.5; flag = (num8 > num9); if (flag) { double num10 = num8; num8 = num9; num9 = num10; } rect.X = ((double)(num7 - (float)num2) + 0.5); rect.Y = (num8); rect.Width = ((double)width); rect.Height = (Math.Max(-0.5, num9 - rect.Top)); rectangleGeometry.Rect = (rect); Painter.AddShape(rectangleGeometry, aColor); } else { var lineGeometry = new LineGeometry { StartPoint = new Point((double)num7 + 0.5, (double)ValScale.ScaledY(list[i].Value, aRect)), EndPoint = new Point((double)num7 + 0.5, (double)ValScale.ScaledY(0f, aRect)) }; Painter.AddLine(lineGeometry, aColor); } } } } } } } private void BuildCandlestickPoints(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel) { var list = indicatorModel.CalculateDataPoints; if (list == null || !list.Any()) return; var num = (float)((int)Math.Round(unchecked(0.3 * (double)dateScale.DistanceBetweenDates()))); #region 未知作用 bool upFilled = true; bool downFilled = true; var fillModel = PriceColorType.BarUpDown; //var price = this.PlotCalculation as PriceHistoryCalculation; //if (price != null) //{ // upFilled = price.UpFilled; // downFilled = price.DownFilled; // fillModel = price.FillMode; //} #endregion var start = dateScale.FirstVisibleIndexFromData(list); var length = list.Count; for (var i = start; i < length; i++) { var current = list[i]; var visible = dateScale.DateVisible(current.Date); if (!visible) continue; var ohlcDataPoint = current as IOHLCDataPoint; if (ohlcDataPoint == null) continue; var dateX = (float)((int)Math.Round((double)dateScale.XforDate(ohlcDataPoint.Date))); var color = this.GetPointColor(ohlcDataPoint); var isFill = false; var isRising = false; var isDeclining = false; if (ohlcDataPoint.Close > ohlcDataPoint.Open) { isRising = true; isFill = upFilled; } else if (ohlcDataPoint.Close < ohlcDataPoint.Open) { isDeclining = true; isFill = downFilled; } if (i > 0 && fillModel == PriceColorType.CloseUpDown) { if (ohlcDataPoint.Close > ohlcDataPoint.Value) { isFill = upFilled; } else if (ohlcDataPoint.Close < ohlcDataPoint.Value) { isFill = downFilled; } } var rect = new Rect(); if (!isRising && !isDeclining) { //相等画直线 rect = new Rect(dateX - num + 0.5, 0.5 + valScale.ScaledY(ohlcDataPoint.Open, aRect), 2f * num, 0); painter.AddLine(new LineGeometry { StartPoint = new Point(rect.X - 0.5, rect.Y), EndPoint = new Point(rect.Right + 0.5, rect.Y) }, color); } else if (isRising) { rect = new Rect(dateX - num + 0.5, 0.5 + (double)valScale.ScaledY(ohlcDataPoint.Close, aRect), 2f * num, 0); rect.Height = (0.5 + (double)valScale.ScaledY(ohlcDataPoint.Open, aRect) - rect.Top); var rectangleGeometry = new RectangleGeometry { Rect = rect }; if (isFill) { painter.AddShape(rectangleGeometry, color); } else { painter.AddLine(rectangleGeometry, color); } } else { rect = new Rect(dateX - num + 0.5, 0.5 + (double)valScale.ScaledY(ohlcDataPoint.Open, aRect), 2f * num, 0); rect.Height = (0.5 + (double)valScale.ScaledY(ohlcDataPoint.Close, aRect) - rect.Top); var rectangleGeometry = new RectangleGeometry { Rect = (rect) }; if (isFill) { painter.AddShape(rectangleGeometry, color); } else { painter.AddLine(rectangleGeometry, color); } } painter.AddLine(new LineGeometry { StartPoint = new Point(dateX + 0.5, (double)valScale.ScaledY(ohlcDataPoint.High, aRect)), EndPoint = new Point((double)dateX + 0.5, rect.Top) }, color); painter.AddLine(new LineGeometry { StartPoint = new Point(dateX + 0.5, (double)valScale.ScaledY(ohlcDataPoint.Low, aRect)), EndPoint = new Point(dateX + 0.5, rect.Bottom) }, color); } } private void BuildDotPoints(PlotPainter Painter, IDateScaler dateScale, IValueScaler ValScale, Rect aRect, IndicatorModel indicatorModel, bool IsfillPoint) { var list = indicatorModel.CalculateDataPoints; checked { float num = (float)((int)Math.Round(unchecked(0.35 * (double)dateScale.DistanceBetweenDates()))); bool flag = num <= 1f; if (flag) { num = 1.01f; } flag = ((double)num > 3.5); if (flag) { num = 3.5f; } flag = (list != null); if (flag) { int num2 = dateScale.FirstVisibleIndexFromData(list); int arg_90_0 = num2; int num3 = list.Count - 1; int num4 = arg_90_0; while (true) { int arg_1EA_0 = num4; int num5 = num3; if (arg_1EA_0 > num5) { break; } flag = dateScale.DateVisible(list[num4].Date); if (flag) { // Color aColor = this.GetPointColor(list[num4]); Color aColor = Colors.White; // this.GetPointColor(list[num4]); var upColorBrush = indicatorModel.UpBrush; if (!ColorHelper.IsEmptyColor(upColorBrush)) { aColor = upColorBrush; } else { indicatorModel.UpBrush = (Colors.White); } var scalefloat = dateScale.XforDate(list[num4].Date); if (float.IsNaN(scalefloat)) { float num6 = (float)((int)Math.Round((double)scalefloat)); flag = (num > 1f); unchecked { if (flag) { EllipseGeometry ellipseGeometry = new EllipseGeometry(); double num7 = (double)ValScale.ScaledY(list[num4].Value, aRect) - 0.5; EllipseGeometry arg_123_0 = ellipseGeometry; Point point = new Point((double)num6, num7); arg_123_0.Center = (point); ellipseGeometry.RadiusX = ((double)num); ellipseGeometry.RadiusY = ((double)num); Painter.AddShape(ellipseGeometry, aColor, IsfillPoint); } else { LineGeometry lineGeometry = new LineGeometry(); Painter.AddLine(lineGeometry, aColor); LineGeometry arg_198_0 = lineGeometry; Point point = new Point((double)num6 + 0.5, (double)ValScale.ScaledY(list[num4].Value, aRect) - 0.5); arg_198_0.StartPoint = (point); LineGeometry arg_1D6_0 = lineGeometry; point = new Point((double)num6 + 0.5, (double)ValScale.ScaledY(list[num4].Value, aRect) + 0.5); arg_1D6_0.EndPoint = (point); } } } } num4++; } } } } private void BuildCROSSDOTPoints(PlotPainter Painter, IDateScaler dateScale, IValueScaler ValScale, Rect aRect, IndicatorModel indicatorModel) { var list = indicatorModel.CalculateDataPoints; checked { float num = (float)((int)Math.Round(unchecked(0.35 * (double)dateScale.DistanceBetweenDates()))); bool flag = num <= 1f; if (flag) { num = 1.01f; } flag = ((double)num > 3.5); if (flag) { num = 3.5f; } flag = (list != null); if (flag) { int num2 = dateScale.FirstVisibleIndexFromData(list); int arg_90_0 = num2; int num3 = list.Count - 1; int num4 = arg_90_0; while (true) { int arg_1EA_0 = num4; int num5 = num3; if (arg_1EA_0 > num5) { break; } flag = dateScale.DateVisible(list[num4].Date); if (flag) { Color aColor = Colors.White; // this.GetPointColor(list[num4]); var upColorBrush = (indicatorModel.UpBrush); if (!ColorHelper.IsEmptyColor(upColorBrush)) { aColor = upColorBrush; } else { indicatorModel.UpBrush = (Colors.White); } var scalefloat = dateScale.XforDate(list[num4].Date); if (float.IsNaN(scalefloat)) { float num6 = (float)((int)Math.Round(scalefloat)); flag = (num > 1f); unchecked { if (flag) { PathGeometry pathGeometry = new PathGeometry(); double num7 = (double)ValScale.ScaledY(list[num4].Value, aRect) - 0.5; LineGeometry line1 = new LineGeometry(new Point(num6 - num, num7 - num), new Point(num6 + num, num7 + num)); LineGeometry line2 = new LineGeometry(new Point(num6 - num, num7 + num), new Point(num6 + num, num7 - num)); pathGeometry.AddGeometry(line1); pathGeometry.AddGeometry(line2); Painter.AddShape(pathGeometry, aColor); } else { LineGeometry lineGeometry = new LineGeometry(); Painter.AddLine(lineGeometry, aColor); LineGeometry arg_198_0 = lineGeometry; Point point = new Point((double)num6 + 0.5, (double)ValScale.ScaledY(list[num4].Value, aRect) - 0.5); arg_198_0.StartPoint = (point); LineGeometry arg_1D6_0 = lineGeometry; point = new Point((double)num6 + 0.5, (double)ValScale.ScaledY(list[num4].Value, aRect) + 0.5); arg_1D6_0.EndPoint = (point); } } } } num4++; } } } } private void BuildHLCPoints(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel) { var list = indicatorModel.CalculateDataPoints; checked { float num = (float)((int)Math.Round(unchecked(0.3 * (double)dateScale.DistanceBetweenDates()))); bool flag = list != null; if (flag) { int num2 = dateScale.FirstVisibleIndexFromData(list); int arg_60_0 = num2; int num3 = list.Count - 1; int num4 = arg_60_0; while (true) { int arg_1B5_0 = num4; int num5 = num3; if (arg_1B5_0 > num5) { break; } flag = dateScale.DateVisible(list[num4].Date); if (flag) { Color aColor = this.GetPointColor(list[num4]); float num6 = (float)((int)Math.Round((double)dateScale.XforDate(list[num4].Date))); IOHLCDataPoint iOHLCDataPoint = (IOHLCDataPoint)list[num4]; LineGeometry lineGeometry = new LineGeometry(); painter.AddLine(lineGeometry, aColor); LineGeometry arg_F5_0 = lineGeometry; unchecked { Point point = new Point((double)num6 + 0.5, (double)valScale.ScaledY(iOHLCDataPoint.High, aRect)); arg_F5_0.StartPoint = (point); LineGeometry arg_12A_0 = lineGeometry; point = new Point((double)num6 + 0.5, (double)(1f + valScale.ScaledY(iOHLCDataPoint.Low, aRect))); arg_12A_0.EndPoint = (point); lineGeometry = new LineGeometry(); painter.AddLine(lineGeometry, aColor); LineGeometry arg_173_0 = lineGeometry; point = new Point((double)(num6 + num + 1f), 0.5 + (double)valScale.ScaledY(iOHLCDataPoint.Close, aRect)); arg_173_0.StartPoint = (point); LineGeometry arg_1A2_0 = lineGeometry; point = new Point((double)num6, 0.5 + (double)valScale.ScaledY(iOHLCDataPoint.Close, aRect)); arg_1A2_0.EndPoint = (point); } } num4++; } } } } private void BuildOHLCPoints(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel) { var list = indicatorModel.CalculateDataPoints; checked { float num = (float)((int)Math.Round(unchecked(0.3 * (double)dateScale.DistanceBetweenDates()))); bool flag = list != null; if (flag) { int num2 = dateScale.FirstVisibleIndexFromData(list); int num3 = list.Count - 1; while (true) { if (num2 > num3) { break; } flag = dateScale.DateVisible(list[num2].Date); if (flag) { Color aColor = this.GetPointColor(list[num2]); float num6 = (float)((int)Math.Round((double)dateScale.XforDate(list[num2].Date))); var iOHLCDataPoint = (IOHLCDataPoint)list[num2]; var lineGeometry = new LineGeometry(); painter.AddLine(lineGeometry, this.GetPointColor(list[num2])); unchecked { Point point = lineGeometry.StartPoint = new Point((double)num6 + 0.5, (double)valScale.ScaledY(iOHLCDataPoint.High, aRect)); lineGeometry.EndPoint = new Point((double)num6 + 0.5, (double)(1f + valScale.ScaledY(iOHLCDataPoint.Low, aRect))); lineGeometry = new LineGeometry(); painter.AddLine(lineGeometry, aColor); lineGeometry.StartPoint = new Point((double)(num6 - num), 0.5 + (double)valScale.ScaledY(iOHLCDataPoint.Open, aRect)); lineGeometry.EndPoint = new Point((double)(num6 + 1f), 0.5 + (double)valScale.ScaledY(iOHLCDataPoint.Open, aRect)); lineGeometry = new LineGeometry(); painter.AddLine(lineGeometry, aColor); lineGeometry.StartPoint = new Point((double)(num6 + num + 1f), 0.5 + (double)valScale.ScaledY(iOHLCDataPoint.Close, aRect)); lineGeometry.EndPoint = new Point((double)num6, 0.5 + (double)valScale.ScaledY(iOHLCDataPoint.Close, aRect)); } } num2++; } } } } /// /// 返回光标处的弹出菜单元素 /// /// The desc. /// A value. /// if set to true [is dark background]. /// The digits. /// if set to true [allow abbreviate]. /// ControlPair. private ControlPair BuildQuoteControlPair(string desc, float aVal, bool isDarkBackground, int digits, bool allowAbbreviate) { var foreground = isDarkBackground ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Black); var leftTextBlock = new TextBlock { Text = desc, Foreground = foreground, Padding = new Thickness(10.0, 0.0, 10.0, 0.0), }; var rightTextBlock = new TextBlock { Text = TextFormatting.FormatNumber(aVal, digits, allowAbbreviate), Foreground = foreground, HorizontalAlignment = HorizontalAlignment.Right, Padding = new Thickness(5.0, 0.0, 0.0, 0.0) }; return new ControlPair { ControlLeft = leftTextBlock, ControlRight = rightTextBlock }; } /// /// Builds the quote control pair. /// /// The desc. /// The value string. /// if set to true [is dark background]. /// ControlPair. private ControlPair BuildQuoteControlPair(string desc, string valueString, bool isDarkBackground) { var foreground = isDarkBackground ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Black); var leftTextBlock = new TextBlock { Text = desc, Foreground = foreground, Padding = new Thickness(10.0, 0.0, 10.0, 0.0), }; var rightTextBlock = new TextBlock { Text = valueString, Foreground = foreground, HorizontalAlignment = HorizontalAlignment.Right, Padding = new Thickness(5.0, 0.0, 0.0, 0.0) }; return new ControlPair { ControlLeft = leftTextBlock, ControlRight = rightTextBlock }; } /// /// 创建区域图 /// /// /// /// /// private List BuildArea(IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel) { var list = new List(); var path = new Path(); var rectangleGeometry = new RectangleGeometry(); rectangleGeometry.Rect = (aRect); path.Clip = (rectangleGeometry); path.UseLayoutRounding = (true); var solidColorBrush = new SolidColorBrush((this.Indicator.AreaBrush)); solidColorBrush.Opacity = ((double)this.Indicator.Alpha / 256); path.StrokeThickness = indicatorModel.LineWidth < 1 ? 1 : indicatorModel.LineWidth; path.Fill = (solidColorBrush); var pathGeometry = new PathGeometry(); path.Data = (pathGeometry); var pathFigure = new PathFigure(); pathGeometry.Figures.Add(pathFigure); var list2 = indicatorModel.SubData[indicatorModel.FillRNGKey] as List; var doubleCond = indicatorModel.SubData[indicatorModel.CondKey] as double[]; bool flag = false; bool flag2 = list2 != null && doubleCond != null; checked { bool flag3; if (flag2) { int num = list2.Count - 1; int num2 = 0; while (true) { int arg_1BF_0 = num2; int num3 = num; if (arg_1BF_0 > num3) { break; } bool arg_125_0 = (dateScale.DateVisible(list2[num2].Date) || (num2 < list2.Count - 1 && dateScale.DateVisible(list2[num2 + 1].Date))) || (num2 > 0 && dateScale.DateVisible(list2[num2 - 1].Date)); flag3 = arg_125_0 && Convert.ToBoolean(doubleCond[num2]); if (flag3) { float num4 = valScale.ScaledY(list2[num2].Value, aRect); float num5 = dateScale.XforDate(list2[num2].Date); flag3 = !flag; if (flag3) { var arg_175_0 = pathFigure; Point startPoint = new Point((double)num5, (double)num4); arg_175_0.StartPoint = (startPoint); flag = true; } else { var lineSegment = new LineSegment(); var arg_19A_0 = lineSegment; Point startPoint = new Point((double)num5, (double)num4); arg_19A_0.Point = (startPoint); pathFigure.Segments.Add(lineSegment); } } num2++; } } list2 = this.Indicator.CalculateDataPoints; flag3 = (list2 != null) && doubleCond != null; ; if (flag3) { int num6 = list2.Count - 1; while (true) { int arg_2E3_0 = num6; int num3 = 0; if (arg_2E3_0 < num3) { break; } bool arg_24A_0 = (dateScale.DateVisible(list2[num6].Date) || (num6 < list2.Count - 1 && dateScale.DateVisible(list2[num6 + 1].Date))) || (num6 > 0 && dateScale.DateVisible(list2[num6 - 1].Date)); flag2 = arg_24A_0 && Convert.ToBoolean(doubleCond[num6]); ; if (flag2) { float num7 = valScale.ScaledY(list2[num6].Value, aRect); float num8 = dateScale.XforDate(list2[num6].Date); flag3 = !flag; if (flag3) { PathFigure arg_29A_0 = pathFigure; Point startPoint = new Point((double)num8, (double)num7); arg_29A_0.StartPoint = (startPoint); flag = true; } else { LineSegment lineSegment = new LineSegment(); LineSegment arg_2BF_0 = lineSegment; Point startPoint = new Point((double)num8, (double)num7); arg_2BF_0.Point = (startPoint); pathFigure.Segments.Add(lineSegment); } } num6 += -1; } } flag3 = flag; if (flag3) { LineSegment lineSegment = new LineSegment(); LineSegment arg_322_0 = lineSegment; Point startPoint = pathFigure.StartPoint; Point point = new Point(startPoint.X, pathFigure.StartPoint.Y); arg_322_0.Point = (point); pathFigure.Segments.Add(lineSegment); } list.Add(path); return list; } } #region 暂时未用到 private void BuildTodaysOpenLine(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel) { var list = indicatorModel.CalculateDataPoints; bool flag = list != null && list.Count > 1; checked { if (flag) { DateTime aDate = list[list.Count - 1].Date; int num = list.Count - 1; while (true) { if (num < 0) { return; } flag = (DateTime.Compare(list[num].Date.Date, aDate.Date) < 0); if (flag) { break; } num += -1; } bool flag2 = num < list.Count - 1; if (flag2) { float num3 = dateScale.XforDate(list[num + 1].Date); float num4 = dateScale.XforDate(aDate); var lineGeometry = new LineGeometry(); float aVal = list[num + 1].Value; flag2 = (list[num + 1] is IOHLCDataPoint); if (flag2) { aVal = ((IOHLCDataPoint)list[num + 1]).Open; } painter.AddLine(lineGeometry, c_TodayOpenColor); unchecked { lineGeometry.StartPoint = new Point((double)num4, 0.5 + (double)valScale.ScaledY(aVal, aRect)); lineGeometry.EndPoint = new Point((double)num3, 0.5 + (double)valScale.ScaledY(aVal, aRect)); } } } } } private void BuildYesterdaysCloseLine(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel) { var list = indicatorModel.CalculateDataPoints; bool flag = list != null && list.Count > 1; if (flag) { int num; float num3; float num4; LineGeometry lineGeometry; LineGeometry arg_F7_0; checked { DateTime aDate = list[list.Count - 1].Date; num = list.Count - 1; while (true) { int arg_13F_0 = num; int num2 = 0; if (arg_13F_0 < num2) { return; } flag = (DateTime.Compare(list[num].Date.Date, aDate.Date) < 0); if (flag) { break; } num += -1; } num3 = dateScale.XforDate(list[num].Date); num4 = dateScale.XforDate(aDate); lineGeometry = new LineGeometry(); painter.AddLine(lineGeometry, c_YestodayColor); arg_F7_0 = lineGeometry; } Point point = new Point((double)num4, 0.5 + (double)valScale.ScaledY(list[num].Value, aRect)); arg_F7_0.StartPoint = (point); LineGeometry arg_12A_0 = lineGeometry; point = new Point((double)num3, 0.5 + (double)valScale.ScaledY(list[num].Value, aRect)); arg_12A_0.EndPoint = (point); } } #endregion private Color GetPointColor(ILineDataPoint aPoint) { bool flag = aPoint is IColoredDataPoint; Color result; if (flag) { result = ((IColoredDataPoint)aPoint).Color; } else { result = this.CurrentPlotColor(); } return result; } private bool HasOHLC() { //bool flag = this.mOutputData == null || this.mOutputData.DataPoints == null; //checked //{ // if (!flag) // { // var list = this.mOutputData.DataPoints; // int num = list.Count - 1; // int num2 = 0; // while (true) // { // int num3 = num; // if (num2 > num3) // { // return false; // } // flag = (list[num2] is IOHLCDataPoint); // if (flag) // { // break; // } // num2++; // } // return true; // } // return false; //} return true; } private bool NotHasColoredDataPoint() { //if (this.mOutputData == null || this.mOutputData.DataPoints == null) return true; //return !this.mOutputData.DataPoints.OfType().Any(); return true; } private void OnPlotStyleChanged() { if (PlotStyleChanged != null) { PlotStyleChanged(); } } #endregion Private Methods #endregion Methods #region Other //public override XElement ToXML(List args) //{ // XElement xElement = new XElement(this.RootName()); // xElement.Add(new XAttribute("PlotColor", this.mPlotColorDarkBG.ToString())); // xElement.Add(new XAttribute("PlotColorL", this.mPlotColorLightBG.ToString())); // bool flag = this.mPlotNegValsDiffColor; // if (flag) // { // xElement.Add(new XAttribute("PlotNegValsDiffColor", true.ToString())); // } // xElement.Add(new XAttribute("NegPlotColor", this.mPlotNegColorDarkBG.ToString())); // xElement.Add(new XAttribute("NegPlotColorL", this.mPlotNegColorLightBG.ToString())); // xElement.Add(new XAttribute("AreaColor", this.mAreaFillColorDarkBG.ToString())); // xElement.Add(new XAttribute("AreaColorL", this.mAreaFillColorLightBG.ToString())); // xElement.Add(new XAttribute("PlotStyle", this.mPlotStyle.ToString())); // xElement.Add(new XAttribute("Thickness", this.LinePlot_1593.ToString())); // xElement.Add(new XAttribute("DashPattern", this.LinePlot_1591.ToString())); // xElement.Add(new XAttribute("OutputDataGUID", this.mOutputData.DataGUID.ToString())); // flag = (this.mSource != null && (args == null || !args.Contains("NOSAVEINDSOURCE"))); // if (flag) // { // xElement.Add(new XAttribute("SourceID", this.mSource.UID())); // } // xElement.Add(this.mCalculation.ToXML(args)); // base.AddToXML(xElement, args); // return xElement; //} #endregion Other } }