using Microsoft.VisualBasic; using Microsoft.VisualBasic.CompilerServices; using System; using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Shapes; using System.Xml.Linq; using MuchInfo.Chart.WPF.Controls.Drawing; using MuchInfo.Chart.Data.EnumTypes; using MuchInfo.Chart.WPF.Primitives.Interfaces; using MuchInfo.Chart.Infrastructure.Helpers; using MuchInfo.Chart.Infrastructure.Utilities; using MuchInfo.Chart.Infrastructure.Controls; using MuchInfo.Chart.WPF.Helpers; namespace MuchInfo.Chart.WPF.Primitives.Drawing { public class DrawingFibRetracement : DrawingFibBase { private ExtendableLine drawingFibRetracement_1046; private Line drawingFibRetracement_1047; private Path drawingFibRetracement_1048; private PathGeometry drawingFibRetracement_1049; private List drawingFibRetracement_1050; private bool drawingFibRetracement_1051; public bool ShowValues { get { return this.drawingFibRetracement_1051; } set { bool flag = this.drawingFibRetracement_1051 != value; if (flag) { this.drawingFibRetracement_1051 = value; this.MoveDrawingToNewLocations(this.mLastRect); this.PropertyChanged(); } } } public DrawingFibRetracement() { this.drawingFibRetracement_1051 = true; base.TurnAllOn(); } public override DrawingToolType ToolType() { return DrawingToolType.FibRetr; } public override IDrawingTool Clone() { return new DrawingFibRetracement { Color = Colors.White }; } protected override List GetDrawingPlots(Chart owner, ScaleLayer aScale, Rect aRect) { List list = new List(); bool flag = this.drawingFibRetracement_1046 == null; if (flag) { this.drawingFibRetracement_1046 = new ExtendableLine(this, owner); this.drawingFibRetracement_1046.Stroke = new SolidColorBrush(this.mColor); this.drawingFibRetracement_1046.StrokeThickness = 1.4; this.drawingFibRetracement_1046.ExtensionStroke = new SolidColorBrush(this.mExtensionColor); } flag = (this.drawingFibRetracement_1050 == null); if (flag) { this.drawingFibRetracement_1050 = new List(); SolidColorBrush foreground = new SolidColorBrush(this.mColor); try { List.Enumerator enumerator = this.FibLevels.GetEnumerator(); while (enumerator.MoveNext()) { DrawingFibBase.FibLevel current = enumerator.Current; TextBlock textBlock = new TextBlock(); textBlock.FontSize = (8.0); textBlock.Visibility = (Visibility)(1); textBlock.Foreground = (foreground); textBlock.IsHitTestVisible = (false); this.drawingFibRetracement_1050.Add(textBlock); } } finally { //List.Enumerator enumerator; //enumerator.Dispose(); } } this.drawingFibRetracement_1047 = new Line(); this.drawingFibRetracement_1047.Stroke = (new SolidColorBrush(this.mColor)); this.drawingFibRetracement_1047.StrokeThickness = (0.5); this.drawingFibRetracement_1047.IsHitTestVisible = (false); this.drawingFibRetracement_1048 = new Path(); this.drawingFibRetracement_1048.Stroke = (new SolidColorBrush(this.mColor)); this.drawingFibRetracement_1048.StrokeThickness = (0.5); this.drawingFibRetracement_1049 = new PathGeometry(); this.drawingFibRetracement_1048.Data = (this.drawingFibRetracement_1049); this.drawingFibRetracement_1048.IsHitTestVisible = (false); DoubleCollection doubleCollection = new DoubleCollection(); doubleCollection.Add(10.0); doubleCollection.Add(10.0); this.drawingFibRetracement_1048.StrokeDashArray = (doubleCollection); this.MoveDrawingToNewLocations(aRect); try { List.Enumerator enumerator2 = this.drawingFibRetracement_1050.GetEnumerator(); while (enumerator2.MoveNext()) { TextBlock current2 = enumerator2.Current; list.Add(current2); } } finally { //List.Enumerator enumerator2; //enumerator2.Dispose(); } list.Add(this.drawingFibRetracement_1046); list.Add(this.drawingFibRetracement_1047); list.Add(this.drawingFibRetracement_1048); return list; } public override string RootName { get { return "FibonacciRetracement"; } } public override string MenuDescription() { return LanguageManager.FindResource(LanguageConst.DrawingTool_Abbreviation_FibonacciRetracement); } public override string Abbreviation() { return "Fib Ret"; } public override string Description() { return this.MenuDescription(); } protected override void ColorChanged() { bool flag = this.drawingFibRetracement_1046 != null; if (flag) { this.drawingFibRetracement_1046.Stroke = new SolidColorBrush(this.mColor); this.drawingFibRetracement_1046.ExtensionStroke = new SolidColorBrush(this.mExtensionColor); } flag = (this.drawingFibRetracement_1050 != null); if (flag) { SolidColorBrush foreground = new SolidColorBrush(this.mColor); try { List.Enumerator enumerator = this.drawingFibRetracement_1050.GetEnumerator(); while (enumerator.MoveNext()) { TextBlock current = enumerator.Current; current.Foreground = (foreground); } } finally { //List.Enumerator enumerator; //enumerator.Dispose(); } } flag = (this.drawingFibRetracement_1047 != null); if (flag) { this.drawingFibRetracement_1047.Stroke = (new SolidColorBrush(this.mColor)); } flag = (this.drawingFibRetracement_1048 != null); if (flag) { this.drawingFibRetracement_1048.Stroke = (new SolidColorBrush(this.mColor)); } } protected override void MoveDrawingToNewLocations(Rect aRect) { try { List.Enumerator enumerator = this.drawingFibRetracement_1050.GetEnumerator(); while (enumerator.MoveNext()) { TextBlock current = enumerator.Current; current.Visibility = (Visibility)(1); } } finally { //List.Enumerator enumerator; //enumerator.Dispose(); } int num = 0; bool flag = this.mLastScale == null || this.mLastScale.GetmScaler() == null; if (!flag) { this.drawingFibRetracement_1049.Figures.Clear(); checked { Point point = new Point((double)((int)Math.Round(this.mDrawP1.X)), (double)((int)Math.Round(this.mDrawP1.Y))); Point point2 = new Point((double)((int)Math.Round(this.mDrawP2.X)), (double)((int)Math.Round(this.mDrawP2.Y))); Point 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)))); Size size = new Size(12.0, 12.0); flag = (this.drawingFibRetracement_1046 != null); if (flag) { this.drawingFibRetracement_1046.SetPosition(this.mDrawP1, this.mDrawP2, this.ExtendLeft, this.ExtendRight, aRect); } flag = (this.drawingFibRetracement_1047 != null); if (flag) { this.drawingFibRetracement_1047.X1 = (aRect.Left); this.drawingFibRetracement_1047.X2 = (aRect.Right); this.drawingFibRetracement_1047.Y1 = (this.mDrawP2.Y); this.drawingFibRetracement_1047.Y2 = (this.mDrawP2.Y); } } float num2 = this.P1Val - this.P2Val; try { List.Enumerator enumerator2 = this.FibLevels.GetEnumerator(); while (enumerator2.MoveNext()) { DrawingFibBase.FibLevel current2 = enumerator2.Current; flag = current2.IsOn; if (flag) { float num3 = num2 * current2.Value / 100f; num3 += this.P2Val; num3 = this.mLastScale.GetmScaler().PercentFromValue(num3); num3 = this.mLastScale.GetmScaler().YFromPercent(num3, aRect); flag = ((double)num3 >= aRect.Top && (double)num3 <= aRect.Bottom); checked { if (flag) { Point p = new Point(aRect.Left, (double)num3); Point p2 = new Point(aRect.Right, (double)num3); this.AddLine(this.drawingFibRetracement_1049, p, p2); flag = this.drawingFibRetracement_1051; if (flag) { TextBlock textBlock = this.drawingFibRetracement_1050[num]; num++; textBlock.Text = (Strings.Format(current2.Value, "0.0")); textBlock.SetValue(Canvas.LeftProperty, 4.0); textBlock.SetValue(Canvas.TopProperty, (double)num3); textBlock.Visibility = (Visibility)(0); } } } } } } finally { //List.Enumerator enumerator2; //enumerator2.Dispose(); } } } protected void AddLine(PathGeometry geom, Point p1, Point p2) { PathFigure pathFigure = new PathFigure(); geom.Figures.Add(pathFigure); LineSegment lineSegment = new LineSegment(); pathFigure.Segments.Add(lineSegment); pathFigure.StartPoint = (p1); lineSegment.Point = (p2); } public override ImageSource Icon() { ImageSource result; try { result = ImageHelper.GetImage("FibRet.png"); } catch (Exception expr_3A) { ProjectData.SetProjectError(expr_3A); result = null; ProjectData.ClearProjectError(); } return result; } protected override bool CanExtendLeft() { return true; } protected override bool CanExtendRight() { return true; } protected override void AddFromXml(XElement xml) { base.AddFromXml(xml); bool flag = xml.Attribute("HideVals") != null; if (flag) { this.drawingFibRetracement_1051 = false; } } protected override void AddToXml(XElement xml, List args) { base.AddToXml(xml, args); bool flag = !this.drawingFibRetracement_1051; if (flag) { xml.Add(new XAttribute("HideVals", "1")); } } public override List AdditionalEditors() { List list = base.AdditionalEditors(); ControlPair controlPair = new ControlPair(); BooleanEditor controlRight = new BooleanEditor(this, "ShowValues", "Show Values"); controlPair.ControlRight = controlRight; list.Add(controlPair); return list; } } }