| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- 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<TextBlock> 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<FrameworkElement> GetDrawingPlots(Chart owner, ScaleLayer aScale, Rect aRect)
- {
- List<FrameworkElement> list = new List<FrameworkElement>();
- 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<TextBlock>();
- SolidColorBrush foreground = new SolidColorBrush(this.mColor);
- try
- {
- List<DrawingFibBase.FibLevel>.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<drawingFibBase.FibLevel>.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<TextBlock>.Enumerator enumerator2 = this.drawingFibRetracement_1050.GetEnumerator();
- while (enumerator2.MoveNext())
- {
- TextBlock current2 = enumerator2.Current;
- list.Add(current2);
- }
- }
- finally
- {
- //List<TextBlock>.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<TextBlock>.Enumerator enumerator = this.drawingFibRetracement_1050.GetEnumerator();
- while (enumerator.MoveNext())
- {
- TextBlock current = enumerator.Current;
- current.Foreground = (foreground);
- }
- }
- finally
- {
- //List<TextBlock>.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<TextBlock>.Enumerator enumerator = this.drawingFibRetracement_1050.GetEnumerator();
- while (enumerator.MoveNext())
- {
- TextBlock current = enumerator.Current;
- current.Visibility = (Visibility)(1);
- }
- }
- finally
- {
- //List<TextBlock>.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<DrawingFibBase.FibLevel>.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<drawingFibBase.FibLevel>.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<object> args)
- {
- base.AddToXml(xml, args);
- bool flag = !this.drawingFibRetracement_1051;
- if (flag)
- {
- xml.Add(new XAttribute("HideVals", "1"));
- }
- }
- public override List<ControlPair> AdditionalEditors()
- {
- List<ControlPair> list = base.AdditionalEditors();
- ControlPair controlPair = new ControlPair();
- BooleanEditor controlRight = new BooleanEditor(this, "ShowValues", "Show Values");
- controlPair.ControlRight = controlRight;
- list.Add(controlPair);
- return list;
- }
- }
- }
|