本文整理汇总了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);
}
示例2: HitTestCore
protected override HitTestResult HitTestCore(PointHitTestParameters htp)
{
var htr = base.HitTestCore(htp);
if (htr == null)
htr = new PointHitTestResult(this, htp.HitPoint);
return htr;
}
示例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;
}
示例4: HitTestCore
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
{
// Hit if within bounding box
Point pt = hitTestParameters.HitPoint;
return new PointHitTestResult(this, pt);
}
示例5: HitTestCore
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
{
var alpha = GetAlphaColor(hitTestParameters.HitPoint);
if (alpha == 0)
return null;
return base.HitTestCore(hitTestParameters);
}
示例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;
}
示例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);
}
示例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);
}
示例9: SelectItemAt
public void SelectItemAt(Point pt)
{
PointHitTestParameters param = new PointHitTestParameters(pt);
VisualTreeHelper.HitTest(this._hitTestRoot,
this.SelectHitTestFilter,
this.SelectHitTestResult,
param);
}
示例10: HitTestCore
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
{
if (VisualTreeHelper.GetDescendantBounds(this).Contains(hitTestParameters.HitPoint))
{
return new PointHitTestResult(this, hitTestParameters.HitPoint);
}
return null;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}