123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- 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
- {
- /// <summary>
- /// ProcessDetailView.xaml 的交互逻辑
- /// </summary>
- public partial class ProcessDetailView : UserControl
- {
- private ProcessDetailViewModel<double> processDetail;
- public ProcessDetailView()
- {
- InitializeComponent();
- }
- private void OnAnnotationCreated(object sender, AnnotationCreationArgs e)
- {
- if (e.NewAnnotation is LineArrowAnnotation newAnnotation)
- {
- try
- {
- processDetail = DataContext as ProcessDetailViewModel<double>;
- if (processDetail != 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; }
- processDetail.VisibleRangeTime = new DoubleRange()
- {
- Min = x1,
- Max = x2
- };
- LOG.Info($"LineArrowAnnotation x1[{x1},x2[{x2}]]");
- if (y1 > y2) { temp = y1; y1 = y2; y2 = temp; }
- processDetail.VisibleRangeValue = new DoubleRange()
- {
- Min = y1,
- Max = y2
- };
- LOG.Info($"LineArrowAnnotation y1[{y1},y2[{y2}]]");
- }
- if(!sciChart.Annotations.Remove(newAnnotation))
- syncChart?.Annotations?.Remove(newAnnotation);
- 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;
- }
-
- }
- }
|