DrawingTironeLevels.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. namespace MuchInfo.Chart.WPF.Primitives.Drawing
  12. {
  13. public class DrawingTironeLevels : Drawing2PointLinkedBase
  14. {
  15. private ExtendableLine _extendableLine;
  16. private float drawingTironeLevels_1096;
  17. private float drawingTironeLevels_1097;
  18. public DrawingTironeLevels()
  19. {
  20. this.drawingTironeLevels_1096 = 0f;
  21. this.drawingTironeLevels_1097 = 0f;
  22. }
  23. public override DrawingToolType ToolType()
  24. {
  25. return DrawingToolType.Tirone;
  26. }
  27. public override bool CanPlotOnAllSymbols()
  28. {
  29. return true;
  30. }
  31. public override IDrawingTool Clone()
  32. {
  33. return new DrawingTironeLevels
  34. {
  35. mColor = Colors.Orange
  36. };
  37. }
  38. protected override List<FrameworkElement> GetDrawingPlots(Chart owner, ScaleLayer aScale, Rect aRect)
  39. {
  40. List<FrameworkElement> list = new List<FrameworkElement>();
  41. bool flag = this._extendableLine == null;
  42. if (flag)
  43. {
  44. this._extendableLine = new ExtendableLine(this, owner);
  45. this._extendableLine.Stroke = new SolidColorBrush(this.mColor);
  46. this._extendableLine.StrokeThickness = 1.4;
  47. DoubleCollection doubleCollection = new DoubleCollection();
  48. doubleCollection.Add(10.0);
  49. doubleCollection.Add(10.0);
  50. this._extendableLine.SetMainStrokeDash(doubleCollection);
  51. this._extendableLine.ChannelStroke = this._extendableLine.Stroke;
  52. this._extendableLine.ExtensionStroke = this._extendableLine.Stroke;
  53. }
  54. this.MoveDrawingToNewLocations(aRect);
  55. list.Add(this._extendableLine);
  56. return list;
  57. }
  58. public override string MenuDescription()
  59. {
  60. return LanguageManager.FindResource(LanguageConst.DrawingTool_Abbreviation_TironeLevels);
  61. }
  62. public override string Abbreviation()
  63. {
  64. return "Tirone";
  65. }
  66. public override string Description()
  67. {
  68. return this.MenuDescription();
  69. }
  70. protected override void ColorChanged()
  71. {
  72. bool flag = this._extendableLine != null;
  73. if (flag)
  74. {
  75. this._extendableLine.Stroke = new SolidColorBrush(this.mColor);
  76. this._extendableLine.ChannelStroke = this._extendableLine.Stroke;
  77. this._extendableLine.ExtensionStroke = this._extendableLine.Stroke;
  78. }
  79. }
  80. public override void CalculateValues()
  81. {
  82. this.CalcHighLowForPoints(this.P1Date, this.P2Date, ref this.drawingTironeLevels_1096, ref this.drawingTironeLevels_1097);
  83. this.mDrawP1.Y = ((double)this.mLastScale.GetmScaler().ScaledY(this.drawingTironeLevels_1097 +
  84. (this.drawingTironeLevels_1096 - this.drawingTironeLevels_1097) / 2f, this.mLastRect));
  85. this.mDrawP2.Y = ((double)this.mLastScale.GetmScaler().ScaledY(this.drawingTironeLevels_1097 +
  86. (this.drawingTironeLevels_1096 - this.drawingTironeLevels_1097) / 2f, this.mLastRect));
  87. }
  88. protected override void MoveDrawingToNewLocations(Rect aRect)
  89. {
  90. bool flag = this._extendableLine != null;
  91. if (flag)
  92. {
  93. this._extendableLine.SetPosition(this.mDrawP1, this.mDrawP2, this.ExtendLeft, this.ExtendRight, aRect);
  94. Point p = default(Point);
  95. Point p2 = default(Point);
  96. Point pointA = new Point();
  97. Point pointB = new Point();
  98. p.X = (this.mDrawP1.X);
  99. float num = this.drawingTironeLevels_1097 + 2f * (this.drawingTironeLevels_1096 - this.drawingTironeLevels_1097) / 3f;
  100. num = this.mLastScale.GetmScaler().ScaledY(num, this.mLastRect);
  101. p.Y = ((double)num);
  102. p2.X = (this.mDrawP2.X);
  103. num = this.drawingTironeLevels_1097 + 2f * (this.drawingTironeLevels_1096 - this.drawingTironeLevels_1097) / 3f;
  104. num = this.mLastScale.GetmScaler().ScaledY(num, this.mLastRect);
  105. p2.Y = ((double)num);
  106. PointOfLineAtRectangleCalculator(ref pointA, ref pointB, p, p2, aRect);
  107. this._extendableLine.SetTopPosition(pointA, pointB, this.ExtendLeft, this.ExtendRight, aRect);
  108. p.X = (this.mDrawP1.X);
  109. num = this.drawingTironeLevels_1097 + (this.drawingTironeLevels_1096 - this.drawingTironeLevels_1097) / 3f;
  110. num = this.mLastScale.GetmScaler().ScaledY(num, this.mLastRect);
  111. p.Y = ((double)num);
  112. p2.X = (this.mDrawP2.X);
  113. num = this.drawingTironeLevels_1097 + (this.drawingTironeLevels_1096 - this.drawingTironeLevels_1097) / 3f;
  114. num = this.mLastScale.GetmScaler().ScaledY(num, this.mLastRect);
  115. p2.Y = ((double)num);
  116. PointOfLineAtRectangleCalculator(ref pointA, ref pointB, p, p2, aRect);
  117. this._extendableLine.SetBotPosition(pointA, pointB, this.ExtendLeft, this.ExtendRight, aRect);
  118. }
  119. }
  120. public override ImageSource Icon()
  121. {
  122. ImageSource result;
  123. try
  124. {
  125. result = ImageHelper.GetImage("Tirone.png");
  126. }
  127. catch (Exception expr_3A)
  128. {
  129. ProjectData.SetProjectError(expr_3A);
  130. result = null;
  131. ProjectData.ClearProjectError();
  132. }
  133. return result;
  134. }
  135. protected override bool CanExtendLeft()
  136. {
  137. return true;
  138. }
  139. protected override bool CanExtendRight()
  140. {
  141. return true;
  142. }
  143. protected override bool AllowExtensionColorEdit()
  144. {
  145. return false;
  146. }
  147. public override string RootName
  148. {
  149. get { return "drawTIRN"; }
  150. }
  151. }
  152. }