當前位置: 首頁>>代碼示例>>C#>>正文


C# Media.PointHitTestParameters類代碼示例

本文整理匯總了C#中System.Windows.Media.PointHitTestParameters的典型用法代碼示例。如果您正苦於以下問題:C# PointHitTestParameters類的具體用法?C# PointHitTestParameters怎麽用?C# PointHitTestParameters使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PointHitTestParameters類屬於System.Windows.Media命名空間,在下文中一共展示了PointHitTestParameters類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: HitTestCore

        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);
        }
開發者ID:steamprodz,項目名稱:DantistApp,代碼行數:28,代碼來源:OpaqueClickableImage.cs

示例2: HitTestCore

 protected override HitTestResult HitTestCore(PointHitTestParameters htp)
 {
     var htr = base.HitTestCore(htp);
     if (htr == null)
         htr = new PointHitTestResult(this, htp.HitPoint);
     return htr;
 }
開發者ID:hehaotian,項目名稱:igt-editor,代碼行數:7,代碼來源:ui-part-controls.xaml.cs

示例3: HitTestCore

 //dont hit test, these are just overlay graphics
 protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
 {
     if (IsHitTestVisible)
         return base.HitTestCore(hitTestParameters);
     else
         return null;
 }
開發者ID:legendmaker,項目名稱:Wpf,代碼行數:8,代碼來源:OverlayRenderDecorator.cs

示例4: HitTestCore

        protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            // Hit if within bounding box

            Point pt = hitTestParameters.HitPoint;

            return new PointHitTestResult(this, pt);
        }
開發者ID:csuffyy,項目名稱:circuitdiagram,代碼行數:8,代碼來源:CircuitElementDrawingVisual.cs

示例5: HitTestCore

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

            return base.HitTestCore(hitTestParameters);
        }
開發者ID:kakesu,項目名稱:Procurement,代碼行數:8,代碼來源:AlphaHittestedImage.cs

示例6: HitTestCore

        /// <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;
        }
開發者ID:HSchoenfelder,項目名稱:Petedit,代碼行數:14,代碼來源:PartialCanvas.cs

示例7: HitTestCore

 /// <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);
 }
開發者ID:fengyuqi,項目名稱:Fluent.Ribbon,代碼行數:14,代碼來源:RibbonScrollViewer.cs

示例8: HitTestCore

 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);
 }
開發者ID:nonconforme,項目名稱:UrhoAngelscriptIDE,代碼行數:9,代碼來源:BreakpointMargin.cs

示例9: SelectItemAt

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

            VisualTreeHelper.HitTest(this._hitTestRoot,
                                     this.SelectHitTestFilter,
                                     this.SelectHitTestResult,
                                     param);
        }
開發者ID:habs57,項目名稱:tablet-interaction,代碼行數:9,代碼來源:HitTestHelper.cs

示例10: HitTestCore

        protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
        {
            if (VisualTreeHelper.GetDescendantBounds(this).Contains(hitTestParameters.HitPoint))
            {
                return new PointHitTestResult(this, hitTestParameters.HitPoint);
            }

            return null;
        }
開發者ID:jonbonne,項目名稱:OCTGN,代碼行數:9,代碼來源:CardScroller.cs

示例11: HitTestCore

        //----------------------------------------------------------------------
        //
        //  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;
        }
開發者ID:JianwenSun,項目名稱:cc,代碼行數:21,代碼來源:HostVisual.cs

示例12: HitTest

        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);
        }
開發者ID:jayawantsawant,項目名稱:WPFSamples,代碼行數:12,代碼來源:MainWindow.xaml.cs

示例13: HitTestCore

        /// <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;
        }
開發者ID:JianwenSun,項目名稱:cc,代碼行數:20,代碼來源:DrawingVisual.cs

示例14: HitTestCore

        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);
        }
開發者ID:Gravecorp,項目名稱:OCTGN,代碼行數:18,代碼來源:OpaqueClickableImage.cs

示例15: HitTestCore

 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);
     }
 }
開發者ID:fatihboy,項目名稱:Robosapien,代碼行數:21,代碼來源:TransparentImage.cs


注:本文中的System.Windows.Media.PointHitTestParameters類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。