Поделиться через


Ink.HitTest - метод (Point, Single)

Обновлен: Ноябрь 2007

Returns the Strokes collection of Stroke objects that are either completely inside or intersected by a known circle.

Пространство имен:  Microsoft.Ink
Сборка:  Microsoft.Ink (в Microsoft.Ink.dll)

Синтаксис

'Декларация
Public Function HitTest ( _
    point As Point, _
    radius As Single _
) As Strokes
'Применение
Dim instance As Ink
Dim point As Point
Dim radius As Single
Dim returnValue As Strokes

returnValue = instance.HitTest(point, _
    radius)
public Strokes HitTest(
    Point point,
    float radius
)
public:
Strokes^ HitTest(
    Point point, 
    float radius
)
public Strokes HitTest(
    Point point,
    float radius
)
public function HitTest(
    point : Point, 
    radius : float
) : Strokes

Параметры

  • radius
    Тип: System.Single
    The radius of the hit test circle, in ink space coordinates.

Возвращаемое значение

Тип: Microsoft.Ink.Strokes
The Strokes collection contained within the specified area.

Заметки

If a Stroke object intersects the circle, the complete Stroke is returned.

This method computes the intersection, considering the full set of DrawingAttributes that apply to the Stroke object, including the Width, whether the FitToCurve property is true or false, and the value of the PenTip property.

After a rotation or shear transform has been performed on a Stroke object or a Strokes collection, the transformed x and y coordinates are no longer concentric with the original coordinates. Because of this, the radius parameter should not be calculated from the x or y coordinates.

To determine which points of a known Stroke object intersect the hit test area, call the Stroke.HitTest method.

Примеры

In this example, any Stroke objects of an InkOverlay that intersect a circle with its center point in the middle of the ink control, and a radius of 120 pixels are changed to red. The circle that a Stroke must intersect to qualify for the color change is drawn in blue.

Const RadiusPixel As Integer = 120
' get the control. InkOverlay.AttachedControl must be set
Dim inkControl As Control = mInkOverlay.AttachedControl
' get the center of the ink control
Dim centerPt As Point = New Point(inkControl.Width / 2, inkControl.Height / 2)
' create the rectangle used to draw the circle around the center
Dim hitTestRect As Rectangle = New Rectangle(centerPt.X - RadiusPixel, centerPt.Y - RadiusPixel, RadiusPixel * 2, RadiusPixel * 2)
' get our graphics object
Dim g As Graphics = inkControl.CreateGraphics()
' convert centerPt to ink space coordinates
mInkOverlay.Renderer.PixelToInkSpace(g, centerPt)
' tempPt is used only to convert RadiusPixel to ink coords
Dim tempPt As Point = New Point(RadiusPixel, 0)
mInkOverlay.Renderer.PixelToInkSpace(g, tempPt)
' now tempPt.X = radius in ink coordinates
' Find strokes hit by the circle described by centerPt and radius
Dim hitStrokes As Strokes = mInkOverlay.Ink.HitTest(centerPt, tempPt.X)
' change the strokes that fall inside the circle to red
hitStrokes.ModifyDrawingAttributes(New DrawingAttributes(Color.Red))
' invalidate the ink control
inkControl.Invalidate()
' let the Invalidate message process
Application.DoEvents()
' draw the circle we used for the hit test
g.DrawEllipse(Pens.Blue, hitTestRect)
g.Dispose()
const int RadiusPixel = 120;
// get the control. InkOverlay.AttachedControl must be set
Control inkControl = mInkOverlay.AttachedControl;
// get the center of the ink control
Point centerPt = new Point(inkControl.Width / 2, inkControl.Height / 2);
// create the rectangle used to draw the circle around the center
Rectangle hitTestRect = new Rectangle(centerPt.X - RadiusPixel, centerPt.Y - RadiusPixel, RadiusPixel * 2, RadiusPixel * 2);
// get our graphics object
Graphics g = inkControl.CreateGraphics();
// convert centerPt to ink space coordinates
mInkOverlay.Renderer.PixelToInkSpace(g, ref centerPt);
// tempPt is used only to convert RadiusPixel to ink coords
Point tempPt = new Point(RadiusPixel, 0);
mInkOverlay.Renderer.PixelToInkSpace(g, ref tempPt);
// now tempPt.X = radius in ink coordinates
// Find strokes hit by the circle described by centerPt and radius
Strokes hitStrokes = mInkOverlay.Ink.HitTest(centerPt, tempPt.X);
// change the strokes that fall inside the circle to red
hitStrokes.ModifyDrawingAttributes(new DrawingAttributes(Color.Red));
// invalidate the ink control
inkControl.Invalidate();
// let the Invalidate message process
Application.DoEvents();
// draw the circle we used for the hit test
g.DrawEllipse(Pens.Blue, hitTestRect);
g.Dispose();

Платформы

Windows Vista

Среды .NET Framework и .NET Compact Framework поддерживают не все версии каждой платформы. Поддерживаемые версии перечислены в разделе Требования к системе для .NET Framework.

Сведения о версии

.NET Framework

Поддерживается в версии: 3.0

См. также

Ссылки

Ink Класс

Ink - члены

HitTest - перегрузка

Microsoft.Ink - пространство имен

Strokes

ExtendedProperties