| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- using MuchInfo.Chart.Data;
- using MuchInfo.Chart.Data.EnumTypes;
- using MuchInfo.Chart.WPF.Helpers;
- using MuchInfo.Chart.WPF.Primitives.Interfaces;
- using System;
- using NPOI.SS.UserModel;
- namespace MuchInfo.Chart.WPF.Primitives.Drawing
- {
- public class SharedDrawingToolSpec : IDrawingToolSpec
- {
- #region Fields
- private DrawingToolInfo _drawingToolInfo;
- private SharedDrawingToolContainer _sharedDrawingToolContainer;
- #endregion Fields
- #region Constructors
- public SharedDrawingToolSpec(SharedDrawingToolContainer aOwner, string symbol, IDrawingTool aTool, TimeSpan timeFrame, Guid scaleGuid, bool isPriceScale)
- {
- this._sharedDrawingToolContainer = aOwner;
- this._drawingToolInfo = new DrawingToolInfo
- {
- DrawType = checked((short)aTool.ToolType()),
- DrawingGUID = Guid.NewGuid(),
- TimeFrame = timeFrame.Ticks,
- Symbol = symbol
- };
- bool flag = !isPriceScale;
- if (flag)
- {
- this._drawingToolInfo.ScaleGUID = scaleGuid;
- }
- aTool.GetDrawingInfo(this._drawingToolInfo);
- this._drawingToolInfo.ChartID = "ORIGSCALEGUID|" + this._sharedDrawingToolContainer.ScaleLayer().ScaleGUID.ToString();
- SharedDrawingManager.AddDrawing(this._drawingToolInfo);
- }
- public SharedDrawingToolSpec(SharedDrawingToolContainer aOwner, DrawingToolInfo info)
- {
- this._sharedDrawingToolContainer = aOwner;
- this._drawingToolInfo = info;
- }
- #endregion Constructors
- #region Methods
- #region Public Static Methods
- public static IDrawingTool CreateToolFromInfo(DrawingToolInfo aInfo, SharedDrawingToolSpec aOwner)
- {
- IDrawingTool result;
- try
- {
- var drawingToolType = (DrawingToolType)(aInfo.DrawType.Value);
- IDrawingTool drawingTool = null;
- switch (drawingToolType)
- {
- //case DrawingToolType.AndrewsFork:
- // drawingTool = new drawingAndrewsPitchfork();
- // break;
- case DrawingToolType.Ellipse:
- drawingTool = new DrawingEllipse();
- break;
- case DrawingToolType.ErrorChannel:
- drawingTool = new DrawingErrorChannel();
- break;
- //case DrawingToolType.FibArc:
- // drawingTool = new drawingFibArc();
- // break;
- case DrawingToolType.FibFan:
- drawingTool = new DrawingFibFan();
- break;
- case DrawingToolType.GannBox:
- drawingTool = new DrawingGannBox();
- break;
- case DrawingToolType.FibRetr:
- drawingTool = new DrawingFibRetracement();
- break;
- case DrawingToolType.FibTime:
- drawingTool = new DrawingFibTimeZones();
- break;
- case DrawingToolType.GannFann:
- drawingTool = new DrawingGannFann();
- break;
- case DrawingToolType.HLine:
- drawingTool = new DrawingHorizontalLine();
- break;
- case DrawingToolType.QuadLines:
- drawingTool = new DrawingQuadrantLines();
- break;
- //case DrawingToolType.RaffReg:
- // drawingTool = new drawingRaffRegression();
- // break;
- case DrawingToolType.Rectangle:
- drawingTool = new DrawingRectangle();
- break;
- //case DrawingToolType.RegrChan:
- // drawingTool = new drawingRegressionChannel();
- // break;
- //case DrawingToolType.RegrLine:
- // drawingTool = new drawingRegressionLine();
- // break;
- case DrawingToolType.SpeedLines:
- drawingTool = new DrawingSpeedLines();
- break;
- case DrawingToolType.Text:
- drawingTool = new DrawingText();
- break;
- case DrawingToolType.Tirone:
- drawingTool = new DrawingTironeLevels();
- break;
- case DrawingToolType.TrendLine:
- drawingTool = new DrawingTrendLine();
- break;
- case DrawingToolType.VLine:
- drawingTool = new DrawingVerticalLine();
- break;
- case DrawingToolType.Arrow:
- drawingTool = new DrawingArrow();
- break;
- }
- bool flag = drawingTool != null;
- if (flag)
- {
- drawingTool.FromInfo(aInfo);
- drawingTool.OwnerSpec = aOwner;
- result = drawingTool;
- return result;
- }
- }
- catch (Exception expr_1B2)
- {
- throw expr_1B2;
- }
- result = null;
- return result;
- }
- #endregion Public Static Methods
- #region Public Methods
- public void DeleteTool()
- {
- SharedDrawingManager.DeleteDrawing(this._drawingToolInfo);
- bool flag = this._sharedDrawingToolContainer != null;
- if (flag)
- {
- this._sharedDrawingToolContainer.SharedDrawingToolContainer_3819(this);
- }
- }
- public DrawingToolInfo GetDrawingInfo()
- {
- return this._drawingToolInfo;
- }
- public IDrawingTool GetTool()
- {
- return SharedDrawingToolSpec.CreateToolFromInfo(this._drawingToolInfo, this);
- }
- public ScaleLayer ScaleLayer()
- {
- return this._sharedDrawingToolContainer.ScaleLayer();
- }
- public void ToolChanged(IDrawingTool aTool)
- {
- aTool.GetDrawingInfo(this._drawingToolInfo);
- SharedDrawingManager.UpdateDrawing(this._drawingToolInfo);
- }
- #endregion Public Methods
- #region Internal Methods
- internal Guid SharedDrawingToolSpec_3830()
- {
- bool flag = this._drawingToolInfo != null;
- Guid drawingGUID = Guid.Empty;
- if (flag)
- {
- drawingGUID = this._drawingToolInfo.DrawingGUID;
- }
- return drawingGUID;
- }
- #endregion Internal Methods
- #endregion Methods
- }
- }
|