ProcessDetailView.xaml.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using Aitex.Core.RT.Log;
  2. using SciChart.Charting.ChartModifiers;
  3. using SciChart.Charting.Visuals.Annotations;
  4. using SciChart.Data.Model;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory
  20. {
  21. /// <summary>
  22. /// ProcessDetailView.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class ProcessDetailView : UserControl
  25. {
  26. public ProcessDetailView()
  27. {
  28. InitializeComponent();
  29. }
  30. private void OnAnnotationCreated(object sender, AnnotationCreationArgs e)
  31. {
  32. if (e.NewAnnotation is LineArrowAnnotation newAnnotation)
  33. {
  34. try
  35. {
  36. if (e.NewAnnotation.ParentSurface != null)
  37. {
  38. double x1 = 0, y1 = 0, x2 = 0, y2 = 0, temp = 0;
  39. if (newAnnotation.X1 is Double xx1) x1 = xx1;
  40. if (newAnnotation.X2 is Double xx2) x2 = xx2;
  41. if (newAnnotation.Y1 is Double yy1) y1 = yy1;
  42. if (newAnnotation.Y2 is Double yy2) y2 = yy2;
  43. if (x1 > x2) { temp = x1; x1 = x2; x2 = temp; }
  44. e.NewAnnotation.ParentSurface.XAxis.VisibleRange = new DoubleRange()
  45. {
  46. Min = x1,
  47. Max = x2
  48. };
  49. LOG.Info($"LineArrowAnnotation x1[{x1},x2[{x2}]]");
  50. if (y1 > y2) { temp = y1; y1 = y2; y2 = temp; }
  51. e.NewAnnotation.ParentSurface.YAxis.VisibleRange = new DoubleRange()
  52. {
  53. Min = y1,
  54. Max = y2
  55. };
  56. LOG.Info($"LineArrowAnnotation y1[{y1},y2[{y2}]]");
  57. }
  58. e.NewAnnotation.ParentSurface.Annotations.Clear();
  59. ZoomByLine.IsChecked = false;
  60. }
  61. catch (Exception ex)
  62. {
  63. LOG.Info($"LineArrowAnnotation:{ex.StackTrace}-{ex.Message}");
  64. }
  65. }
  66. }
  67. private void RadioButton_Checked(object sender, RoutedEventArgs e)
  68. {
  69. if(sender is RadioButton radio)
  70. {
  71. switch (radio.Name)
  72. {
  73. case "ShowVerticalLine":
  74. if (sliceModifier.VerticalLines == null || sliceModifier.VerticalLines.Count == 0)
  75. {
  76. sliceModifier.VerticalLines.Add(new VerticalLineAnnotation() { X1 = 0 });
  77. sciChart.MouseLeftButtonUp += sciChart_MouseLeftButtonUp;
  78. }
  79. break;
  80. case "DeleteVertical":
  81. sliceModifier.VerticalLines.Clear();
  82. break;
  83. }
  84. }
  85. e.Handled = true;
  86. }
  87. private void ShowVetical_UnChecked(object sender, RoutedEventArgs e)
  88. {
  89. HoldVetical.IsChecked = false;
  90. sciChart.MouseLeftButtonUp -= sciChart_MouseLeftButtonUp;
  91. e.Handled = true;
  92. }
  93. int ClickCount = 0;
  94. private void Double_Click(object sender, RoutedEventArgs e)
  95. {
  96. var t = sender as RadioButton;
  97. ClickCount++;
  98. if(ClickCount%2==0) t.IsChecked = false;
  99. if(t.IsChecked==true)
  100. {
  101. Grid.SetRowSpan(sciChart, 1);
  102. syncChart.Visibility = Visibility.Visible;
  103. doubleParameterTree.Visibility = Visibility.Visible;
  104. treeTitle.Visibility = Visibility.Visible;
  105. Grid.SetRowSpan(ParameterTreeView, 1);
  106. }
  107. else
  108. {
  109. syncChart.Visibility = Visibility.Collapsed;
  110. Grid.SetRowSpan(sciChart, 2);
  111. treeTitle.Visibility= Visibility.Collapsed;
  112. doubleParameterTree.Visibility = Visibility.Collapsed;
  113. Grid.SetRowSpan(ParameterTreeView, 3);
  114. }
  115. }
  116. private void sciChart_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  117. {
  118. if (ShowVerticalLine.IsChecked == true && HoldVetical.IsChecked == false)
  119. {
  120. var vertical = sliceModifier.VerticalLines?.FirstOrDefault();
  121. if (vertical != null) vertical.X1 = rolloverModifier.SeriesData.SeriesInfo.FirstOrDefault().XValue;
  122. }
  123. e.Handled = true;
  124. }
  125. }
  126. }