当前位置: 首页>>代码示例>>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;未经允许,请勿转载。