104 lines
3.3 KiB
C#
104 lines
3.3 KiB
C#
|
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;
|
|||
|
|
|||
|
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));
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public ObservableCollection<IRenderableSeries> Target
|
|||
|
{
|
|||
|
get { return (ObservableCollection<IRenderableSeries>)GetValue(TargetProperty); }
|
|||
|
set { SetValue(TargetProperty, value); }
|
|||
|
}
|
|||
|
|
|||
|
public static readonly DependencyProperty TargetProperty =
|
|||
|
DependencyProperty.Register("Target", typeof(ObservableCollection<IRenderableSeries>), typeof(SciChartMouseDownChangingLocationBehavior), new PropertyMetadata(null));
|
|||
|
|
|||
|
|
|||
|
protected override void OnAttached()
|
|||
|
{
|
|||
|
AssociatedObject.PreviewMouseDown += mousedown;
|
|||
|
}
|
|||
|
|
|||
|
private void mousedown(object sender, MouseButtonEventArgs e)
|
|||
|
{
|
|||
|
if (e.ChangedButton == MouseButton.Left)
|
|||
|
{
|
|||
|
foreach (IRenderableSeries series in Target)
|
|||
|
{
|
|||
|
if (series.IsSelected)
|
|||
|
{
|
|||
|
double xvalue = 0, yvalue = 0;
|
|||
|
if (double.TryParse(XAxisInfo.CursorFormattedDataValue, out xvalue) && double.TryParse(YAxisInfo.CursorFormattedDataValue, out yvalue))
|
|||
|
{
|
|||
|
ChartDataLineX s = series as ChartDataLineX;
|
|||
|
|
|||
|
s.DataXOffset = xvalue;
|
|||
|
s.DataOffset = yvalue;
|
|||
|
s.IsSelected = false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
e.Handled = true; //不写会失去焦点
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|