Compartir a través de


Ink.HitTest (Método) (Point, Single)

Actualización: noviembre 2007

Devuelve la colección Strokes de objetos Stroke que están completamente dentro o que forman intersección con un círculo conocido.

Espacio de nombres:  Microsoft.Ink
Ensamblado:  Microsoft.Ink (en Microsoft.Ink.dll)

Sintaxis

'Declaración
Public Function HitTest ( _
    point As Point, _
    radius As Single _
) As Strokes
'Uso
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

Parámetros

  • point
    Tipo: System.Drawing.Point
    El centro del círculo de la prueba de posicionamiento, en coordenadas de espacio de entrada manuscrita.
  • radius
    Tipo: System.Single
    El radio del círculo de la prueba de posicionamiento, en coordenadas de espacio de entrada manuscrita.

Valor devuelto

Tipo: Microsoft.Ink.Strokes
La colección Strokes incluida en el área especificada.

Comentarios

Si un objeto Stroke forma intersección con el círculo, se devuelve el objeto Stroke completo.

Este método calcula la intersección, considerado el conjunto completo de atributos DrawingAttributes que se aplican al objeto Stroke, incluido el ancho Width, donde la propiedad FitToCurve es true o false, y el valor de la propiedad PenTip.

Después de realizar un giro o una transformación de la distorsión en un objeto Stroke o en una colección Strokes, las coordenadas X e Y transformadas ya no serán concéntricas con respecto a las coordenadas originales. Por tanto, el parámetro de radio no se debe calcular a partir de las coordenadas X o Y.

Para determinar qué puntos de un objeto Stroke conocido forman intersección en el área de la prueba de posicionamiento, llame al método Stroke.HitTest.

Ejemplos

En este ejemplo, todos los objetos Stroke de InkOverlay que formen una intersección con un círculo con su punto central en el medio del control de entrada manuscrita y un radio de 120 píxeles, cambian a rojo. El círculo con el que un objeto Stroke debe formar una intersección para que pueda cambiar el color se dibuja en azul.

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();

Plataformas

Windows Vista

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Información de versión

.NET Framework

Compatible con: 3.0

Vea también

Referencia

Ink (Clase)

Ink (Miembros)

HitTest (Sobrecarga)

Microsoft.Ink (Espacio de nombres)

Strokes

ExtendedProperties