|
|
@ -44,8 +44,9 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
_dispatcher = Application.Current.Dispatcher;
|
|
|
|
_dispatcher = Application.Current.Dispatcher;
|
|
|
|
_wavesModel = new WavesModel();
|
|
|
|
_wavesModel = new WavesModel();
|
|
|
|
(Application.Current.MainWindow as System.Windows.Window).Closing += ApplicationClosingDispose;
|
|
|
|
(Application.Current.MainWindow as System.Windows.Window).Closing += ApplicationClosingDispose;
|
|
|
|
|
|
|
|
IntervalTime=100;
|
|
|
|
CreateChart();
|
|
|
|
CreateChart();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 字段
|
|
|
|
#region 字段
|
|
|
@ -55,9 +56,11 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
int _samplingFrequency = 500; // 采样频率 (Hz).
|
|
|
|
int _samplingFrequency = 500; // 采样频率 (Hz).
|
|
|
|
WavesModel _wavesModel;
|
|
|
|
WavesModel _wavesModel;
|
|
|
|
private int _lChartCount = 1;
|
|
|
|
private int _lChartCount = 1;
|
|
|
|
public ConcurrentQueue<StationModel> smList;
|
|
|
|
public ConcurrentQueue<StationModel> smList=new ConcurrentQueue<StationModel>();
|
|
|
|
|
|
|
|
|
|
|
|
public List<AxisY> _chartAxisY=new List<AxisY>();
|
|
|
|
public List<AxisY> _chartAxisY=new List<AxisY>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private DispatcherTimer dispatcherTimer=new DispatcherTimer();
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 属性
|
|
|
|
#region 属性
|
|
|
@ -144,6 +147,40 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
SetProperty(ref _currentTime, value);
|
|
|
|
SetProperty(ref _currentTime, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private YAxisAutoPlacement _yaxisPlacement;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public YAxisAutoPlacement YaxisPlacement
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
get { return _yaxisPlacement; }
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LChartALL.ViewXY.AxisLayout.YAxisAutoPlacement = value;
|
|
|
|
|
|
|
|
int distancetoX =_wavesModel.SetYasixPlacement(LChartALL);
|
|
|
|
|
|
|
|
foreach (var item in LChartALL.ViewXY.YAxes)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
item.Title.DistanceToAxis = distancetoX;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SetProperty(ref _yaxisPlacement, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int _IntervalTime=10;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int IntervalTime
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
get { return _IntervalTime; }
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (value >=10)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dispatcherTimer.Interval = TimeSpan.FromMilliseconds(value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SetProperty(ref _IntervalTime, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 事件
|
|
|
|
#region 事件
|
|
|
@ -200,6 +237,8 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
st.Stop();
|
|
|
|
st.Stop();
|
|
|
|
Debug.WriteLine("统计时间StartChart************:{0}", st.Elapsed);
|
|
|
|
Debug.WriteLine("统计时间StartChart************:{0}", st.Elapsed);
|
|
|
|
FeedDatasToChart();
|
|
|
|
FeedDatasToChart();
|
|
|
|
|
|
|
|
_wavesModel.CreateAxisYEventTime(CurrentEventTime, LChartALL.ViewXY, smList.ToList());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -355,21 +394,28 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
if (_lChartAll != null)
|
|
|
|
if (_lChartAll != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool yAxesVisible = ((bool)isCheck == true);
|
|
|
|
bool yAxesVisible = ((bool)isCheck == true);
|
|
|
|
|
|
|
|
if (smList.Count == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
_lChartAll.BeginUpdate();
|
|
|
|
if (yAxesVisible)
|
|
|
|
if (yAxesVisible)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
StartChart();
|
|
|
|
//Set real-time monitoring automatic old data destruction
|
|
|
|
//Set real-time monitoring automatic old data destruction
|
|
|
|
LChartALL.ViewXY.DropOldSeriesData = true;
|
|
|
|
LChartALL.ViewXY.DropOldSeriesData = true;
|
|
|
|
_pointsAppended = LChartALL.ViewXY.XAxes[0].Minimum;
|
|
|
|
_pointsAppended = LChartALL.ViewXY.XAxes[0].Minimum;
|
|
|
|
CompositionTarget.Rendering -= CompositionTarget_Rendering;
|
|
|
|
dispatcherTimer.Tick -= CompositionTarget_Rendering;
|
|
|
|
CompositionTarget.Rendering += CompositionTarget_Rendering;
|
|
|
|
dispatcherTimer.Tick += CompositionTarget_Rendering;
|
|
|
|
LChartALL.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.Scrolling;
|
|
|
|
LChartALL.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.Scrolling;
|
|
|
|
|
|
|
|
dispatcherTimer.Start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
dispatcherTimer.Stop();
|
|
|
|
|
|
|
|
|
|
|
|
LChartALL.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.None;
|
|
|
|
LChartALL.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.None;
|
|
|
|
CompositionTarget.Rendering -= CompositionTarget_Rendering;
|
|
|
|
dispatcherTimer.Tick -= CompositionTarget_Rendering;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
|
_lChartAll.EndUpdate();
|
|
|
@ -395,18 +441,18 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
LChartALL.ViewXY.AxisLayout.SegmentsGap = 0;
|
|
|
|
LChartALL.ViewXY.AxisLayout.SegmentsGap = 0;
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.PanDirection = PanDirection.Horizontal;
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.PanDirection = PanDirection.Horizontal;
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.WheelZooming = WheelZooming.Horizontal;
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.WheelZooming = WheelZooming.Horizontal;
|
|
|
|
LChartALL.ViewXY.AxisLayout.YAxisAutoPlacement = YAxisAutoPlacement.AllLeft;
|
|
|
|
LChartALL.ViewXY.AxisLayout.YAxisAutoPlacement = YAxisAutoPlacement.AllRight;
|
|
|
|
LChartALL.ViewXY.AxisLayout.YAxisTitleAutoPlacement = false;
|
|
|
|
LChartALL.ViewXY.AxisLayout.YAxisTitleAutoPlacement = false;
|
|
|
|
LChartALL.ViewXY.AxisLayout.AutoAdjustMargins = false;
|
|
|
|
LChartALL.ViewXY.AxisLayout.AutoAdjustMargins = false;
|
|
|
|
|
|
|
|
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.DevicePrimaryButtonAction = UserInteractiveDeviceButtonAction.None;
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.DevicePrimaryButtonAction = UserInteractiveDeviceButtonAction.Pan;
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.DeviceSecondaryButtonAction = UserInteractiveDeviceButtonAction.None;
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.DeviceSecondaryButtonAction = UserInteractiveDeviceButtonAction.None;
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.WheelZooming = WheelZooming.Off;
|
|
|
|
LChartALL.ViewXY.ZoomPanOptions.WheelZooming = WheelZooming.Horizontal;
|
|
|
|
// 反锯齿系数。值0和1都不会应用反锯齿
|
|
|
|
// 反锯齿系数。值0和1都不会应用反锯齿
|
|
|
|
LChartALL.ChartRenderOptions.AntiAliasLevel = 0;
|
|
|
|
LChartALL.ChartRenderOptions.AntiAliasLevel = 0;
|
|
|
|
//X轴设置
|
|
|
|
//X轴设置
|
|
|
|
LChartALL.ViewXY.XAxes[0].AllowScrolling = false;
|
|
|
|
LChartALL.ViewXY.XAxes[0].AllowScrolling = true;
|
|
|
|
LChartALL.ViewXY.XAxes[0].PanningEnabled = false;
|
|
|
|
LChartALL.ViewXY.XAxes[0].PanningEnabled = true;
|
|
|
|
LChartALL.ViewXY.XAxes[0].MajorGrid.Pattern = LinePattern.Solid;
|
|
|
|
LChartALL.ViewXY.XAxes[0].MajorGrid.Pattern = LinePattern.Solid;
|
|
|
|
LChartALL.ViewXY.XAxes[0].ValueType = AxisValueType.DateTime;
|
|
|
|
LChartALL.ViewXY.XAxes[0].ValueType = AxisValueType.DateTime;
|
|
|
|
LChartALL.ViewXY.XAxes[0].KeepDivCountOnRangeChange = true;
|
|
|
|
LChartALL.ViewXY.XAxes[0].KeepDivCountOnRangeChange = true;
|
|
|
@ -435,10 +481,14 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
ViewXY v = LChartALL.ViewXY;
|
|
|
|
ViewXY v = LChartALL.ViewXY;
|
|
|
|
LChartALL.SizeChanged -= LChartALL_SizeChanged;
|
|
|
|
LChartALL.SizeChanged -= LChartALL_SizeChanged;
|
|
|
|
LChartALL.SizeChanged += LChartALL_SizeChanged;
|
|
|
|
LChartALL.SizeChanged += LChartALL_SizeChanged;
|
|
|
|
|
|
|
|
LChartALL.ViewXY.Zoomed -= ViewXY_Zoomed;
|
|
|
|
|
|
|
|
LChartALL.ViewXY.Zoomed += ViewXY_Zoomed;
|
|
|
|
|
|
|
|
LChartALL.ViewXY.Panned -= ViewXY_Panned;
|
|
|
|
|
|
|
|
LChartALL.ViewXY.Panned += ViewXY_Panned;
|
|
|
|
DisposeAllAndClear(v.YAxes);
|
|
|
|
DisposeAllAndClear(v.YAxes);
|
|
|
|
DisposeAllAndClear(v.SampleDataSeries);
|
|
|
|
DisposeAllAndClear(v.SampleDataSeries);
|
|
|
|
DisposeAllAndClear(v.LineCollections);
|
|
|
|
DisposeAllAndClear(v.LineCollections);
|
|
|
|
v.Margins=new Thickness(80, 30, 50, 60);
|
|
|
|
v.Margins=new Thickness(60, 30, 60, 60);
|
|
|
|
|
|
|
|
|
|
|
|
v.YAxes.AddRange(_wavesModel.CreateYAxisChart(smList.ToList(), LChartALL));
|
|
|
|
v.YAxes.AddRange(_wavesModel.CreateYAxisChart(smList.ToList(), LChartALL));
|
|
|
|
v.LegendBoxes[0].Position = LegendBoxPositionXY.RightCenter;
|
|
|
|
v.LegendBoxes[0].Position = LegendBoxPositionXY.RightCenter;
|
|
|
@ -520,16 +570,33 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void ViewXY_Panned(object sender, PannedXYEventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach (var item in LChartALL.ViewXY.LineCollections)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
double b = LChartALL.ViewXY.XAxes[0].ValueToCoordD(item.Lines[0].AX) - 80;
|
|
|
|
|
|
|
|
item.Title.Offset.SetValues((int)b, 3);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void ViewXY_Zoomed(object sender, ZoomedXYEventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach (var item in LChartALL.ViewXY.LineCollections)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
double b = LChartALL.ViewXY.XAxes[0].ValueToCoordD(item.Lines[0].AX) - 80;
|
|
|
|
|
|
|
|
item.Title.Offset.SetValues((int)b, 3);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LChartALL_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
|
private void LChartALL_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
int distancetoX = _wavesModel.SetYasixPlacement(LChartALL);
|
|
|
|
foreach (var item in LChartALL.ViewXY.YAxes)
|
|
|
|
foreach (var item in LChartALL.ViewXY.YAxes)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//更新标题坐标
|
|
|
|
item.Title.DistanceToAxis = distancetoX;
|
|
|
|
item.Title.DistanceToAxis = -(int)e.NewSize.Width+80;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach (var item in LChartALL.ViewXY.LineCollections)
|
|
|
|
foreach (var item in LChartALL.ViewXY.LineCollections)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
double b = LChartALL.ViewXY.XAxes[0].ValueToCoordD(item.Lines[0].AX)-80;
|
|
|
|
double b = LChartALL.ViewXY.XAxes[0].ValueToCoordD(item.Lines[0].AX)-80;
|
|
|
|
item.Title.Offset.SetValues((int)b, 3);
|
|
|
|
item.Title.Offset.SetValues((int)b, 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -550,7 +617,6 @@ namespace mseedChart.MainModule.ViewModels
|
|
|
|
_dispatcher.Invoke(() =>
|
|
|
|
_dispatcher.Invoke(() =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LChartALL.BeginUpdate();
|
|
|
|
LChartALL.BeginUpdate();
|
|
|
|
_wavesModel.CreateAxisYEventTime(CurrentEventTime, LChartALL.ViewXY, smList.ToList());
|
|
|
|
|
|
|
|
for (int channelIndex = 0; channelIndex < _channelCount; channelIndex++)
|
|
|
|
for (int channelIndex = 0; channelIndex < _channelCount; channelIndex++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LChartALL.ViewXY.SampleDataSeries[channelIndex].AddSamples(_data[channelIndex], true);
|
|
|
|
LChartALL.ViewXY.SampleDataSeries[channelIndex].AddSamples(_data[channelIndex], true);
|
|
|
|