DrawingSpeedLines.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. using Microsoft.VisualBasic.CompilerServices;
  2. using MuchInfo.Chart.Data.EnumTypes;
  3. using MuchInfo.Chart.Infrastructure.Helpers;
  4. using MuchInfo.Chart.WPF.Controls.Drawing;
  5. using MuchInfo.Chart.WPF.Helpers;
  6. using MuchInfo.Chart.WPF.Primitives.Interfaces;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Windows;
  10. using System.Windows.Media;
  11. using System.Windows.Shapes;
  12. namespace MuchInfo.Chart.WPF.Primitives.Drawing
  13. {
  14. public class DrawingSpeedLines : Drawing2PointBase
  15. {
  16. private ExtendableLine drawingSpeedLines_1084;
  17. private List<Line> drawingSpeedLines_1085;
  18. public DrawingSpeedLines()
  19. {
  20. this.drawingSpeedLines_1085 = new List<Line>();
  21. }
  22. public override DrawingToolType ToolType()
  23. {
  24. return DrawingToolType.SpeedLines;
  25. }
  26. public override IDrawingTool Clone()
  27. {
  28. return new DrawingSpeedLines
  29. {
  30. mColor = Colors.Cyan
  31. };
  32. }
  33. protected override List<FrameworkElement> GetDrawingPlots(Chart owner, ScaleLayer aScale, Rect aRect)
  34. {
  35. List<FrameworkElement> list = new List<FrameworkElement>();
  36. bool flag = this.drawingSpeedLines_1084 == null;
  37. if (flag)
  38. {
  39. this.drawingSpeedLines_1084 = new ExtendableLine(this, owner);
  40. this.drawingSpeedLines_1084.Stroke = new SolidColorBrush(this.mColor);
  41. this.drawingSpeedLines_1084.StrokeThickness = 1.4;
  42. DoubleCollection doubleCollection = new DoubleCollection();
  43. doubleCollection.Add(10.0);
  44. doubleCollection.Add(10.0);
  45. this.drawingSpeedLines_1084.SetMainStrokeDash(doubleCollection);
  46. this.drawingSpeedLines_1084.ExtensionStroke = this.drawingSpeedLines_1084.Stroke;
  47. }
  48. this.drawingSpeedLines_1085.Clear();
  49. int num = 0;
  50. checked
  51. {
  52. int arg_111_0;
  53. int num2;
  54. do
  55. {
  56. Line line = new Line();
  57. line.Stroke = (new SolidColorBrush(this.mColor));
  58. line.StrokeThickness = (1.4);
  59. this.drawingSpeedLines_1085.Add(line);
  60. list.Add(line);
  61. num++;
  62. arg_111_0 = num;
  63. num2 = 2;
  64. }
  65. while (arg_111_0 <= num2);
  66. this.MoveDrawingToNewLocations(aRect);
  67. list.Add(this.drawingSpeedLines_1084);
  68. return list;
  69. }
  70. }
  71. public override string RootName
  72. {
  73. get { return "drawSPL"; }
  74. }
  75. public override string MenuDescription()
  76. {
  77. return LanguageManager.FindResource(LanguageConst.DrawingTool_Abbreviation_SpeedLine);
  78. }
  79. public override string Description()
  80. {
  81. return MenuDescription();
  82. }
  83. public override string Abbreviation()
  84. {
  85. return "Speed";
  86. }
  87. protected override void ColorChanged()
  88. {
  89. bool flag = this.drawingSpeedLines_1084 != null;
  90. if (flag)
  91. {
  92. this.drawingSpeedLines_1084.Stroke = new SolidColorBrush(this.mColor);
  93. this.drawingSpeedLines_1084.ExtensionStroke = this.drawingSpeedLines_1084.Stroke;
  94. }
  95. try
  96. {
  97. List<Line>.Enumerator enumerator = this.drawingSpeedLines_1085.GetEnumerator();
  98. while (enumerator.MoveNext())
  99. {
  100. Line current = enumerator.Current;
  101. current.Stroke = (new SolidColorBrush(this.mColor));
  102. }
  103. }
  104. finally
  105. {
  106. //List<Line>.Enumerator enumerator;
  107. //enumerator.Dispose();
  108. }
  109. }
  110. protected override void MoveDrawingToNewLocations(Rect aRect)
  111. {
  112. bool flag = this.drawingSpeedLines_1084 != null;
  113. if (flag)
  114. {
  115. this.drawingSpeedLines_1084.SetPosition(this.mDrawP1, this.mDrawP2, this.mDrawP1.X > this.mDrawP2.X, this.mDrawP1.X < this.mDrawP2.X, aRect);
  116. }
  117. Point point;
  118. Point point2;
  119. Point pointA = new Point();
  120. Point pointB = new Point();
  121. checked
  122. {
  123. point = new Point((double)((int)Math.Round(this.mDrawP1.X)), (double)((int)Math.Round(this.mDrawP1.Y)));
  124. point2 = new Point((double)((int)Math.Round(this.mDrawP2.X)), (double)((int)Math.Round(this.mDrawP2.Y)));
  125. 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))));
  126. Size size = new Size(12.0, 12.0);
  127. flag = (point.X != point2.X);
  128. }
  129. if (flag)
  130. {
  131. float num = (float)(point2.Y - point.Y);
  132. int num2 = 0;
  133. int arg_2DD_0;
  134. int num7;
  135. do
  136. {
  137. float num3 = 1f;
  138. flag = (num2 == 1);
  139. if (flag)
  140. {
  141. num3 = 0.6666667f;
  142. }
  143. flag = (num2 == 2);
  144. if (flag)
  145. {
  146. num3 = 0.333333343f;
  147. }
  148. float num4 = (float)((double)(num * num3) + point.Y);
  149. float num5 = (float)(((double)num4 - point.Y) / (point2.X - point.X));
  150. flag = (point2.X > point.X);
  151. float num6;
  152. if (flag)
  153. {
  154. num6 = (float)aRect.Right;
  155. }
  156. else
  157. {
  158. num6 = (float)aRect.Left;
  159. }
  160. Point point4 = new Point(Math.Round(num6), point.Y + Math.Round((num6 - point.X) * num5));
  161. double slope = GeometryHelper.LineSlope(ref point, ref point4);
  162. flag = (point4.Y < aRect.Top);
  163. if (flag)
  164. {
  165. point4 = new Point(GeometryHelper.XFromLine(point, slope, aRect.Top), aRect.Top);
  166. }
  167. flag = (point4.Y > aRect.Bottom);
  168. if (flag)
  169. {
  170. point4 = new Point(GeometryHelper.XFromLine(point, slope, aRect.Bottom), aRect.Bottom);
  171. }
  172. try
  173. {
  174. PointOfLineAtRectangleCalculator(ref pointA, ref pointB, point, point4, aRect);
  175. this.drawingSpeedLines_1085[num2].X1 = double.IsNaN(pointA.X) ? 0 : pointA.X;
  176. this.drawingSpeedLines_1085[num2].Y1 = double.IsNaN(pointA.Y) ? 0 : pointA.Y;
  177. this.drawingSpeedLines_1085[num2].X2 = double.IsNaN(pointB.X) ? 0 : pointB.X;
  178. this.drawingSpeedLines_1085[num2].Y2 = double.IsNaN(pointB.Y) ? 0 : pointB.Y;
  179. this.drawingSpeedLines_1085[num2].Visibility = (Visibility)(0);
  180. }
  181. catch { ; }
  182. checked
  183. {
  184. num2++;
  185. arg_2DD_0 = num2;
  186. num7 = 2;
  187. }
  188. }
  189. while (arg_2DD_0 <= num7);
  190. }
  191. else
  192. {
  193. try
  194. {
  195. PointOfLineAtRectangleCalculator(ref pointA, ref pointB, point, point2, aRect);
  196. this.drawingSpeedLines_1085[0].X1 = pointA.X;
  197. this.drawingSpeedLines_1085[0].Y1 = pointA.Y;
  198. this.drawingSpeedLines_1085[0].X2 = pointB.X;
  199. this.drawingSpeedLines_1085[0].Y2 = pointB.Y;
  200. this.drawingSpeedLines_1085[1].Visibility = (Visibility)(1);
  201. this.drawingSpeedLines_1085[2].Visibility = (Visibility)(1);
  202. }
  203. catch
  204. {
  205. ;
  206. }
  207. }
  208. this.drawingSpeedLines_1085[0].Visibility = (Visibility)(1);
  209. }
  210. public override ImageSource Icon()
  211. {
  212. ImageSource result;
  213. try
  214. {
  215. result = ImageHelper.GetImage("FibFan.png");
  216. }
  217. catch (Exception expr_3A)
  218. {
  219. ProjectData.SetProjectError(expr_3A);
  220. result = null;
  221. ProjectData.ClearProjectError();
  222. }
  223. return result;
  224. }
  225. protected override bool CanExtendLeft()
  226. {
  227. return false;
  228. }
  229. protected override bool CanExtendRight()
  230. {
  231. return false;
  232. }
  233. }
  234. }