2023-09-13 17:28:59 +08:00
|
|
|
|
using SciChart.Charting.Visuals.RenderableSeries;
|
|
|
|
|
using SciChart.Charting.Visuals;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
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.Interactivity;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
|
using System.Windows.Shapes;
|
2023-09-14 17:02:13 +08:00
|
|
|
|
using SciChart.Charting.Model.ChartSeries;
|
2023-09-13 17:28:59 +08:00
|
|
|
|
|
|
|
|
|
namespace SicUI.Models.PMs.Charting
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// PMChartingV2View.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class PMChartingV2View : UserControl
|
|
|
|
|
{
|
|
|
|
|
public PMChartingV2View()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class SciChartMouseDownChangingLocationBehavior : Behavior<SciChartSurface>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AxisInfo YAxisInfo
|
|
|
|
|
{
|
|
|
|
|
get { return (AxisInfo)GetValue(YAxisInfoProperty); }
|
|
|
|
|
set { SetValue(YAxisInfoProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty YAxisInfoProperty =
|
|
|
|
|
DependencyProperty.Register("YAxisInfo", typeof(AxisInfo), typeof(SciChartMouseDownChangingLocationBehavior), new PropertyMetadata(null));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AxisInfo XAxisInfo
|
|
|
|
|
{
|
|
|
|
|
get { return (AxisInfo)GetValue(XAxisInfoProperty); }
|
|
|
|
|
set { SetValue(XAxisInfoProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Using a DependencyProperty as the backing store for XAxisInfo. This enables animation, styling, binding, etc...
|
|
|
|
|
public static readonly DependencyProperty XAxisInfoProperty =
|
|
|
|
|
DependencyProperty.Register("XAxisInfo", typeof(AxisInfo), typeof(SciChartMouseDownChangingLocationBehavior), new PropertyMetadata(null));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-14 17:02:13 +08:00
|
|
|
|
public ObservableCollection<IRenderableSeriesViewModel> Target
|
2023-09-13 17:28:59 +08:00
|
|
|
|
{
|
2023-09-14 17:02:13 +08:00
|
|
|
|
get { return (ObservableCollection<IRenderableSeriesViewModel>)GetValue(TargetProperty); }
|
2023-09-13 17:28:59 +08:00
|
|
|
|
set { SetValue(TargetProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty TargetProperty =
|
2023-09-14 17:02:13 +08:00
|
|
|
|
DependencyProperty.Register("Target", typeof(ObservableCollection<IRenderableSeriesViewModel>), typeof(SciChartMouseDownChangingLocationBehavior), new PropertyMetadata(null));
|
2023-09-13 17:28:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnAttached()
|
|
|
|
|
{
|
|
|
|
|
AssociatedObject.PreviewMouseDown += mousedown;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mousedown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.ChangedButton == MouseButton.Left)
|
|
|
|
|
{
|
2023-09-14 17:02:13 +08:00
|
|
|
|
foreach (IRenderableSeriesViewModel series in Target)
|
2023-09-13 17:28:59 +08:00
|
|
|
|
{
|
|
|
|
|
if (series.IsSelected)
|
|
|
|
|
{
|
|
|
|
|
double xvalue = 0, yvalue = 0;
|
|
|
|
|
if (double.TryParse(XAxisInfo.CursorFormattedDataValue, out xvalue) && double.TryParse(YAxisInfo.CursorFormattedDataValue, out yvalue))
|
|
|
|
|
{
|
2023-09-14 17:02:13 +08:00
|
|
|
|
ChartDataLineXV2 s = series as ChartDataLineXV2;
|
2023-09-13 17:28:59 +08:00
|
|
|
|
|
|
|
|
|
s.DataXOffset = xvalue;
|
|
|
|
|
s.DataOffset = yvalue;
|
|
|
|
|
s.IsSelected = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e.Handled = true; //不写会失去焦点
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|