| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- using Microsoft.VisualBasic.CompilerServices;
- 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.Media;
- using System.Windows.Shapes;
- namespace MuchInfo.Chart.WPF.Primitives.Drawing
- {
- public class DrawingFibFan : DrawingFibBase
- {
- private ExtendableLine drawingFibFan_1043;
- private Path drawingFibFan_1044;
- private PathGeometry drawingFibFan_1045;
- public DrawingFibFan()
- {
- base.TurnOnForArc();
- }
- public override DrawingToolType ToolType()
- {
- return DrawingToolType.FibFan;
- }
- public override IDrawingTool Clone()
- {
- return new DrawingFibFan
- {
- Color = Colors.White
- };
- }
- protected override List<FrameworkElement> GetDrawingPlots(Chart owner, ScaleLayer aScale, Rect aRect)
- {
- List<FrameworkElement> list = new List<FrameworkElement>();
- bool flag = this.drawingFibFan_1043 == null;
- if (flag)
- {
- this.drawingFibFan_1043 = new ExtendableLine(this, owner);
- this.drawingFibFan_1043.Stroke = new SolidColorBrush(this.mColor);
- this.drawingFibFan_1043.ExtensionStroke = new SolidColorBrush(this.mColor);
- this.drawingFibFan_1043.StrokeThickness = 1.4;
- DoubleCollection doubleCollection = new DoubleCollection();
- doubleCollection.Add(10.0);
- doubleCollection.Add(10.0);
- this.drawingFibFan_1043.SetExtensionStrokeDash(doubleCollection);
- }
- this.drawingFibFan_1044 = new Path();
- this.drawingFibFan_1044.Stroke = (new SolidColorBrush(this.mColor));
- this.drawingFibFan_1044.StrokeThickness = (1.4);
- this.drawingFibFan_1045 = new PathGeometry();
- this.drawingFibFan_1044.Data = (this.drawingFibFan_1045);
- this.drawingFibFan_1044.IsHitTestVisible = (false);
- this.MoveDrawingToNewLocations(aRect);
- list.Add(this.drawingFibFan_1044);
- list.Add(this.drawingFibFan_1043);
- return list;
- }
- public override string RootName
- {
- get { return "drawFIBFAN"; }
- }
- public override string MenuDescription()
- {
- return LanguageManager.FindResource(LanguageConst.DrawingTool_Abbreviation_FibonacciFan);
- }
- public override string Abbreviation()
- {
- return "Fib Fan";
- }
- public override string Description()
- {
- return this.MenuDescription();
- }
- protected override void ColorChanged()
- {
- bool flag = this.drawingFibFan_1043 != null;
- if (flag)
- {
- this.drawingFibFan_1043.Stroke = new SolidColorBrush(this.mColor);
- this.drawingFibFan_1043.ExtensionStroke = this.drawingFibFan_1043.Stroke;
- }
- flag = (this.drawingFibFan_1044 != null);
- if (flag)
- {
- this.drawingFibFan_1044.Stroke = (new SolidColorBrush(this.mColor));
- }
- }
- protected override void MoveDrawingToNewLocations(Rect aRect)
- {
- bool flag = this.mLastScale == null || this.mLastScale.GetmScaler() == null;
- if (!flag)
- {
- this.drawingFibFan_1045.Figures.Clear();
- Point point;
- Point point2;
- checked
- {
- point = new Point((double)((int)Math.Round(this.mDrawP1.X)), (double)((int)Math.Round(this.mDrawP1.Y)));
- 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.drawingFibFan_1043 != null);
- if (flag)
- {
- this.drawingFibFan_1043.SetPosition(this.mDrawP1, this.mDrawP2, this.mDrawP1.X > this.mDrawP2.X, this.mDrawP1.X < this.mDrawP2.X, aRect);
- }
- flag = (point.X != point2.X);
- }
- if (flag)
- {
- float num = this.P1Val - this.P2Val;
- try
- {
- point.X = drawingFibFan_1043.lineMain.X1;
- List<DrawingFibBase.FibLevel>.Enumerator enumerator = this.FibLevels.GetEnumerator();
- while (enumerator.MoveNext())
- {
- DrawingFibBase.FibLevel current = enumerator.Current;
- flag = current.IsOn;
- if (flag)
- {
- float num2 = num * current.Value / 100f;
- num2 += this.P2Val;
- num2 = this.mLastScale.GetmScaler().PercentFromValue(num2);
- num2 = this.mLastScale.GetmScaler().YFromPercent(num2, aRect);
- Point point4 = new Point(point2.X, (double)num2);
- Point point5 = point4;
- double slope = GeometryHelper.LineSlope(ref point, ref point5);
- flag = (point2.X > point.X);
- float num3;
- if (flag)
- {
- num3 = (float)aRect.Right;
- }
- else
- {
- num3 = (float)aRect.Left;
- }
- Point p = new Point((double)checked((int)Math.Round((double)num3)), GeometryHelper.YFromLine(point, slope, (double)num3));
- flag = (p.Y < aRect.Top);
- if (flag)
- {
- p = new Point(GeometryHelper.XFromLine(point, slope, aRect.Top), aRect.Top);
- }
- flag = (p.Y > aRect.Bottom);
- if (flag)
- {
- p = new Point(GeometryHelper.XFromLine(point, slope, aRect.Bottom), aRect.Bottom);
- }
- if (p.X < aRect.Left)
- {
- p = new Point(aRect.Left, GeometryHelper.YFromLine(point, slope, aRect.Left));
- }
- if (p.X > aRect.Width)
- {
- p = new Point(aRect.Width, GeometryHelper.YFromLine(point, slope, aRect.Width));
- }
- this.AddLine(this.drawingFibFan_1045, point, p);
- }
- }
- }
- finally
- {
- //List<drawingFibBase.FibLevel>.Enumerator enumerator;
- //enumerator.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("FibFan.png");
- }
- catch (Exception expr_3A)
- {
- ProjectData.SetProjectError(expr_3A);
- result = null;
- ProjectData.ClearProjectError();
- }
- return result;
- }
- protected override bool CanExtendLeft()
- {
- return false;
- }
- protected override bool CanExtendRight()
- {
- return false;
- }
- }
- }
|