/// <summary> /// Returns the elements that are hit at the specified position. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// A sequence of hit results. /// </returns> public IEnumerable <HitTestResult> HitTest(HitTestArguments args) { foreach (var element in this.GetHitTestElements()) { var result = element.HitTest(args); if (result != null) { yield return(result); } } }
/// <summary> /// Returns the elements that are hit at the specified position. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// A sequence of hit results. /// </returns> public IEnumerable<HitTestResult> HitTest(HitTestArguments args) { foreach (var element in this.GetHitTestElements()) { var result = element.HitTest(args); if (result != null) { yield return result; } } }
/// <summary> /// Returns the elements that are hit at the specified position. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// A sequence of hit results. /// </returns> public IEnumerable <HitTestResult> HitTest(HitTestArguments args) { // Revert the order to handle the top-level elements first foreach (var element in this.GetElements().Reverse()) { var uiElement = element as UIElement; if (uiElement == null) { continue; } var result = uiElement.HitTest(args); if (result != null) { yield return(result); } } }
/// <summary> /// Handles the touch started event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">A <see cref="OxyPlot.OxyTouchEventArgs" /> instance containing the event data.</param> public virtual void HandleTouchStarted(object sender, OxyTouchEventArgs e) { var args = new HitTestArguments(e.Position, MouseHitTolerance); foreach (var result in this.HitTest(args)) { result.Element.OnTouchStarted(e); if (e.Handled) { this.currentTouchEventElement = result.Element; return; } } if (!e.Handled) { this.OnTouchStarted(sender, e); } }
/// <summary> /// Returns the elements that are hit at the specified position. /// </summary> /// <param name="args">The hit test arguments.</param> /// <returns> /// A sequence of hit results. /// </returns> public IEnumerable<HitTestResult> HitTest(HitTestArguments args) { // Revert the order to handle the top-level elements first foreach (var element in this.GetElements().Reverse()) { var uiElement = element as UIElement; if (uiElement == null) { continue; } var result = uiElement.HitTest(args); if (result != null) { yield return result; } } }
/// <summary> /// Handles the mouse down event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="OxyPlot.OxyMouseEventArgs" /> instance containing the event data.</param> public virtual void HandleMouseDown(object sender, OxyMouseDownEventArgs e) { var args = new HitTestArguments(e.Position, MouseHitTolerance); foreach (var result in this.HitTest(args)) { e.HitTestResult = result; result.Element.OnMouseDown(e); if (e.Handled) { this.currentMouseEventElement = result.Element; return; } } if (!e.Handled) { this.OnMouseDown(sender, e); } }
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> /// 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 virtual HitTestResult HitTestOverride(HitTestArguments args) { return(null); }
protected override HitTestResult HitTestOverride(HitTestArguments args) { return Points.Count < 2 ? null : base.HitTestOverride(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 virtual HitTestResult HitTestOverride(HitTestArguments args) { return null; }