private void ViewModel_SignalShowChanged(SignalToken signalToken) { var series = _chart.ViewXY.PointLineSeries.Where(p => p.Tag == signalToken).FirstOrDefault(); if (series != null) { series.Visible = !series.Visible; } }
private void Token_LimitChanged(SignalToken token) { var axisY = _chart.ViewXY.YAxes.Where(o => o.Tag == token).SingleOrDefault(); if (axisY != null) { axisY.RangeChanged -= AxisY_RangeChanged; axisY.Maximum = token.UpperLimit; axisY.Minimum = token.LowerLimit; axisY.RangeChanged += AxisY_RangeChanged; } }
/// <summary> /// Sendet eine leere Anfrage zum Wechsel der Quellgruppe. Diese kann von allen Aktionen /// verwendet werden, um interne Zustände zu (re-)initialisieren. /// </summary> /// <param name="disableDecryptionReset">Gesetzt, um die Neuinitialisierung der Entschlüsselung /// zu deaktivieren.</param> private void SendEmptyTuneRequest(bool disableDecryptionReset = false) { // Process using (var tune = TuneToken.Create(TunePipeline, null, null)) tune.Execute(); if (!disableDecryptionReset) { using (var crypt = DecryptToken.Create(DecryptionPipeline, null)) crypt.Execute(); } using (var sig = SignalToken.Create(SignalPipeline)) sig.Execute(); // Reset m_currentDecryption = s_NoSources; }
private void ViewModel_SignalRemoved(SignalToken token) { try { _chart.BeginUpdate(); var series = _chart.ViewXY.PointLineSeries.Where(o => o.Tag == token).SingleOrDefault(); if (series != null) { series.Clear(); _chart.ViewXY.PointLineSeries.Remove(series); } var axisY = _chart.ViewXY.YAxes.Where(o => o.Tag == token).SingleOrDefault(); if (axisY != null) { _chart.ViewXY.YAxes.Remove(axisY); if (_chart.ViewXY.YAxes.Count > 0) { _chart.ViewXY.Annotations[0].AssignYAxisIndex = -1; _chart.ViewXY.Annotations[0].AssignYAxisIndex = 0; AnnotationXY cursorValueDisplay = _chart.ViewXY.Annotations[0]; float fTargetYCoord = _chart.ViewXY.GetMarginsRect().Bottom; double dY; _chart.ViewXY.YAxes[0].CoordToValue(fTargetYCoord, out dY); cursorValueDisplay.TargetAxisValues.Y = dY; } else { AxisY axisYnone = new AxisY(_chart.ViewXY); axisYnone.Title.Font = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 10, System.Drawing.FontStyle.Regular); axisYnone.AxisThickness = 2; axisYnone.AxisColor = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238); axisYnone.Units.Text = "none"; _chart.ViewXY.YAxes.Add(axisYnone); } } _chart.EndUpdate(); } catch (Exception ex) { EventAggregatorService.Instance.EventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("趋势趋势-移除信号", ex)); _chart.EndUpdate(); } }
private void ViewModel_SignalSelected(SignalToken signalToken) { var series = _chart.ViewXY.PointLineSeries.Where(p => p.Tag == signalToken).FirstOrDefault(); if (series != null) { series.SetHighlight(); } _chart.ViewXY.PointLineSeries.ForEach(p => { if (p.Tag == signalToken) { p.MouseHighlight = MouseOverHighlight.Simple; } else { p.MouseHighlight = MouseOverHighlight.None; } }); }
private void ViewModel_SignalAdded(SignalToken token, DateTime time, double size) { try { _chart.BeginUpdate(); var axisYnone = _chart.ViewXY.YAxes.Where(o => o.Units.Text == "none").SingleOrDefault(); _chart.ViewXY.YAxes.Remove(axisYnone); #region AxisY axisY = new AxisY(_chart.ViewXY); if (token is BaseDivfreSignalToken) { var vToken = token as BaseDivfreSignalToken; string unit = (vToken.DataContracts == null || vToken.DataContracts.Count == 0 || vToken.DataContracts[0].Unit == null) ? "" : vToken.DataContracts[0].Unit; axisY.Title.Font = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 10, System.Drawing.FontStyle.Regular); axisY.AxisThickness = 2; axisY.AxisColor = vToken.SolidColorBrush.Color;//Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238); axisY.Title.Text = vToken.DisplayName + "(" + unit + ")"; axisY.SetRange(0, 10); axisY.Tag = token; _chart.ViewXY.YAxes.Add(axisY); if (_chart.ViewXY.Annotations.Count == 0) { CreateAnnotation(); } PointLineSeries series = new PointLineSeries(_chart.ViewXY, _chart.ViewXY.XAxes[0], axisY); series.MouseInteraction = false; series.Title.Text = vToken.DisplayName + "(" + unit + ")"; series.LineStyle.Color = token.SolidColorBrush.Color; series.Title.Color = token.SolidColorBrush.Color; series.LineStyle.AntiAliasing = LineAntialias.Normal; series.LineStyle.Width = 1; series.Tag = token; if (vToken.DataContracts != null)//加入数据 { SeriesPoint[] points = new SeriesPoint[vToken.DataContracts.Count]; for (int i = 0; i < points.Length; i++) { points[i].X = _chart.ViewXY.XAxes[0].DateTimeToAxisValue(vToken.DataContracts[i].ACQDatetime); points[i].Y = vToken.DataContracts[i].Result.Value; AddMarker(series, points[i], vToken.DataContracts[i].AlarmGrade); } series.Points = points; } _chart.ViewXY.PointLineSeries.Add(series); if (vToken.DataContracts != null) { axisY.Maximum = vToken.UpperLimit; axisY.Minimum = vToken.LowerLimit; } } #endregion #region else if (token is BaseAlarmSignalToken) { var anToken = token as BaseAlarmSignalToken; if (anToken.DataContracts != null) { string unit = (anToken.DataContracts == null || anToken.DataContracts.Count == 0 || anToken.DataContracts[0].Unit == null) ? "" : anToken.DataContracts[0].Unit; axisY.Title.Font = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 10, System.Drawing.FontStyle.Regular); axisY.AxisThickness = 2; axisY.AxisColor = anToken.SolidColorBrush.Color; //Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238); axisY.Title.Text = anToken.DisplayName + "(" + unit + ")"; axisY.SetRange(0, 10); axisY.Tag = token; _chart.ViewXY.YAxes.Add(axisY); if (_chart.ViewXY.Annotations.Count == 0) { CreateAnnotation(); } PointLineSeries series = new PointLineSeries(_chart.ViewXY, _chart.ViewXY.XAxes[0], axisY); series.MouseInteraction = false; series.Title.Text = anToken.DisplayName + "(" + unit + ")"; series.LineStyle.Color = token.SolidColorBrush.Color; series.Title.Color = token.SolidColorBrush.Color; series.LineStyle.AntiAliasing = LineAntialias.Normal; series.LineStyle.Width = 1; series.Tag = token; if (anToken.DataContracts != null) { SeriesPoint[] points = new SeriesPoint[anToken.DataContracts.Count]; for (int i = 0; i < points.Length; i++) { points[i].X = _chart.ViewXY.XAxes[0].DateTimeToAxisValue(anToken.DataContracts[i].ACQDatetime); points[i].Y = anToken.DataContracts[i].Result.Value; AddMarker(series, points[i], anToken.DataContracts[i].AlarmGrade); } series.Points = points; } _chart.ViewXY.PointLineSeries.Add(series); if (anToken.DataContracts != null) { axisY.Maximum = anToken.UpperLimit;; axisY.Minimum = anToken.LowerLimit;; } } } #endregion _chart.ViewXY.Annotations[0].AssignYAxisIndex = -1; _chart.ViewXY.Annotations[0].AssignYAxisIndex = 0; _chart.EndUpdate(); _chart.ViewXY.XAxes[0].SetRange(_chart.ViewXY.XAxes[0].DateTimeToAxisValue(time), _chart.ViewXY.XAxes[0].DateTimeToAxisValue(time.AddHours(size))); token.LimitChanged += Token_LimitChanged; axisY.RangeChanged += AxisY_RangeChanged; if (_chart.ViewXY.LineSeriesCursors[0].ValueAtXAxis <_chart.ViewXY.XAxes[0].Minimum || _chart.ViewXY.LineSeriesCursors[0].ValueAtXAxis> _chart.ViewXY.XAxes[0].Maximum) { _chart.ViewXY.LineSeriesCursors[0].ValueAtXAxis = (_chart.ViewXY.XAxes[0].Minimum + _chart.ViewXY.XAxes[0].Maximum) / 2.0; } else { UpdateCursorResult(_chart.ViewXY.LineSeriesCursors[0].ValueAtXAxis); } } catch (Exception ex) { EventAggregatorService.Instance.EventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("趋势-添加信号", ex)); _chart.EndUpdate(); } }