Condividi tramite


Metodo Ink.NearestPoint (Point)

Aggiornamento: novembre 2007

Restituisce l'oggetto Stroke all'interno dell'oggetto Ink che è più vicino all'oggetto Point specificato, fornito nelle coordinate dello spazio dell'input penna.

Spazio dei nomi:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Sintassi

'Dichiarazione
Public Function NearestPoint ( _
    point As Point _
) As Stroke
'Utilizzo
Dim instance As Ink
Dim point As Point
Dim returnValue As Stroke

returnValue = instance.NearestPoint(point)
public Stroke NearestPoint(
    Point point
)
public:
Stroke^ NearestPoint(
    Point point
)
public Stroke NearestPoint(
    Point point
)
public function NearestPoint(
    point : Point
) : Stroke

Parametri

  • point
    Tipo: System.Drawing.Point
    Punto specificato all'interno dell'oggetto Ink, specificato nelle coordinate dello spazio di input penna.

Valore restituito

Tipo: Microsoft.Ink.Stroke
Oggetto Stroke contenente un oggetto Point più vicino all'oggetto point specificato nell'oggetto Ink. Se più tratti contengono un oggetto Point che si trova alla medesima distanza dall'oggetto Point noto, il valore di questo risultato è arbitrario. Se l'oggetto Ink contiene zero oggetti Stroke, il valore restituito è nullriferimento null (Nothing in Visual Basic) (Nothing in Visual Basic).

Esempi

In questo esempio, il colore dell'oggetto Stroke più vicino al centro del controllo dell'input penna viene modificato in rosso.

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)
Using g As Graphics = inkControl.CreateGraphics()
    ' convert center point to ink space coordinates
    mInkOverlay.Renderer.PixelToInkSpace(g, centerPt)
End Using
' get the nearest stroke
Dim nStroke As Stroke = mInkOverlay.Ink.NearestPoint(centerPt)
' nStroke will be null if there aren't any strokes
If Not IsNothing(nStroke) Then
    ' change the color of the nearest stroke to red
    nStroke.DrawingAttributes.Color = Color.Red
    inkControl.Invalidate()
End If
Control inkControl = mInkOverlay.AttachedControl;
// get the center of the ink control
Point centerPt = new Point(inkControl.Width / 2, inkControl.Height / 2);
using (Graphics g = inkControl.CreateGraphics())
{
    // convert center point to ink space coordinates
    mInkOverlay.Renderer.PixelToInkSpace(g, ref centerPt);
}

// get the nearest stroke
Stroke nStroke = mInkOverlay.Ink.NearestPoint(centerPt);

// nStroke will be null if there aren't any strokes
if (nStroke != null)
{
    // change the color of the nearest stroke to red
    nStroke.DrawingAttributes.Color = Color.Red;
    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

Vedere anche

Riferimenti

Ink Classe

Membri Ink

Overload NearestPoint

Spazio dei nomi Microsoft.Ink

Stroke

Stroke.Split