Ink.NearestPoint - метод (Point)
Обновлен: Ноябрь 2007
Returns the Stroke object within the Ink object that is nearest to a specified Point, given in ink space coordinates.
Пространство имен: Microsoft.Ink
Сборка: Microsoft.Ink (в Microsoft.Ink.dll)
Синтаксис
'Декларация
Public Function NearestPoint ( _
point As Point _
) As Stroke
'Применение
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
Параметры
- point
Тип: System.Drawing.Point
The specified point within the Ink object, given in ink space coordinates.
Возвращаемое значение
Тип: Microsoft.Ink.Stroke
The Stroke that contains a Point that is closest to the specified point in the Ink object. If more than one stroke contains a Point that is the same distance from the known Point, the value of this result is arbitrary. If the Ink object contains zero Stroke objects, the return value is nullссылка null (Nothing в Visual Basic) (Nothing in Visual Basic).
Примеры
In this example, the color of the Stroke object that is nearest to the center of the ink control is changed to red.
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();
}
Платформы
Windows Vista
Среды .NET Framework и .NET Compact Framework поддерживают не все версии каждой платформы. Поддерживаемые версии перечислены в разделе Требования к системе для .NET Framework.
Сведения о версии
.NET Framework
Поддерживается в версии: 3.0