/// <summary> /// Occurs when an input device begins a manipulation on the plot. /// </summary> /// <param name="e">The <see cref="OxyPlot.OxyMouseEventArgs" /> instance containing the event data.</param> public override void Started(OxyMouseEventArgs e) { base.Started(e); this.currentSeries = this.PlotView.ActualModel != null?this.PlotView.ActualModel.GetSeriesFromPoint(e.Position) : null; this.Delta(e); }
/// <summary> /// Gets the nearest tracker hit. /// </summary> /// <param name="s"> /// The series. /// </param> /// <param name="point"> /// The point. /// </param> /// <param name="snap"> /// Snap to points. /// </param> /// <param name="pointsOnly"> /// Check points only (no interpolation). /// </param> /// <returns> /// A tracker hit result. /// </returns> private static TrackerHitResult GetNearestHit(ITrackableSeries s, ScreenPoint point, bool snap, bool pointsOnly) { if (s == null) { return(null); } // Check data points only if (snap || pointsOnly) { TrackerHitResult result = s.GetNearestPoint(point, false); if (result != null) { if (result.Position.DistanceTo(point) < 20) { return(result); } } } // Check between data points (if possible) if (!pointsOnly) { TrackerHitResult result = s.GetNearestPoint(point, true); return(result); } return(null); }
/// <summary> /// Occurs when a manipulation is complete. /// </summary> /// <param name="e">The <see cref="OxyPlot.OxyMouseEventArgs" /> instance containing the event data.</param> public override void Completed(OxyMouseEventArgs e) { base.Completed(e); this.currentSeries = null; this.PlotView.HideTracker(); if (this.PlotView.ActualModel != null) { this.PlotView.ActualModel.OnTrackerChanged(null); } }
/// <summary> /// Occurs when a manipulation is complete. /// </summary> /// <param name="e"> /// The <see cref="OxyPlot.ManipulationEventArgs"/> instance containing the event data. /// </param> public override void Completed(ManipulationEventArgs e) { base.Completed(e); if (this.currentSeries == null) { return; } this.currentSeries = null; this.PlotControl.HideTracker(); }
/// <summary> /// Occurs when the input device changes position during a manipulation. /// </summary> /// <param name="e">The <see cref="OxyPlot.OxyMouseEventArgs" /> instance containing the event data.</param> public override void Delta(OxyMouseEventArgs e) { base.Delta(e); if (this.currentSeries == null || !this.LockToInitialSeries) { // get the nearest this.currentSeries = this.PlotView.ActualModel != null?this.PlotView.ActualModel.GetSeriesFromPoint(e.Position, 20) : null; } if (this.currentSeries == null) { if (!this.LockToInitialSeries) { this.PlotView.HideTracker(); } return; } var actualModel = this.PlotView.ActualModel; if (actualModel == null) { return; } if (!actualModel.PlotArea.Contains(e.Position.X, e.Position.Y)) { return; } var result = GetNearestHit(this.currentSeries, e.Position, this.Snap, this.PointsOnly); if (result != null) { result.PlotModel = this.PlotView.ActualModel; this.PlotView.ShowTracker(result); this.PlotView.ActualModel.OnTrackerChanged(result); } }
/// <summary> /// Occurs when the input device changes position during a manipulation. /// </summary> /// <param name="e">The <see cref="OxyPlot.OxyMouseEventArgs" /> instance containing the event data.</param> public override void Delta(OxyMouseEventArgs e) { base.Delta(e); if (this.currentSeries == null || !this.LockToInitialSeries) { // get the nearest this.currentSeries = this.PlotView.ActualModel != null ? this.PlotView.ActualModel.GetSeriesFromPoint(e.Position, 20) : null; } if (this.currentSeries == null) { if (!this.LockToInitialSeries) { this.PlotView.HideTracker(); } return; } var actualModel = this.PlotView.ActualModel; if (actualModel == null) { return; } if (!actualModel.PlotArea.Contains(e.Position.X, e.Position.Y)) { return; } var result = GetNearestHit(this.currentSeries, e.Position, this.Snap, this.PointsOnly); if (result != null) { result.PlotModel = this.PlotView.ActualModel; this.PlotView.ShowTracker(result); this.PlotView.ActualModel.OnTrackerChanged(result); } }
/// <summary> /// Gets the nearest tracker hit. /// </summary> /// <param name="s">The series.</param> /// <param name="point">The point.</param> /// <param name="snap">Snap to points.</param> /// <param name="pointsOnly">Check points only (no interpolation).</param> /// <returns>A tracker hit result.</returns> private static TrackerHitResult GetNearestHit(ITrackableSeries s, ScreenPoint point, bool snap, bool pointsOnly) { if (s == null) { return null; } // Check data points only if (snap || pointsOnly) { var result = s.GetNearestPoint(point, false); if (result != null) { if (result.Position.DistanceTo(point) < 20) { return result; } } } // Check between data points (if possible) if (!pointsOnly) { var result = s.GetNearestPoint(point, true); return result; } return null; }
/// <summary> /// Occurs when an input device begins a manipulation on the plot. /// </summary> /// <param name="e">The <see cref="OxyPlot.OxyMouseEventArgs" /> instance containing the event data.</param> public override void Started(OxyMouseEventArgs e) { base.Started(e); this.currentSeries = this.PlotView.ActualModel != null ? this.PlotView.ActualModel.GetSeriesFromPoint(e.Position) : null; this.Delta(e); }
/// <summary> /// Occurs when an input device begins a manipulation on the plot. /// </summary> /// <param name="e"> /// The <see cref="OxyPlot.ManipulationEventArgs"/> instance containing the event data. /// </param> public override void Started(ManipulationEventArgs e) { base.Started(e); this.currentSeries = this.PlotControl.GetSeriesFromPoint(e.CurrentPosition); this.Delta(e); }