DrawingVerticalLine.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using Microsoft.VisualBasic.CompilerServices;
  2. using MuchInfo.Chart.Data.EnumTypes;
  3. using MuchInfo.Chart.Infrastructure.Helpers;
  4. using MuchInfo.Chart.Infrastructure.Utilities;
  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 DrawingVerticalLine : Drawing1PointBase
  15. {
  16. #region Fields
  17. private Line _vLine;
  18. #endregion Fields
  19. #region Properties
  20. #region Public Properties
  21. public override string RootName
  22. {
  23. get { return "DrawVLine"; }
  24. }
  25. #endregion Public Properties
  26. #endregion Properties
  27. #region Methods
  28. #region Public Methods
  29. public override string Abbreviation()
  30. {
  31. return LanguageManager.FindResource(LanguageConst.DrawingTool_Abbreviation_VerticalLine);
  32. }
  33. public override List<ControlPair> AdditionalEditors()
  34. {
  35. return new List<ControlPair>();
  36. }
  37. public override bool CanPlotOnAllSymbols()
  38. {
  39. return true;
  40. }
  41. public override bool CanSaveByPercent()
  42. {
  43. return true;
  44. }
  45. public override IDrawingTool Clone()
  46. {
  47. return new DrawingVerticalLine
  48. {
  49. mColor = Colors.White
  50. };
  51. }
  52. public override string Description()
  53. {
  54. return this.MenuDescription();
  55. }
  56. public override ImageSource Icon()
  57. {
  58. ImageSource result;
  59. try
  60. {
  61. result = ImageHelper.GetImage("VLine.png");
  62. }
  63. catch (Exception expr_3A)
  64. {
  65. ProjectData.SetProjectError(expr_3A);
  66. result = null;
  67. ProjectData.ClearProjectError();
  68. }
  69. return result;
  70. }
  71. public override string MenuDescription()
  72. {
  73. return LanguageManager.FindResource(LanguageConst.DrawingTool_Edit_Description_VerticalLine);
  74. }
  75. public override DrawingToolType ToolType()
  76. {
  77. return DrawingToolType.VLine;
  78. }
  79. #endregion Public Methods
  80. #region Protected Methods
  81. protected override void ColorChanged()
  82. {
  83. bool flag = this._vLine != null;
  84. if (flag)
  85. {
  86. this._vLine.Stroke = (new SolidColorBrush(this.mColor));
  87. }
  88. }
  89. protected override List<FrameworkElement> GetDrawingPlots(Chart owner, ScaleLayer aScale, Rect aRect)
  90. {
  91. var list = new List<FrameworkElement>();
  92. this._vLine = new Line
  93. {
  94. Stroke = new SolidColorBrush(this.mColor),
  95. StrokeThickness = 1.4
  96. };
  97. this.MoveDrawingToNewLocations(aRect);
  98. list.Add(this._vLine);
  99. return list;
  100. }
  101. protected override void MoveDrawingToNewLocations(Rect aRect)
  102. {
  103. bool flag = this._vLine != null;
  104. if (flag)
  105. {
  106. this._vLine.X1 = (this.mLastX1);
  107. this._vLine.Y1 = (aRect.Top);
  108. this._vLine.X2 = (this.mLastX1);
  109. this._vLine.Y2 = (aRect.Bottom);
  110. }
  111. flag = (this.SelectionArea != null);
  112. if (flag)
  113. {
  114. this.SelectionArea.SetPosition(this.mLastX1, aRect.Top, this.mLastX1, aRect.Bottom);
  115. }
  116. }
  117. #endregion Protected Methods
  118. #endregion Methods
  119. }
  120. }