예제 #1
0
 /// <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);
         }
     }
 }
예제 #2
0
파일: Model.cs 프로젝트: Keyabob/MMG
 /// <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;
         }
     }
 }
예제 #3
0
        /// <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);
                }
            }
        }
예제 #4
0
        /// <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);
            }
        }
예제 #5
0
        /// <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;
                }
            }
        }
예제 #6
0
        /// <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);
        }
예제 #8
0
 /// <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));
 }
예제 #9
0
 /// <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);
 }
예제 #10
0
        /// <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);
            }
        }
예제 #11
0
        /// <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);
            }
        }
예제 #12
0
 protected override HitTestResult HitTestOverride(HitTestArguments args) {
     return Points.Count < 2 ? null : base.HitTestOverride(args);
 }
예제 #13
0
 /// <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);
 }
예제 #14
0
 /// <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;
 }