Freigeben über


Ink.HitTest-Methode (array<Point[], Single)

Gibt die innerhalb einer durch eine Polylinie definierte Auswahlbegrenzung enthaltene Strokes-Auflistung zurück.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Syntax

'Declaration
Public Function HitTest ( _
    points As Point(), _
    percentIntersect As Single _
) As Strokes
'Usage
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

Parameter

  • points
    Typ: array<System.Drawing.Point[]
    Die Punkte, die in der Auswahlbegrenzung zur Auswahl der Stroke-Objekte dienen. Der Auswahlbereich ist der Bereich innerhalb der Auswahlbegrenzung, in dem sich die Begrenzung zuerst selbst schneidet.
  • percentIntersect
    Typ: System.Single
    Für einen Treffer erforderlicher Prozentanteil der Punkte eines Stroke-Objekts, die innerhalb der Auswahlbegrenzung liegen müssen.

Rückgabewert

Typ: Microsoft.Ink.Strokes
Die Strokes-Auflistung, die im angegebenen Bereich enthalten ist.

Hinweise

Wenn sich die Auswahlbegrenzung nicht selbst schneidet, fügt die HitTest-Methode einen Punkt am Ende des Arrays hinzu, um eine gerade Linie vom ersten Punkt bis zum letzten Punkt zu erstellen. Wenn die Begrenzung eine gerade Linie ist, die nicht innerhalb der Auswahlbegrenzung liegt, dann werden keine Stroke-Objekte ausgewählt.

Diese Methode löst eine Ausnahme aus, wenn der Punkteparameter gleich nullNULL-Verweis (Nothing in Visual Basic) (Nothing in Microsoft Visual Basic.NET) ist oder weniger als drei Punkte enthält.

Beispiele

In diesem Beispiel werden alle Stroke-Objekte eines InkOverlay, bei denen mindestens 50 % der Punkte innerhalb einer Begrenzungsauswahl liegen, in rot geändert. Die Auswahlpunkte der Begrenzung beschreiben ein Rechteck, das 45 Grad um die Mitte des Freihandsteuerelements gedreht ist. Die Begrenzungsauswahl wird durch Auswahlpunkte sichtbar gemacht, mit denen ein Stroke-Objekt erstellt wird.

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

Plattformen

Windows Vista

.NET Framework und .NET Compact Framework unterstützen nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.

Versionsinformationen

.NET Framework

Unterstützt in: 3.0

Siehe auch

Referenz

Ink-Klasse

Ink-Member

HitTest-Überladung

Microsoft.Ink-Namespace

Strokes

ExtendedProperties