Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Aggiornamento: novembre 2007
Restituisce l'insieme Strokes contenuto all'interno di un limite di selezione di polilinea.
Spazio dei nomi: Microsoft.Ink
Assembly: Microsoft.Ink (in Microsoft.Ink.dll)
Sintassi
'Dichiarazione
Public Function HitTest ( _
points As Point(), _
percentIntersect As Single _
) As Strokes
'Utilizzo
Dim instance As Ink
Dim points As Point()
Dim percentIntersect As Single
Dim returnValue As Strokes
returnValue = instance.HitTest(points, _
percentIntersect)
public Strokes HitTest(
Point[] points,
float percentIntersect
)
public:
Strokes^ HitTest(
array<Point>^ points,
float percentIntersect
)
public Strokes HitTest(
Point[] points,
float percentIntersect
)
public function HitTest(
points : Point[],
percentIntersect : float
) : Strokes
Parametri
- points
Tipo: array<System.Drawing.Point[]
Punti utilizzati nel limite di selezione per selezionare gli oggetti Stroke. L'area di selezione è l'area nel limite di selezione nel quale si interseca per prima il limite.
- percentIntersect
Tipo: System.Single
Percentuale di punti in Tratto che deve essere contenuta nel limite di selezione per essere considerata un'occorrenza.
Valore restituito
Tipo: Microsoft.Ink.Strokes
Insieme Strokes contenuto nell'area specificata.
Note
Se il limite di selezione non si interseca, il metodo HitTest aggiunge un punto alla fine della matrice per creare una linea retta dal primo all'ultimo punto. Se il limite è una linea retta senza area all'interno del limite di selezione, non viene selezionato alcun oggetto Stroke.
Questo metodo genera un'eccezione se il parametro dei punti è nullriferimento null (Nothing in Visual Basic) (Nothing in Microsoft Visual Basic.NET) o contiene meno di tre punti.
Esempi
In questo esempio, vengono modificati in rosso tutti gli oggetti Stroke di un oggetto InkOverlay aventi almeno il 50% dei punti nella selezione del limite. I punti di selezione del limite descrivono un rettangolo ruotato di 45 gradi attorno al centro del controllo dell'input penna. La selezione del limite viene resa visibile tramite i punti di selezione per creare un oggetto Stroke.
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 boundary points. These points describe a rectangle
' that is rotated around the center 45 degrees (a diamond)
Dim boundaryPts() As Point = _
{ _
New Point(centerPt.X, centerPt.Y - (RadiusPixel / 2)), _
New Point(centerPt.X + (RadiusPixel / 2), centerPt.Y), _
New Point(centerPt.X, centerPt.Y + (RadiusPixel / 2)), _
New Point(centerPt.X - (RadiusPixel / 2), centerPt.Y), _
New Point(centerPt.X, centerPt.Y - (RadiusPixel / 2)) _
}
Using g As Graphics = inkControl.CreateGraphics()
' convert boundary points to ink space coordinates
mInkOverlay.Renderer.PixelToInkSpace(g, boundaryPts)
End Using
' show the tilted rectangle (diamond) by creating a stroke
mInkOverlay.Ink.CreateStroke(boundaryPts)
' Find strokes that are at least 50% inside the boundary points
Dim hitStrokes As Strokes = mInkOverlay.Ink.HitTest(boundaryPts, 50.0F)
' change the strokes that fall inside the boundary points to red
hitStrokes.ModifyDrawingAttributes(New DrawingAttributes(Color.Red))
' invalidate the ink control
inkControl.Invalidate()
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 boundary points. These points describe a rectangle
// that is rotated around the center 45 degrees (a diamond)
Point[] boundaryPts = new Point[5]
{
new Point(centerPt.X, centerPt.Y - (RadiusPixel / 2)),
new Point(centerPt.X + (RadiusPixel / 2), centerPt.Y),
new Point(centerPt.X, centerPt.Y + (RadiusPixel / 2)),
new Point(centerPt.X - (RadiusPixel / 2), centerPt.Y),
new Point(centerPt.X, centerPt.Y - (RadiusPixel / 2))
};
using (Graphics g = inkControl.CreateGraphics())
{
// convert boundary points to ink space coordinates
mInkOverlay.Renderer.PixelToInkSpace(g, ref boundaryPts);
}
// show the tilted rectangle (diamond) by creating a stroke
mInkOverlay.Ink.CreateStroke(boundaryPts);
// Find strokes that are at least 50% inside the boundary points
Strokes hitStrokes = mInkOverlay.Ink.HitTest(boundaryPts, 50.0f);
// change the strokes that fall inside the boundary points to red
hitStrokes.ModifyDrawingAttributes(new DrawingAttributes(Color.Red));
// invalidate the ink control
inkControl.Invalidate();
Piattaforme
Windows Vista
.NET Framework e .NET Compact Framework non supportano tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.
Informazioni sulla versione
.NET Framework
Supportato in: 3.0