Ink.NearestPoint 方法 (Point)
傳回 Ink 物件內最接近指定 Point 的 Stroke 物件,以筆墨空間座標表示。
命名空間: 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
Ink 物件內指定的點,以筆墨空間座標表示。
傳回值
型別:Microsoft.Ink.Stroke
包含 Point 的 Stroke,最接近 Ink 物件中的指定 point。如果多個筆劃包含的 Point 與已知 Point (英文) 有相同的距離,這個結果的值就是任意值。如果 Ink 物件沒有包含 Stroke 物件,則傳回值是 nullNull 參照 (即 Visual Basic 中的 Nothing) (在 Visual Basic 中為 Nothing)。
範例
在這個範例中,最接近筆墨控制項中心之 Stroke 物件的色彩會變更為紅色。
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