| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- 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 DrawingSpeedLines : Drawing2PointBase
- {
- private ExtendableLine drawingSpeedLines_1084;
- private List<Line> drawingSpeedLines_1085;
- public DrawingSpeedLines()
- {
- this.drawingSpeedLines_1085 = new List<Line>();
- }
- public override DrawingToolType ToolType()
- {
- return DrawingToolType.SpeedLines;
- }
- public override IDrawingTool Clone()
- {
- return new DrawingSpeedLines
- {
- mColor = Colors.Cyan
- };
- }
- protected override List<FrameworkElement> GetDrawingPlots(Chart owner, ScaleLayer aScale, Rect aRect)
- {
- List<FrameworkElement> list = new List<FrameworkElement>();
- bool flag = this.drawingSpeedLines_1084 == null;
- if (flag)
- {
- this.drawingSpeedLines_1084 = new ExtendableLine(this, owner);
- this.drawingSpeedLines_1084.Stroke = new SolidColorBrush(this.mColor);
- this.drawingSpeedLines_1084.StrokeThickness = 1.4;
- DoubleCollection doubleCollection = new DoubleCollection();
- doubleCollection.Add(10.0);
- doubleCollection.Add(10.0);
- this.drawingSpeedLines_1084.SetMainStrokeDash(doubleCollection);
- this.drawingSpeedLines_1084.ExtensionStroke = this.drawingSpeedLines_1084.Stroke;
- }
- this.drawingSpeedLines_1085.Clear();
- int num = 0;
- checked
- {
- int arg_111_0;
- int num2;
- do
- {
- Line line = new Line();
- line.Stroke = (new SolidColorBrush(this.mColor));
- line.StrokeThickness = (1.4);
- this.drawingSpeedLines_1085.Add(line);
- list.Add(line);
- num++;
- arg_111_0 = num;
- num2 = 2;
- }
- while (arg_111_0 <= num2);
- this.MoveDrawingToNewLocations(aRect);
- list.Add(this.drawingSpeedLines_1084);
- return list;
- }
- }
- public override string RootName
- {
- get { return "drawSPL"; }
- }
- public override string MenuDescription()
- {
- return LanguageManager.FindResource(LanguageConst.DrawingTool_Abbreviation_SpeedLine);
- }
- public override string Description()
- {
- return MenuDescription();
- }
- public override string Abbreviation()
- {
- return "Speed";
- }
- protected override void ColorChanged()
- {
- bool flag = this.drawingSpeedLines_1084 != null;
- if (flag)
- {
- this.drawingSpeedLines_1084.Stroke = new SolidColorBrush(this.mColor);
- this.drawingSpeedLines_1084.ExtensionStroke = this.drawingSpeedLines_1084.Stroke;
- }
- try
- {
- List<Line>.Enumerator enumerator = this.drawingSpeedLines_1085.GetEnumerator();
- while (enumerator.MoveNext())
- {
- Line current = enumerator.Current;
- current.Stroke = (new SolidColorBrush(this.mColor));
- }
- }
- finally
- {
- //List<Line>.Enumerator enumerator;
- //enumerator.Dispose();
- }
- }
- protected override void MoveDrawingToNewLocations(Rect aRect)
- {
- bool flag = this.drawingSpeedLines_1084 != null;
- if (flag)
- {
- this.drawingSpeedLines_1084.SetPosition(this.mDrawP1, this.mDrawP2, this.mDrawP1.X > this.mDrawP2.X, this.mDrawP1.X < this.mDrawP2.X, aRect);
- }
- Point point;
- Point point2;
- Point pointA = new Point();
- Point pointB = new Point();
- 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 = (point.X != point2.X);
- }
- if (flag)
- {
- float num = (float)(point2.Y - point.Y);
- int num2 = 0;
- int arg_2DD_0;
- int num7;
- do
- {
- float num3 = 1f;
- flag = (num2 == 1);
- if (flag)
- {
- num3 = 0.6666667f;
- }
- flag = (num2 == 2);
- if (flag)
- {
- num3 = 0.333333343f;
- }
- float num4 = (float)((double)(num * num3) + point.Y);
- float num5 = (float)(((double)num4 - point.Y) / (point2.X - point.X));
- flag = (point2.X > point.X);
- float num6;
- if (flag)
- {
- num6 = (float)aRect.Right;
- }
- else
- {
- num6 = (float)aRect.Left;
- }
- Point point4 = new Point(Math.Round(num6), point.Y + Math.Round((num6 - point.X) * num5));
- double slope = GeometryHelper.LineSlope(ref point, ref point4);
- flag = (point4.Y < aRect.Top);
- if (flag)
- {
- point4 = new Point(GeometryHelper.XFromLine(point, slope, aRect.Top), aRect.Top);
- }
- flag = (point4.Y > aRect.Bottom);
- if (flag)
- {
- point4 = new Point(GeometryHelper.XFromLine(point, slope, aRect.Bottom), aRect.Bottom);
- }
- try
- {
- PointOfLineAtRectangleCalculator(ref pointA, ref pointB, point, point4, aRect);
- this.drawingSpeedLines_1085[num2].X1 = double.IsNaN(pointA.X) ? 0 : pointA.X;
- this.drawingSpeedLines_1085[num2].Y1 = double.IsNaN(pointA.Y) ? 0 : pointA.Y;
- this.drawingSpeedLines_1085[num2].X2 = double.IsNaN(pointB.X) ? 0 : pointB.X;
- this.drawingSpeedLines_1085[num2].Y2 = double.IsNaN(pointB.Y) ? 0 : pointB.Y;
- this.drawingSpeedLines_1085[num2].Visibility = (Visibility)(0);
- }
- catch { ; }
- checked
- {
- num2++;
- arg_2DD_0 = num2;
- num7 = 2;
- }
- }
- while (arg_2DD_0 <= num7);
- }
- else
- {
- try
- {
- PointOfLineAtRectangleCalculator(ref pointA, ref pointB, point, point2, aRect);
- this.drawingSpeedLines_1085[0].X1 = pointA.X;
- this.drawingSpeedLines_1085[0].Y1 = pointA.Y;
- this.drawingSpeedLines_1085[0].X2 = pointB.X;
- this.drawingSpeedLines_1085[0].Y2 = pointB.Y;
- this.drawingSpeedLines_1085[1].Visibility = (Visibility)(1);
- this.drawingSpeedLines_1085[2].Visibility = (Visibility)(1);
- }
- catch
- {
- ;
- }
- }
- this.drawingSpeedLines_1085[0].Visibility = (Visibility)(1);
- }
- 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;
- }
- }
- }
|