//dont hit test, these are just overlay graphics
 protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
 {
     if (IsHitTestVisible)
         return base.HitTestCore(hitTestParameters);
     else
         return null;
 }
        protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            if (IsClone)
            {
                var source = (BitmapSource)Source;

                // Get the pixel of the source that was hit
                var x = (int)(hitTestParameters.HitPoint.X / ActualWidth * source.PixelWidth);
                var y = (int)(hitTestParameters.HitPoint.Y / ActualHeight * source.PixelHeight);

                // Copy the single pixel into a new byte array representing RGBA
                var pixel = new byte[4];
                try
                {
                    source.CopyPixels(new Int32Rect(x, y, 1, 1), pixel, 4, 0);
                }
                catch { }

                // Check the alpha (transparency) of the pixel
                // - threshold can be adjusted from 0 to 255
                if (pixel[3] < 10)
                    return null;
                return new PointHitTestResult(this, hitTestParameters.HitPoint);
            }

            return base.HitTestCore(hitTestParameters);
            //return new PointHitTestResult(this, hitTestParameters.HitPoint);
        }
 protected override HitTestResult HitTestCore(PointHitTestParameters htp)
 {
     var htr = base.HitTestCore(htp);
     if (htr == null)
         htr = new PointHitTestResult(this, htp.HitPoint);
     return htr;
 }
        protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            // Hit if within bounding box

            Point pt = hitTestParameters.HitPoint;

            return new PointHitTestResult(this, pt);
        }
 /// <summary>
 /// Performs a hit test to determine whether the specified 
 /// points are within the bounds of this ScrollViewer
 /// </summary>
 /// <returns>The result of the hit test</returns>
 /// <param name="hitTestParameters">The parameters for hit testing within a visual object</param>
 protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
 {
     if (this.VisualChildrenCount > 0)
     {
         return VisualTreeHelper.HitTest(this.GetVisualChild(0), hitTestParameters.HitPoint);
     }
     return base.HitTestCore(hitTestParameters);
 }
Example #6
0
        /// <summary>
        /// Ensures that a HitTestResult is only returned for the right half of the Canvas.
        /// </summary>
        /// <param name="hitTestParameters">The HitTestParameters.</param>
        /// <returns>The PointHitTestResult, if the hit was over the right half of the Canvas,
        /// null otherwise.</returns>
        protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            Point hitPoint = hitTestParameters.HitPoint;
            if (hitPoint.X > ActualWidth / 2)
                return new PointHitTestResult(this, hitPoint);

            return null;
        }
        protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            var alpha = GetAlphaColor(hitTestParameters.HitPoint);
            if (alpha == 0)
                return null;

            return base.HitTestCore(hitTestParameters);
        }
 protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
 {
     // accept clicks even when clicking on the background
     if (TextView != null && subbed == false) {
         subbed = true;
         TextView.ScrollOffsetChanged += TextView_ScrollOffsetChanged;
     }
     return new PointHitTestResult(this, hitTestParameters.HitPoint);
 }
Example #9
0
        protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            if (VisualTreeHelper.GetDescendantBounds(this).Contains(hitTestParameters.HitPoint))
            {
                return new PointHitTestResult(this, hitTestParameters.HitPoint);
            }

            return null;
        }
        public void SelectItemAt(Point pt)
        {
            PointHitTestParameters param = new PointHitTestParameters(pt);

            VisualTreeHelper.HitTest(this._hitTestRoot,
                                     this.SelectHitTestFilter,
                                     this.SelectHitTestResult,
                                     param);
        }
Example #11
0
        //----------------------------------------------------------------------
        //
        //  Protected Methods
        //
        //----------------------------------------------------------------------

        #region Protected Methods

        /// <summary>
        /// HitTestCore
        /// </summary>
        protected override HitTestResult HitTestCore(
            PointHitTestParameters hitTestParameters)
        {
            //
            // HostVisual never reports itself as being hit. To change this
            // behavior clients should derive from HostVisual and override
            // HitTestCore methods.
            //
            return(null);
        }
Example #12
0
        //----------------------------------------------------------------------
        //
        //  Protected Methods
        //
        //----------------------------------------------------------------------

        #region Protected Methods

        /// <summary>
        /// HitTestCore
        /// </summary>
        protected override HitTestResult HitTestCore(
            PointHitTestParameters hitTestParameters)
        {
            //
            // HostVisual never reports itself as being hit. To change this
            // behavior clients should derive from HostVisual and override
            // HitTestCore methods.
            //
            return null;
        }
        public void HitTest(object sender, System.Windows.Input.MouseButtonEventArgs args)
        {
            Point mouseposition = args.GetPosition(myViewport);
            Point3D testpoint3D = new Point3D(mouseposition.X, mouseposition.Y, 0);
            Vector3D testdirection = new Vector3D(mouseposition.X, mouseposition.Y, 10);
            PointHitTestParameters pointparams = new PointHitTestParameters(mouseposition);
            RayHitTestParameters rayparams = new RayHitTestParameters(testpoint3D, testdirection);

            //test for a result in the Viewport3D
            VisualTreeHelper.HitTest(myViewport, null, HTResult, pointparams);
            UpdateTestPointInfo(testpoint3D, testdirection);
        }
        /// <summary>
        /// HitTestCore implements precise hit testing against render contents
        /// </summary>
        protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            if (hitTestParameters == null)
            {
                throw new ArgumentNullException("hitTestParameters");
            }

            if (_content != null)
            {
                if (_content.HitTestPoint(hitTestParameters.HitPoint))
                {
                    return(new PointHitTestResult(this, hitTestParameters.HitPoint));
                }
            }

            return(null);
        }
Example #15
0
        /// <summary>
        /// HitTestCore implements precise hit testing against render contents
        /// </summary>
        protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            if (hitTestParameters == null)
            {
                throw new ArgumentNullException("hitTestParameters");
            }

            if (_content != null)
            {                
                if (_content.HitTestPoint(hitTestParameters.HitPoint))
                {
                    return new PointHitTestResult(this, hitTestParameters.HitPoint);
                }
            }

            return null;
        }
Example #16
0
        protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            var source = (BitmapSource)Source;

            // Get the pixel of the source that was hit
            var x = (int)(hitTestParameters.HitPoint.X / ActualWidth * source.PixelWidth);
            var y = (int)(hitTestParameters.HitPoint.Y / ActualHeight * source.PixelHeight);

            if (x == source.PixelWidth) x--;
            if (y == source.PixelHeight) y--;

            var pixel = GetPixels(source)[x, y];

            if (pixel.Alpha < 5)
                return null;

            return new PointHitTestResult(this, hitTestParameters.HitPoint);
        }
Example #17
0
 protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
 {
     try {
         // Get value of current pixel
         var source = (BitmapSource) Source;
         var x = (int) (hitTestParameters.HitPoint.X/ActualWidth*source.PixelWidth);
         var y = (int) (hitTestParameters.HitPoint.Y/ActualHeight*source.PixelHeight);
         var pixels = new byte[4];
         source.CopyPixels(new Int32Rect(x, y, 1, 1), pixels, 4, 0);
         // Check alpha channel
         if (pixels[3] > 10) {
             return new PointHitTestResult(this, hitTestParameters.HitPoint);
         }
         else {
             return null;
         }
     }
     catch {
         return new PointHitTestResult(this, hitTestParameters.HitPoint);
     }
 }
Example #18
0
        protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            var source = new FormatConvertedBitmap((BitmapSource) Source, PixelFormats.Bgra32, null, 0);

            // Get the pixel of the source that was hit
            var x = (int)(hitTestParameters.HitPoint.X / ActualWidth * source.PixelWidth);
            var y = (int)(hitTestParameters.HitPoint.Y / ActualHeight * source.PixelHeight);

            if (x == source.PixelWidth) x--;
            if (y == source.PixelHeight) y--;

            var pixelxy = new Int32Rect(x, y, 1, 1);
            var pixelbgra = new byte[4];

            source.CopyPixels(pixelxy, pixelbgra, source.PixelWidth * 4, 0);

            if (pixelbgra[3] < 5)
                return null;

            return new PointHitTestResult(this, hitTestParameters.HitPoint);
        }
Example #19
0
 protected override HitTestResult HitTestCore( PointHitTestParameters hitTestParameters )
 {
     return IsHitTestVisible ? base.HitTestCore( hitTestParameters ) : null;
 }
 protected virtual new HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
 {
     return(default(HitTestResult));
 }
Example #21
0
        private DependencyObject ElementUnderMouseCursor(Point mouseCursor)
        {
            hitResultsList.Clear();
            var hitParams = new PointHitTestParameters(mouseCursor);
            VisualTreeHelper.HitTest(this, null,
                new HitTestResultCallback(DirectHitTestCallback),
                new PointHitTestParameters(mouseCursor));

            return ((hitResultsList.Count > 0) ? hitResultsList[0] : null);
        }
Example #22
0
 protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
 {
     return new PointHitTestResult(this, hitTestParameters.HitPoint);
 }
Example #23
0
		/// <inheritdoc/>
		protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
		{
			// accept clicks even when clicking on the background
			return new PointHitTestResult(this, hitTestParameters.HitPoint);
		}
 protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
 {
     return(default(HitTestResult));
 }
Example #25
0
 protected override Wpf.HitTestResult HitTestCore(Wpf.PointHitTestParameters hitTestParameters)
 {
     return(new Wpf.PointHitTestResult(this, hitTestParameters.HitPoint));
 }
Example #26
0
        /// <summary>
        /// HitTestCore implements precise hit testing against render contents
        /// </summary>
        protected sealed override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            VerifyReentrancy();

            if (hitTestParameters == null)
            {
                throw new ArgumentNullException("hitTestParameters");
            }

            Rect r = new Rect(new Point(), RenderSize);

            if (r.Contains(hitTestParameters.HitPoint))
            {
                return new PointHitTestResult(this, hitTestParameters.HitPoint);
            }
            return null;
        }
Example #27
0
        private void Viewport_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point mousePos = e.GetPosition(_Viewport);
            PointHitTestParameters pointparams = new PointHitTestParameters(mousePos);

            _PieceRightClicked = null;
            VisualTreeHelper.HitTest(_Viewport, null, HTResult, pointparams);
            _PieceRightClicked = _PieceHit;
        }
        /// <summary>
        /// Get a joint from a mouse Position
        /// </summary>
        /// <param name="mousePosition">Mouse Position</param>
        private void GetJoint(Point mousePosition)
        {
            PointHitTestParameters pointparams = new PointHitTestParameters(mousePosition);

            VisualTreeHelper.HitTest(Session.CurrentSession.Viewport, null, HTResult, pointparams);
        }
Example #29
0
 protected override System.Windows.Media.HitTestResult HitTestCore(System.Windows.Media.PointHitTestParameters hitTestParameters)
 {
     return(new PointHitTestResult(this, hitTestParameters.HitPoint));
 }
Example #30
0
 protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters) {
     return null;
 }
Example #31
0
        /// <summary>
        /// HitTestCore implements whether we have hit the bounds of this visual.
        /// </summary>
        protected virtual HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            if (hitTestParameters == null)
            {
                throw new ArgumentNullException("hitTestParameters");
            }

            // If we don't have a clip, or if the clip contains the point, keep going.
            if (GetHitTestBounds().Contains(hitTestParameters.HitPoint))
            {
                return new PointHitTestResult(this, hitTestParameters.HitPoint);
            }
            else
            {
                return null;
            }
        }
Example #32
0
		/// <inheritdoc/>
		protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
		{
			// accept clicks even where the text area draws no background
			return new PointHitTestResult(this, hitTestParameters.HitPoint);
		}
Example #33
0
 // HitTestCore override not to hit testable Caret.
 protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
 { 
     // Return null not to hit testable for CaretElement.
     return null; 
 } 
Example #34
0
        private void Viewport_MouseMove(object obj, MouseEventArgs e)
        {
            Point mousePos = e.GetPosition(_Viewport);
            PointHitTestParameters pointparams = new PointHitTestParameters(mousePos);

            _RayDistance = double.MaxValue;
            _PieceHit = null;
            VisualTreeHelper.HitTest(_Viewport, null, HTResult, pointparams);
            if (_PieceHit != null)
                OnMouseOver(_PieceHit);
        }
Example #35
0
        /// <summary>
        /// This method provides an internal extension point for Viewport3DVisual
        /// to grab the HitTestFilterCallback and ResultDelegate before it gets lost in the
        /// forward to HitTestCore.
        /// </summary>
        internal virtual HitTestResultBehavior HitTestPointInternal(
            HitTestFilterCallback filterCallback,
            HitTestResultCallback resultCallback,
            PointHitTestParameters hitTestParameters)
        {
            HitTestResult hitResult = HitTestCore(hitTestParameters);

            if (hitResult != null)
            {
                return resultCallback(hitResult);
            }

            return HitTestResultBehavior.Continue;
        }
Example #36
0
        private void Viewport_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (_PieceRightClicked != null)
            {
                Point mousePos = e.GetPosition(_Viewport);
                PointHitTestParameters pointparams = new PointHitTestParameters(mousePos);

                VisualTreeHelper.HitTest(_Viewport, null, HTResult, pointparams);
                if (_PieceRightClicked.Equals(_PieceHit))
                    OnRightClick(_PieceRightClicked);
                _PieceRightClicked = null;
            }
        }
Example #37
0
 protected virtual HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
 {
     throw new NotImplementedException();
 }