/// <summary> /// Called on mouse move events. /// </summary> /// <param name="args">An instance that contains the event data.</param> protected override void OnMouseMoved(MouseMovedEventArgs args) { base.OnMouseMoved(args); if (args.Handled) { return; } if (ShowDynamicTooltips) { string tooltip = null; var hitArgs = new HitTestArguments(new ScreenPoint(args.X, args.Y), MouseHitTolerance); foreach (var result in ActualModel.HitTest(hitArgs)) { var plotElement = result.Element as PlotElement; if (plotElement != null && !String.IsNullOrEmpty(plotElement.ToolTip)) { tooltip = String.IsNullOrEmpty(tooltip) ? plotElement.ToolTip : tooltip + Environment.NewLine + plotElement.ToolTip; } } TooltipText = tooltip; } args.Handled = ActualController.HandleMouseMove(this, args.ToOxyMouseEventArgs()); }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { if (screenRectangle.Contains(args.Point)) { return(new HitTestResult(this, args.Point)); } return(null); }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { if (this.actualBounds.Contains(args.Point)) { return(new HitTestResult(this, args.Point)); } return(null); }
protected override HitTestResult HitTestOverride(HitTestArguments args) { if (this.actualBounds == null) { return(null); } return(ScreenPointHelper.IsPointInPolygon(args.Point, this.actualBounds) ? new HitTestResult(this, args.Point) : null); }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { if (this.screenPosition.DistanceTo(args.Point) < this.Size) { return(new HitTestResult(this, this.screenPosition)); } return(null); }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { if (this.screenPoints == null) { // Points not specified. return(null); } return(ScreenPointHelper.IsPointInPolygon(args.Point, this.screenPoints) ? new HitTestResult(this, args.Point) : null); }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { if (this.actualBounds == null) { return(null); } // Todo: see if performance can be improved by checking rectangle (with rotation and alignment), not polygon return(ScreenPointHelper.IsPointInPolygon(args.Point, this.actualBounds) ? new HitTestResult(this, args.Point) : null); }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { var nearestPoint = ScreenPointHelper.FindNearestPointOnPolyline(args.Point, this.screenPoints); double dist = (args.Point - nearestPoint).Length; if (dist < args.Tolerance) { return(new HitTestResult(this, nearestPoint)); } return(null); }
public static Example ClickingOnAnAnnotation() { var plotModel = new PlotModel { Title = "Clicking on an annotation", Subtitle = "Click on the rectangles" }; plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom }); plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left }); var annotation1 = new RectangleAnnotation { Fill = OxyColors.Green, Text = "RectangleAnnotation 1", MinimumX = 25, MaximumX = 75, MinimumY = 20, MaximumY = 40 }; plotModel.Annotations.Add(annotation1); var annotation2 = new RectangleAnnotation { Fill = OxyColors.SkyBlue, Text = "RectangleAnnotation 2", MinimumX = 25, MaximumX = 75, MinimumY = 60, MaximumY = 80 }; plotModel.Annotations.Add(annotation2); EventHandler <OxyMouseDownEventArgs> handleMouseClick = (s, e) => { plotModel.Subtitle = "You clicked " + ((RectangleAnnotation)s).Text; plotModel.InvalidatePlot(false); }; annotation1.MouseDown += handleMouseClick; annotation2.MouseDown += handleMouseClick; var controller = new PlotController(); var handleClick = new DelegatePlotCommand <OxyMouseDownEventArgs>( (v, c, e) => { var args = new HitTestArguments(e.Position, 10); var firstHit = v.ActualModel.HitTest(args).FirstOrDefault(x => x.Element is RectangleAnnotation); if (firstHit != null) { e.Handled = true; plotModel.Subtitle = "You clicked " + ((RectangleAnnotation)firstHit.Element).Text; plotModel.InvalidatePlot(false); } }); controller.Bind(new OxyMouseDownGesture(OxyMouseButton.Left), handleClick); return(new Example(plotModel, controller)); }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { var thr = this.GetNearestPoint(args.Point, true) ?? this.GetNearestPoint(args.Point, false); if (thr != null) { double distance = thr.Position.DistanceTo(args.Point); if (distance > args.Tolerance) { return(null); } return(new HitTestResult(this, thr.Position, thr.Item, thr.Index)); } return(null); }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { if ((args.Point - this.screenStartPoint).Length < args.Tolerance) { return(new HitTestResult(this, this.screenStartPoint, null, 1)); } if ((args.Point - this.screenEndPoint).Length < args.Tolerance) { return(new HitTestResult(this, this.screenEndPoint, null, 2)); } var p = ScreenPointHelper.FindPointOnLine(args.Point, this.screenStartPoint, this.screenEndPoint); if ((p - args.Point).Length < args.Tolerance) { return(new HitTestResult(this, p)); } return(null); }
/// <summary> /// Override for legend hit test. /// </summary> /// <param name="args">Arguments passe to the hit test</param> /// <returns>The hit test results.</returns> protected override HitTestResult LegendHitTest(HitTestArguments args) { ScreenPoint point = args.Point; if (this.IsPointInLegend(point)) { if (this.SeriesPosMap != null && this.SeriesPosMap.Count > 0) { foreach (KeyValuePair <Series.Series, OxyRect> kvp in this.SeriesPosMap) { if (kvp.Value.Contains(point)) { kvp.Key.IsVisible = !kvp.Key.IsVisible; this.PlotModel.InvalidatePlot(false); break; } } } } return(null); }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { if (this.screenPoints == null) { // Points not specified. return null; } return ScreenPointHelper.IsPointInPolygon(args.Point, this.screenPoints) ? new HitTestResult(this, args.Point) : null; }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { var nearestPoint = ScreenPointHelper.FindNearestPointOnPolyline(args.Point, this.screenPoints); double dist = (args.Point - nearestPoint).Length; if (dist < args.Tolerance) { return new HitTestResult(this, nearestPoint); } return null; }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { if (this.screenRectangle.Contains(args.Point)) { return new HitTestResult(this, args.Point); } return null; }
/// <summary> /// Override for legend hit test. /// </summary> /// <param name="args">Arguments passe to the hit test</param> /// <returns>The hit test results.</returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { return(this.LegendHitTest(args)); }
/// <summary> /// Tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// A hit test result. /// </returns> public HitTestResult HitTest(HitTestArguments args) { return(this.HitTestOverride(args)); }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { if (this.actualBounds.Contains(args.Point)) { return new HitTestResult(this, args.Point); } return null; }
/// <summary> /// Called on mouse move events. /// </summary> /// <param name="args">An instance that contains the event data.</param> protected override void OnMouseMoved(MouseMovedEventArgs args) { base.OnMouseMoved(args); if (args.Handled) return; if (ShowDynamicTooltips) { string tooltip = null; var hitArgs = new HitTestArguments(new ScreenPoint(args.X, args.Y), MouseHitTolerance); foreach (var result in ActualModel.HitTest(hitArgs)) { var plotElement = result.Element as PlotElement; if (plotElement != null && !String.IsNullOrEmpty(plotElement.ToolTip)) { tooltip = String.IsNullOrEmpty(tooltip) ? plotElement.ToolTip : tooltip + Environment.NewLine + plotElement.ToolTip; } } TooltipText = tooltip; } args.Handled = ActualController.HandleMouseMove(this, args.ToOxyMouseEventArgs()); }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { var thr = this.GetNearestPoint(args.Point, true) ?? this.GetNearestPoint(args.Point, false); if (thr != null) { double distance = thr.Position.DistanceTo(args.Point); if (distance > args.Tolerance) { return null; } return new HitTestResult(this, thr.Position, thr.Item, thr.Index); } return null; }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { if (this.screenPosition.DistanceTo(args.Point) < this.Size) { return new HitTestResult(this, this.screenPosition); } return null; }
/// <summary> /// Defines the legend hit test behaviour. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns>The hit test result.</returns> protected abstract HitTestResult LegendHitTest(HitTestArguments args);
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { if (this.actualBounds == null) { return null; } // Todo: see if performance can be improved by checking rectangle (with rotation and alignment), not polygon return ScreenPointHelper.IsPointInPolygon(args.Point, this.actualBounds) ? new HitTestResult(this, args.Point) : null; }
/// <summary> /// Tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// A hit test result. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { return(null); }
/// <summary> /// Tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// A hit test result. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { return null; }
/// <summary> /// When overridden in a derived class, tests if the plot element is hit by the specified point. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// The result of the hit test. /// </returns> protected override HitTestResult HitTestOverride(HitTestArguments args) { if ((args.Point - this.screenStartPoint).Length < args.Tolerance) { return new HitTestResult(this, this.screenStartPoint, null, 1); } if ((args.Point - this.screenEndPoint).Length < args.Tolerance) { return new HitTestResult(this, this.screenEndPoint, null, 2); } var p = ScreenPointHelper.FindPointOnLine(args.Point, this.screenStartPoint, this.screenEndPoint); if ((p - args.Point).Length < args.Tolerance) { return new HitTestResult(this, p); } return null; }
protected override HitTestResult HitTestOverride(HitTestArguments args) { return(Points.Count < 2 ? null : base.HitTestOverride(args)); }