PocketProcessDataChart.xaml.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using Abt.Controls.SciChart.Visuals.Axes;
  15. using Aitex.Core.Equipment.SusceptorDefine;
  16. using Aitex.Core.UI.View.Smart;
  17. using Aitex.Core.UI.ControlDataContext;
  18. namespace Aitex.Core.UI.Control
  19. {
  20. /// <summary>
  21. /// Interaction logic for PocketProcessDataChart.xaml
  22. /// </summary>
  23. public partial class PocketProcessDataChart : UserControl
  24. {
  25. public PocketProcessDataChart()
  26. {
  27. InitializeComponent();
  28. }
  29. private void sciChart_MouseDoubleClick(object sender, MouseButtonEventArgs e)
  30. {
  31. if (e.ChangedButton == MouseButton.Right)
  32. {
  33. //右键双击,恢复1:1的视图
  34. this.sciChart.ZoomExtents();
  35. }
  36. }
  37. private void NumericAxis_Pyro_MouseEnter(object sender, MouseEventArgs e)
  38. {
  39. pyroAxisTopDown.Visibility = System.Windows.Visibility.Visible;
  40. pyroAxisTopUp.Visibility = System.Windows.Visibility.Visible;
  41. pyroAxisBottomUp.Visibility = System.Windows.Visibility.Visible;
  42. pyroAxisBottomDown.Visibility = System.Windows.Visibility.Visible;
  43. }
  44. private void NumericAxis_Pyro_MouseLeave(object sender, MouseEventArgs e)
  45. {
  46. if (pyroAxisTopDown.IsMouseOver || pyroAxisTopUp.IsMouseOver ||
  47. pyroAxisBottomDown.IsMouseOver || pyroAxisBottomUp.IsMouseOver)
  48. return;
  49. pyroAxisTopDown.Visibility = System.Windows.Visibility.Hidden;
  50. pyroAxisTopUp.Visibility = System.Windows.Visibility.Hidden;
  51. pyroAxisBottomDown.Visibility = System.Windows.Visibility.Hidden;
  52. pyroAxisBottomUp.Visibility = System.Windows.Visibility.Hidden;
  53. }
  54. private void NumericAxis_Wrap_MouseEnter(object sender, MouseEventArgs e)
  55. {
  56. warpAxisTopDown.Visibility = System.Windows.Visibility.Visible;
  57. warpAxisTopUp.Visibility = System.Windows.Visibility.Visible;
  58. warpAxisBottomUp.Visibility = System.Windows.Visibility.Visible;
  59. warpAxisBottomDown.Visibility = System.Windows.Visibility.Visible;
  60. }
  61. private void NumericAxis_Wrap_MouseLeave(object sender, MouseEventArgs e)
  62. {
  63. if (warpAxisTopDown.IsMouseOver || warpAxisTopUp.IsMouseOver ||
  64. warpAxisBottomDown.IsMouseOver || warpAxisBottomUp.IsMouseOver)
  65. return;
  66. warpAxisTopDown.Visibility = System.Windows.Visibility.Hidden;
  67. warpAxisTopUp.Visibility = System.Windows.Visibility.Hidden;
  68. warpAxisBottomDown.Visibility = System.Windows.Visibility.Hidden;
  69. warpAxisBottomUp.Visibility = System.Windows.Visibility.Hidden;
  70. }
  71. private void NumericAxis_Reflect_MouseEnter(object sender, MouseEventArgs e)
  72. {
  73. ReflectAxisTopDown.Visibility = System.Windows.Visibility.Visible;
  74. ReflectAxisTopUp.Visibility = System.Windows.Visibility.Visible;
  75. ReflectAxisBottomUp.Visibility = System.Windows.Visibility.Visible;
  76. ReflectAxisBottomDown.Visibility = System.Windows.Visibility.Visible;
  77. }
  78. private void NumericAxis_Reflect_MouseLeave(object sender, MouseEventArgs e)
  79. {
  80. if (ReflectAxisTopDown.IsMouseOver || ReflectAxisTopUp.IsMouseOver ||
  81. ReflectAxisBottomDown.IsMouseOver || ReflectAxisBottomUp.IsMouseOver)
  82. return;
  83. ReflectAxisTopDown.Visibility = System.Windows.Visibility.Hidden;
  84. ReflectAxisTopUp.Visibility = System.Windows.Visibility.Hidden;
  85. ReflectAxisBottomDown.Visibility = System.Windows.Visibility.Hidden;
  86. ReflectAxisBottomUp.Visibility = System.Windows.Visibility.Hidden;
  87. }
  88. private void YAxisTopUp_Click(object sender, MouseButtonEventArgs e)
  89. {
  90. var l = sender as Label;
  91. NumericAxis axis = sciChart.YAxes[1 + int.Parse(l.Tag.ToString())] as NumericAxis;
  92. double min = (double)axis.VisibleRange.Min;
  93. double max = (double)axis.VisibleRange.Max;
  94. axis.VisibleRange.Max = max + 0.1 * (max - min);
  95. }
  96. private void YAxisTopDown_Click(object sender, MouseButtonEventArgs e)
  97. {
  98. var l = sender as Label;
  99. NumericAxis axis = sciChart.YAxes[1 + int.Parse(l.Tag.ToString())] as NumericAxis;
  100. double min = (double)axis.VisibleRange.Min;
  101. double max = (double)axis.VisibleRange.Max;
  102. axis.VisibleRange.Max = max - 0.1 * (max - min);
  103. }
  104. private void YAxisBottomUp_Click(object sender, MouseButtonEventArgs e)
  105. {
  106. var l = sender as Label;
  107. NumericAxis axis = sciChart.YAxes[1 + int.Parse(l.Tag.ToString())] as NumericAxis;
  108. double min = (double)axis.VisibleRange.Min;
  109. double max = (double)axis.VisibleRange.Max;
  110. axis.VisibleRange.Min = min + 0.1 * (max - min);
  111. }
  112. private void YAxisBottomDown_Click(object sender, MouseButtonEventArgs e)
  113. {
  114. var l = sender as Label;
  115. NumericAxis axis = sciChart.YAxes[1 + int.Parse(l.Tag.ToString())] as NumericAxis;
  116. double min = (double)axis.VisibleRange.Min;
  117. double max = (double)axis.VisibleRange.Max;
  118. axis.VisibleRange.Min = min - 0.1 * (max - min);
  119. }
  120. private void checkAutoRange_Checked(object sender, RoutedEventArgs e)
  121. {
  122. CheckBox ck = sender as CheckBox;
  123. AutoRange value = ck.IsChecked.Value ? Abt.Controls.SciChart.Visuals.Axes.AutoRange.Always : Abt.Controls.SciChart.Visuals.Axes.AutoRange.Never;
  124. sciChart.XAxis.AutoRange = value;
  125. foreach (var yaxis in sciChart.YAxes)
  126. yaxis.AutoRange = value;
  127. }
  128. private void OnChangeLineColor(object sender, RoutedEventArgs e)
  129. {
  130. var btn = (Button)sender;
  131. if (btn != null)
  132. {
  133. string dataId = (string)btn.Tag;
  134. var dlg = new System.Windows.Forms.ColorDialog();
  135. if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  136. {
  137. var newColor = new System.Windows.Media.Color() { A = dlg.Color.A, B = dlg.Color.B, G = dlg.Color.G, R = dlg.Color.R };
  138. var vm = (ProcessDataChartDataItem)DataContext;
  139. var line = vm.RenderableSeries.ToList().Find((o) => ((SmartDataLine)o).UniqueId == dataId);
  140. if (line != null) line.SeriesColor = newColor;
  141. }
  142. }
  143. }
  144. private void OnChangeDrawingItemVisibility(object sender, RoutedEventArgs e)
  145. {
  146. var checkbox = (CheckBox)sender;
  147. if (checkbox != null && checkbox.IsChecked.HasValue)
  148. {
  149. string dataId = (string)checkbox.Tag;
  150. var vm = (ProcessDataChartDataItem)DataContext;
  151. var line = vm.RenderableSeries.ToList().Find((o) => ((SmartDataLine)o).UniqueId == dataId);
  152. if (line != null)
  153. {
  154. line.IsVisible = checkbox.IsChecked.Value;
  155. //vm.InvokePropertyChanged("ReflectionDataSeries");
  156. }
  157. }
  158. }
  159. private void checkConfigPanel_Checked(object sender, RoutedEventArgs e)
  160. {
  161. dataConfigPanelColumn.Width = new GridLength((sender as CheckBox).IsChecked.Value ? 300 : 0, GridUnitType.Pixel);
  162. }
  163. }
  164. }