using Aitex.Core.RT.Log; using SciChart.Charting.ChartModifiers; using SciChart.Charting.Visuals.Annotations; using SciChart.Data.Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory { /// /// ProcessDetailView.xaml 的交互逻辑 /// public partial class ProcessDetailView : UserControl { public ProcessDetailView() { InitializeComponent(); } private void OnAnnotationCreated(object sender, AnnotationCreationArgs e) { if (e.NewAnnotation is LineArrowAnnotation newAnnotation) { try { if (e.NewAnnotation.ParentSurface != null) { double x1 = 0, y1 = 0, x2 = 0, y2 = 0, temp = 0; if (newAnnotation.X1 is Double xx1) x1 = xx1; if (newAnnotation.X2 is Double xx2) x2 = xx2; if (newAnnotation.Y1 is Double yy1) y1 = yy1; if (newAnnotation.Y2 is Double yy2) y2 = yy2; if (x1 > x2) { temp = x1; x1 = x2; x2 = temp; } e.NewAnnotation.ParentSurface.XAxis.VisibleRange = new DoubleRange() { Min = x1, Max = x2 }; LOG.Info($"LineArrowAnnotation x1[{x1},x2[{x2}]]"); if (y1 > y2) { temp = y1; y1 = y2; y2 = temp; } e.NewAnnotation.ParentSurface.YAxis.VisibleRange = new DoubleRange() { Min = y1, Max = y2 }; LOG.Info($"LineArrowAnnotation y1[{y1},y2[{y2}]]"); } e.NewAnnotation.ParentSurface.Annotations.Clear(); ZoomByLine.IsChecked = false; } catch (Exception ex) { LOG.Info($"LineArrowAnnotation:{ex.StackTrace}-{ex.Message}"); } } } private void RadioButton_Checked(object sender, RoutedEventArgs e) { if(sender is RadioButton radio) { switch (radio.Name) { case "ShowVerticalLine": if (sliceModifier.VerticalLines == null || sliceModifier.VerticalLines.Count == 0) { sliceModifier.VerticalLines.Add(new VerticalLineAnnotation() { X1 = 0 }); sciChart.MouseLeftButtonUp += sciChart_MouseLeftButtonUp; } break; case "DeleteVertical": sliceModifier.VerticalLines.Clear(); break; } } e.Handled = true; } private void ShowVetical_UnChecked(object sender, RoutedEventArgs e) { HoldVetical.IsChecked = false; sciChart.MouseLeftButtonUp -= sciChart_MouseLeftButtonUp; e.Handled = true; } int ClickCount = 0; private void Double_Click(object sender, RoutedEventArgs e) { var t = sender as RadioButton; ClickCount++; if(ClickCount%2==0) t.IsChecked = false; if(t.IsChecked==true) { Grid.SetRowSpan(sciChart, 1); syncChart.Visibility = Visibility.Visible; doubleParameterTree.Visibility = Visibility.Visible; treeTitle.Visibility = Visibility.Visible; Grid.SetRowSpan(ParameterTreeView, 1); } else { syncChart.Visibility = Visibility.Collapsed; Grid.SetRowSpan(sciChart, 2); treeTitle.Visibility= Visibility.Collapsed; doubleParameterTree.Visibility = Visibility.Collapsed; Grid.SetRowSpan(ParameterTreeView, 3); } } private void sciChart_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (ShowVerticalLine.IsChecked == true && HoldVetical.IsChecked == false) { var vertical = sliceModifier.VerticalLines?.FirstOrDefault(); if (vertical != null) vertical.X1 = rolloverModifier.SeriesData.SeriesInfo.FirstOrDefault().XValue; } e.Handled = true; } } }