| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640 |
- using Microsoft.VisualBasic.CompilerServices;
- using MuchInfo.Chart.Data.Interfaces;
- using MuchInfo.Chart.Data.Models;
- using MuchInfo.Chart.Infrastructure.Utilities;
- using MuchInfo.Chart.WPF.Controls.Indicator;
- using MuchInfo.Chart.WPF.Helpers;
- using MuchInfo.Chart.WPF.Primitives.Interfaces;
- using System;
- using System.Collections.Generic;
- using System.Runtime.CompilerServices;
- using System.Windows;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Xml.Linq;
- namespace MuchInfo.Chart.WPF.Primitives
- {
- public abstract class PlotBase : IToolTipControlProvider
- {
- #region Fields
- protected Chart mChart;
- protected string mPendingSourceUID;
- protected ScaleLayer mScale;
- private IndicatorModel _indicatorModel;
- /// <summary>
- /// 指标编辑器转换后绘图数据
- /// </summary>
- public IndicatorModel Indicator
- {
- get { return _indicatorModel; }
- set { _indicatorModel = value; }
- }
- /// <summary>
- /// mSource
- /// </summary>
- // private ILineDataSet _outPutSource;
- private double _plotOpacity;
- private string _savedAsName;
- #endregion Fields
- #region Constructors
- protected PlotBase()
- {
- this.mPendingSourceUID = "";
- this._plotOpacity = 1.0;
- }
- protected PlotBase(IndicatorModel indicatorModel, Chart parentchart)
- : this()
- {
- this.mChart = parentchart;
- // _outPutSource = new ChartDataSet(indicatorModel.CalculateDataPoints);
- this._indicatorModel = indicatorModel;
- }
- #endregion Constructors
- #region Properties
- #region Public Properties
- public double PlotOpacity
- {
- get
- {
- return this._plotOpacity;
- }
- set
- {
- bool flag = value != this._plotOpacity;
- if (flag)
- {
- this._plotOpacity = value;
- flag = (this.mChart != null);
- if (flag)
- {
- this.mChart.Refresh();
- }
- }
- }
- }
- public string SavedAsName
- {
- get
- {
- return this._savedAsName;
- }
- set
- {
- this._savedAsName = value;
- }
- }
- public ScaleLayer ScaleLayer
- {
- get
- {
- return this.mScale;
- }
- set
- {
- this.mScale = value;
- }
- }
- #endregion Public Properties
- #region Protected Properties
- ///// <summary>
- ///// 数据源
- ///// </summary>
- //protected virtual ILineDataSet mSource
- //{
- // get
- // {
- // return this._outPutSource;
- // }
- // set
- // {
- // var dataChangedEventHandler = new LineDataSetDataChangedEventHandler(this.OnDataChanged);
- // bool flag = this._outPutSource != null;
- // if (flag)
- // {
- // this._outPutSource.DataChanged -= (dataChangedEventHandler);
- // }
- // this._outPutSource = value;
- // flag = (this._outPutSource != null);
- // if (flag)
- // {
- // this._outPutSource.DataChanged += (dataChangedEventHandler);
- // }
- // }
- //}
- //public ILineDataSet OutputSource
- //{
- // get { return _outPutSource; }
- // // set { _outPutSource = value; }
- //}
- public IndicatorModel OutputSource
- {
- get { return Indicator; }
- // set { _outPutSource = value; }
- }
- #endregion Protected Properties
- #endregion Properties
- #region Methods
- #region Public Methods
-
- public TimeSpan CurrentTimeFrame()
- {
- bool flag = this.mChart != null;
- TimeSpan currentTimeFrame = TimeSpan.Zero;
- if (flag)
- {
- currentTimeFrame = this.mChart.CurrentTimeFrame;
- }
- return currentTimeFrame;
- }
-
- public Chart GetChart()
- {
- return this.mChart;
- }
- public object GetControl()
- {
- return new IndicatorHierarchyDisplay(this);
- }
- public List<FrameworkElement> GetElements(Chart owner, ScaleLayer aScale, IDateScaler dateScale, IValueScaler valScale, Rect aRect)
- {
- //bool flag = this.PlotBase_1655.Count == 0;
- List<FrameworkElement> list;
- list = this.BuildPlot(owner, aScale, dateScale, valScale, aRect);
- //if (flag)
- //{
- // list = this.PlotBase_5028(owner, aScale, dateScale, ValScale, aRect);
- //}
- //else
- //{
- // list = new List<FrameworkElement>();
- // try
- // {
- // List<IPlotAddition>.Enumerator enumerator = this.PlotBase_1655.GetEnumerator();
- // while (enumerator.MoveNext())
- // {
- // IPlotAddition current = enumerator.Current;
- // list.AddRange(current.GetPlots(owner, this, aScale, dateScale, ValScale, aRect));
- // }
- // }
- // finally
- // {
- // //List<IPlotAddition>.Enumerator enumerator;
- // //enumerator.Dispose();
- // }
- // list.AddRange(this.PlotBase_5028(owner, aScale, dateScale, ValScale, aRect));
- //}
- if (list != null)
- {
- foreach (var current in list)
- {
- current.Opacity = this._plotOpacity;
- }
- }
- return list;
- }
- public abstract void InitAsNew();
- public abstract void ReInstanceSources();
- public void RemovedFromChart()
- {
- this.DeleteData();
- this.mChart = null;
- this.mScale = null;
- // this.mLegendBtn = null;
- }
- //public void RemovePlotAddition(IPlotAddition aAdd)
- //{
- // this.PlotBase_1655.Remove(aAdd);
- // bool flag = this.mChart != null;
- // if (flag)
- // {
- // this.mChart.Invalidate();
- // }
- //}
- //public void ScanConditionCreated(baseCondition mCondition, Color aColor)
- //{
- // IMQLScanHost currentIndicatorScanHost = MQLMain.CurrentIndicatorScanHost;
- // bool flag = currentIndicatorScanHost != null;
- // if (flag)
- // {
- // currentIndicatorScanHost.NewIndicatorScanCreated(mCondition, aColor);
- // }
- //}
- //public List<IScannablePlot> SiblingPlots()
- //{
- // List<IScannablePlot> list = new List<IScannablePlot>();
- // bool flag = this.mScale != null;
- // if (flag)
- // {
- // try
- // {
- // List<PlotBase>.Enumerator enumerator = this.mScale.AllPlots().GetEnumerator();
- // while (enumerator.MoveNext())
- // {
- // PlotBase current = enumerator.Current;
- // bool flag2 = current != this;
- // if (flag2)
- // {
- // list.Add(current);
- // }
- // }
- // }
- // finally
- // {
- // //List<PlotBase>.Enumerator enumerator;
- // //enumerator.Dispose();
- // }
- // }
- // return list;
- //}
- public abstract void SourceDataChange(object change);
- #endregion Public Methods
- #region Internal Methods
- /// <summary>
- /// 创建图表
- /// </summary>
- internal abstract List<FrameworkElement> BuildPlot(Chart owner, ScaleLayer aScale, IDateScaler dateScale, IValueScaler valScale, Rect aRect);
- /// <summary>
- ///
- /// </summary>
- internal abstract void Calculate();
- internal void Delete()
- {
- this.DeleteData();
- var webChart = this.mChart;
- bool flag = this.mScale != null;
- if (flag)
- {
- this.mScale.RemoveFromChartPane(this);
- }
- flag = (webChart != null);
- if (flag)
- {
- webChart.Refresh();
- }
- //this.ClearPlotAdditions();
- }
- /// <summary>
- /// ָ 显示在顶部的标题,弹出框的标题
- /// </summary>
- /// <returns></returns>
- internal string Description()
- {
- string result = "";
- return result;
- }
- internal abstract Color GetColor();
- /// <summary>
- /// 添加显示到面板中指标数据
- /// </summary>
- /// <param name="aDate">日期</param>
- /// <param name="isDarkBackground"></param>
- /// <param name="isForex"></param>
- /// <returns></returns>
- internal abstract List<ControlPair> GetControlPairs(DateTime aDate, bool isDarkBackground, bool isForex);
- /// <summary>
- /// Gets the control pairs.
- /// </summary>
- /// <param name="aDate">A date.</param>
- /// <param name="isDarkBackground">if set to <c>true</c> [is dark background].</param>
- /// <param name="digites">The digites.</param>
- /// <returns>List{ControlPair}.</returns>
- internal abstract List<ControlPair> GetControlPairs(DateTime aDate, bool isDarkBackground, int digites);
- internal abstract Color GetPlotColor();
- internal void SetDataSource(List<ILineDataSet> sources)
- {
- bool flag = Operators.CompareString(this.mPendingSourceUID, "", false) == 0;
- if (!flag)
- {
- try
- {
- List<ILineDataSet>.Enumerator enumerator = sources.GetEnumerator();
- while (enumerator.MoveNext())
- {
- ILineDataSet current = enumerator.Current;
- flag = true;// (Operators.CompareString(current.UID(), this.mPendingSourceUID, false) == 0);
- if (flag)
- {
- // this.mSource = current;
- break;
- }
- }
- }
- finally
- {
- //List<ILineDataSetWithUID>.Enumerator enumerator;
- //enumerator.Dispose();
- }
- }
- }
- internal abstract void ShowPlotEdit(FrameworkElement relativeTo);
- /// <summary>
- /// 添加指标
- /// </summary>
- //internal abstract void AddIndicators();
- #endregion Internal Methods
- #region Protected Methods
- protected void AddToXML(XElement xml, List<object> args)
- {
- //bool flag = this.PlotBase_1655.Count > 0;
- //if (flag)
- //{
- // XElement xElement = new XElement("PLOTADDITIONS");
- // try
- // {
- // List<IPlotAddition>.Enumerator enumerator = this.PlotBase_1655.GetEnumerator();
- // while (enumerator.MoveNext())
- // {
- // IPlotAddition current = enumerator.Current;
- // xElement.Add(current.ToXML(args));
- // }
- // }
- // finally
- // {
- // //List<IPlotAddition>.Enumerator enumerator;
- // //enumerator.Dispose();
- // }
- // xml.Add(xElement);
- //}
- var flag = (Operators.CompareString(this._savedAsName, "", false) != 0);
- if (flag)
- {
- xml.Add(new XAttribute("SavedName", this._savedAsName));
- }
- xml.Add(new XAttribute("Opacity", this._plotOpacity.ToString()));
- }
- protected abstract void DeleteData();
- #endregion Protected Methods
- #region Private Methods
- private void AddRemoveIndicators(MouseButtonEventArgs e)
- {
- //bool flag = this.mChart != null && this.mChart.AllowAddRemoveIndicators;
- //if (flag)
- //{
- // PopUpMenu popUpMenu = new PopUpMenu();
- // popUpMenu.AddItem("Edit", ImageMan.GetImage("PropertiesHS.png"), new EventHandler(this.PlotBase_5065));
- // flag = (this is LinePlot && !(this.Calculation() is calcPivotPoints) && !(this.Calculation() is calcIchimoku));
- // if (flag)
- // {
- // popUpMenu.AddItem("Add Indicator", ImageMan.GetImage("add2.png"), new EventHandler(this.PlotBase_5071));
- // }
- // flag = (this == this.mChart.GetPricePlot());
- // if (flag)
- // {
- // popUpMenu.AddItem("Comparisons", ImageMan.GetImage("line-chart.png"), new EventHandler(this.PlotBase_5070));
- // }
- // flag = (this.Calculation().DefaultAddMode == eIndicatorAddMode.eRegular);
- // if (flag)
- // {
- // popUpMenu.AddItem("Edit Plot Guides", ImageMan.GetImage("Ruler.png"), new EventHandler(this.PlotBase_5066));
- // }
- // popUpMenu.AddSeperator();
- // flag = (FSCServices.ServiceLevelAllowed(FSCServices.enumAlmostFSCServiceLevels.eMassiveScansAndSorts) && this is LinePlot && this.mCalculation != null && MQLSocketMan.IndicatorKeyAllowed(this.mCalculation.RootName()));
- // if (flag)
- // {
- // popUpMenu.AddItem("Scan", ImageMan.GetImage("flash.png"), new EventHandler(this.PlotBase_5078));
- // popUpMenu.AddItem("Add Column", ImageMan.GetImage("AddColumn.png"), new EventHandler(this.PlotBase_5079));
- // popUpMenu.AddSeperator();
- // }
- // flag = (this.ScaleLayer != null && this.ScaleLayer.ScaleLayer_5525() != null && this.ScaleLayer.ScaleLayer_5525() is ValueScalerArithmetic);
- // bool flag2;
- // if (flag)
- // {
- // ValueScalerArithmetic valueScalerArithmetic = (ValueScalerArithmetic)this.ScaleLayer.ScaleLayer_5525();
- // flag = (this.DataSource() is _125 && this.Calculation() is calcPriceHistory);
- // if (flag)
- // {
- // flag2 = (valueScalerArithmetic.ScaleMode == ValueScalerArithmetic.enumScaleMethod.eArithmetic);
- // if (flag2)
- // {
- // popUpMenu.AddItem("Arithmetic", ImageMan.GetImage("MenuCheck.png"), null);
- // popUpMenu.AddItem("Log", null, new EventHandler(this.PlotBase_5069));
- // }
- // else
- // {
- // popUpMenu.AddItem("Arithmetic", null, new EventHandler(this.PlotBase_5068));
- // popUpMenu.AddItem("Log", ImageMan.GetImage("MenuCheck.png"), null);
- // }
- // popUpMenu.AddItem("More Scaling...", null, new EventHandler(this.PlotBase_5067));
- // }
- // else
- // {
- // popUpMenu.AddItem("Scaling...", null, new EventHandler(this.PlotBase_5067));
- // }
- // }
- // flag2 = (this != this.mChart.GetPricePlot());
- // if (flag2)
- // {
- // popUpMenu.AddSeperator();
- // popUpMenu.AddItem("Save", ImageMan.GetImage("Save24.png"), new EventHandler(this.PlotBase_5072));
- // popUpMenu.AddSeperator();
- // popUpMenu.AddItem("Remove", ImageMan.GetImage("DeleteHS.png"), new EventHandler(this.PlotBase_5073));
- // }
- // PopUpMenu arg_3BB_0 = popUpMenu;
- // Point offset = new Point(-3.0, -5.0);
- // arg_3BB_0.Show(e, offset);
- //}
- }
- private void OnDataChanged(object change)
- {
- bool flag = change is PlotDeletingDataChange;
- if (flag)
- {
- this.Delete();
- }
- else
- {
- this.SourceDataChange(RuntimeHelpers.GetObjectValue(change));
- }
- }
- //private void PlotBase_5066(object sender, EventArgs e)
- //{
- // PlotGuideLineEditor plotGuideLineEditor = new PlotGuideLineEditor();
- // plotGuideLineEditor.Show(this);
- //}
- //private void PlotBase_5067(object sender, EventArgs e)
- //{
- // bool flag = e is MouseEventArgs;
- // if (flag)
- // {
- // ValueScaleEditor valueScaleEditor = new ValueScaleEditor(this.ScaleLayer);
- // valueScaleEditor.Show((MouseEventArgs)e);
- // }
- //}
- //private void PlotBase_5068(object sender, EventArgs e)
- //{
- // bool flag = this.ScaleLayer != null && this.ScaleLayer.ScaleLayer_5525() is ValueScalerArithmetic;
- // if (flag)
- // {
- // ((ValueScalerArithmetic)this.ScaleLayer.ScaleLayer_5525()).ScaleMode = ValueScalerArithmetic.enumScaleMethod.eArithmetic;
- // }
- //}
- //private void PlotBase_5069(object sender, EventArgs e)
- //{
- // bool flag = this.ScaleLayer != null && this.ScaleLayer.ScaleLayer_5525() is ValueScalerArithmetic;
- // if (flag)
- // {
- // ((ValueScalerArithmetic)this.ScaleLayer.ScaleLayer_5525()).ScaleMode = ValueScalerArithmetic.enumScaleMethod.eLog;
- // }
- //}
- //private void PlotBase_5070(object sender, EventArgs e)
- //{
- // bool flag = e is MouseEventArgs;
- // if (flag)
- // {
- // WebChartEditor webChartEditor = new WebChartEditor(this.mChart, WebChartEditor.DialogStyle.eCompare);
- // webChartEditor.DoWhiteBackground();
- // webChartEditor.Show((MouseEventArgs)e);
- // }
- //}
- //private void PlotBase_5071(object sender, EventArgs e)
- //{
- // bool flag = e is MouseEventArgs;
- // if (flag)
- // {
- // AddIndicatorDialog addIndicatorDialog = new AddIndicatorDialog();
- // addIndicatorDialog.Show(this.mChart, this, (MouseEventArgs)e);
- // }
- //}
- //private void PlotBase_5072(object sender, EventArgs e)
- //{
- // SaveIndicatorDialog saveIndicatorDialog = new SaveIndicatorDialog();
- // saveIndicatorDialog.ShowDialog((MouseEventArgs)e, this);
- //}
- private void OnDelete(object sender, EventArgs e)
- {
- this.Delete();
- }
- private void RefreshChart()
- {
- this.Calculate();
- bool flag = this.mChart != null;
- if (flag)
- {
- this.mChart.Refresh();
- }
- }
- private void ShowPlotEdit(object sender, EventArgs e)
- {
- // this.ShowPlotEdit(this.mLegendBtn);
- }
- #endregion Private Methods
- #endregion Methods
- #region Nested Types
- private class PlotBase_260
- {
- #region Fields
- public List<IBarDataPoint> PlotBase_260_1661;
- public List<IBarDataPoint> PlotBase_260_1662;
- #endregion Fields
- #region Constructors
- public PlotBase_260()
- {
- this.PlotBase_260_1661 = new List<IBarDataPoint>();
- this.PlotBase_260_1662 = new List<IBarDataPoint>();
- }
- #endregion Constructors
- #region Other
- //public void PlotBase_260_5092()
- //{
- // dlgTestMQL dlgTestMQL = new dlgTestMQL();
- // dlgTestMQL.Show(this.PlotBase_260_1663, this.PlotBase_260_1664, this.PlotBase_260_1661, this.PlotBase_260_1662);
- //}
- #endregion Other
- }
- #endregion Nested Types
- #region Other
- //public abstract XElement ToXML(List<object> args);
- #endregion Other
- }
- }
|