using MuchInfo.Chart.Data.EnumTypes; using MuchInfo.Chart.Infrastructure.Helpers; using MuchInfo.Chart.WPF.Controls.Drawing; using MuchInfo.Chart.WPF.Helpers; using MuchInfo.Chart.WPF.Primitives.Interfaces; using System; using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Shapes; namespace MuchInfo.Chart.WPF.Primitives.Drawing { public class DrawingFibTimeZones : Drawing2PointBase { #region Fields private Canvas _canvas; private ExtendableLine _extendableLine; #endregion Fields #region Constructors public DrawingFibTimeZones() { } #endregion Constructors #region Properties #region Public Properties public override string RootName { get { return "DrawFibTimeZone"; } } #endregion Public Properties #endregion Properties #region Methods #region Public Methods public override string Abbreviation() { return LanguageManager.FindResource(LanguageConst.DrawingTool_Abbreviation_FibTimeZones); } public override IDrawingTool Clone() { return new DrawingFibTimeZones { mColor = Colors.White }; } public override string Description() { return this.MenuDescription(); } public override ImageSource Icon() { return ImageHelper.GetImage("FibTime.png"); } public override string MenuDescription() { return LanguageManager.FindResource(LanguageConst.DrawingTool_Edit_Description_FibTimeZones); } public override DrawingToolType ToolType() { return DrawingToolType.FibTime; } #endregion Public Methods #region Protected Methods protected override bool CanExtendLeft() { return true; } protected override bool CanExtendRight() { return true; } protected override void ColorChanged() { bool flag = this._extendableLine != null; if (flag) { this._extendableLine.Stroke = new SolidColorBrush(this.mColor); this._extendableLine.ExtensionStroke = new SolidColorBrush(this.mExtensionColor); } } protected override List GetDrawingPlots(Chart owner, ScaleLayer aScale, Rect aRect) { var list = new List(); this._canvas = new Canvas(); bool flag = this._extendableLine == null; if (flag) { this._extendableLine = new ExtendableLine(this, owner) { Stroke = new SolidColorBrush(this.mColor), ExtensionStroke = new SolidColorBrush(this.mExtensionColor), StrokeThickness = 1.4 }; } this.MoveDrawingToNewLocations(aRect); list.Add(this._canvas); list.Add(this._extendableLine); return list; } protected override void MoveDrawingToNewLocations(Rect aRect) { this._canvas.Children.Clear(); if (this._extendableLine != null) { this._extendableLine.SetPosition(this.mDrawP1, this.mDrawP2, this.ExtendLeft, this.ExtendRight, aRect); } checked { var point = new Point((double)((int)Math.Round(this.mDrawP1.X)), (double)((int)Math.Round(this.mDrawP1.Y))); var point2 = new Point((double)((int)Math.Round(this.mDrawP2.X)), (double)((int)Math.Round(this.mDrawP2.Y))); var point3 = new Point((double)((int)Math.Round(unchecked(this.mDrawP2.X / 2.0 + this.mDrawP1.X / 2.0))), (double)((int)Math.Round(unchecked(this.mDrawP2.Y / 2.0 + this.mDrawP1.Y / 2.0)))); this._canvas.Children.Add(this.CreateLine(point.X, aRect.Top, point.X, aRect.Bottom)); this._canvas.Children.Add(this.CreateTextBlock("0", point.X, aRect.Top)); this._canvas.Children.Add(this.CreateLine(point2.X, aRect.Top, point2.X, aRect.Bottom)); this._canvas.Children.Add(this.CreateTextBlock("1", point2.X, aRect.Top)); var num = (int)Math.Round(unchecked(point2.X - point.X)); var num2 = 1; var num3 = 2; var num4 = 0; var num5 = 0f; while (num > 0 && num4 < 1000 && num5 <= 1f) { var num6 = (int)Math.Round(unchecked(point.X + (double)checked(num3 * num))); var flag = ((double)num6 >= aRect.Right); if (flag) { break; } this._canvas.Children.Add(this.CreateLine((double)num6, aRect.Top, (double)num6, aRect.Bottom)); this._canvas.Children.Add(this.CreateTextBlock(num3.ToString(), (double)num6, aRect.Top)); int num7 = num3; num3 += num2; num2 = num7; } } } #endregion Protected Methods #region Private Methods private Line CreateLine(double x1, double y1, double x2, double y2) { return this.CreateLine(new Point(x1, y1), new Point(x2, y2)); } private Line CreateLine(Point p1, Point p2) { var line = new Line { X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y, Stroke = new SolidColorBrush(this.mColor), StrokeThickness = 1.0, StrokeDashArray = new DoubleCollection { 6.0, 4.0 }, IsHitTestVisible = false }; return line; } private TextBlock CreateTextBlock(string txt, double aX, double aY) { var textBlock = new TextBlock { Text = txt, Foreground = new SolidColorBrush(this.mColor), Margin = new Thickness(2.0, 2.0, 0.0, 0.0), IsHitTestVisible = false }; textBlock.SetValue(Canvas.LeftProperty, aX); textBlock.SetValue(Canvas.TopProperty, aY); return textBlock; } #endregion Private Methods #endregion Methods } }