既知の円に完全に含まれるか、または既知の円と交差する Stroke オブジェクトの Strokes コレクションを返します。
名前空間 : Microsoft.Ink
アセンブリ : Microsoft.Ink (Microsoft.Ink.dll 内)
構文
'宣言
Public Function HitTest ( _
point As Point, _
radius As Single _
) As Strokes
'使用
Dim instance As Ink
Dim point As Point
Dim radius As Single
Dim returnValue As Strokes
returnValue = instance.HitTest(point, _
radius)
public Strokes HitTest(
Point point,
float radius
)
public:
Strokes^ HitTest(
Point point,
float radius
)
public Strokes HitTest(
Point point,
float radius
)
public function HitTest(
point : Point,
radius : float
) : Strokes
パラメータ
- point
型 : System.Drawing.Point
インク空間座標内のヒット テストの円の中心。
- radius
型 : System.Single
インク空間座標内のヒット テスト円の半径。
戻り値
型 : Microsoft.Ink.Strokes
指定された領域に含まれる Strokes コレクション。
解説
Stroke オブジェクトが円と交差する場合は、完全な Stroke が返されます。
このメソッドでは、Width も含めた Stroke オブジェクトに適用されるすべての DrawingAttributes セット、FitToCurve プロパティが true または false のどちらであるか、および PenTip プロパティの値を考慮して、交差部分を計算します。
Stroke オブジェクトまたは Strokes コレクションを回転または傾斜変換すると、変換された x 座標と y 座標の座標軸は元の座標軸と別になります。このため、半径パラメータは x 座標または y 座標から計算しないでください。
既知の Stroke オブジェクトのどのポイントがヒット テスト領域と交差するかを判断するには、Stroke.HitTest メソッドを呼び出します。
例
この例では、InkOverlay において、インク コントロールの中央を中心とする半径 120 ピクセルの円と交差するすべての Stroke オブジェクトが赤色に変更されます。色を変更する条件となるように 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 rectangle used to draw the circle around the center
Dim hitTestRect As Rectangle = New Rectangle(centerPt.X - RadiusPixel, centerPt.Y - RadiusPixel, RadiusPixel * 2, RadiusPixel * 2)
' get our graphics object
Dim g As Graphics = inkControl.CreateGraphics()
' convert centerPt to ink space coordinates
mInkOverlay.Renderer.PixelToInkSpace(g, centerPt)
' tempPt is used only to convert RadiusPixel to ink coords
Dim tempPt As Point = New Point(RadiusPixel, 0)
mInkOverlay.Renderer.PixelToInkSpace(g, tempPt)
' now tempPt.X = radius in ink coordinates
' Find strokes hit by the circle described by centerPt and radius
Dim hitStrokes As Strokes = mInkOverlay.Ink.HitTest(centerPt, tempPt.X)
' change the strokes that fall inside the circle to red
hitStrokes.ModifyDrawingAttributes(New DrawingAttributes(Color.Red))
' invalidate the ink control
inkControl.Invalidate()
' let the Invalidate message process
Application.DoEvents()
' draw the circle we used for the hit test
g.DrawEllipse(Pens.Blue, hitTestRect)
g.Dispose()
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 rectangle used to draw the circle around the center
Rectangle hitTestRect = new Rectangle(centerPt.X - RadiusPixel, centerPt.Y - RadiusPixel, RadiusPixel * 2, RadiusPixel * 2);
// get our graphics object
Graphics g = inkControl.CreateGraphics();
// convert centerPt to ink space coordinates
mInkOverlay.Renderer.PixelToInkSpace(g, ref centerPt);
// tempPt is used only to convert RadiusPixel to ink coords
Point tempPt = new Point(RadiusPixel, 0);
mInkOverlay.Renderer.PixelToInkSpace(g, ref tempPt);
// now tempPt.X = radius in ink coordinates
// Find strokes hit by the circle described by centerPt and radius
Strokes hitStrokes = mInkOverlay.Ink.HitTest(centerPt, tempPt.X);
// change the strokes that fall inside the circle to red
hitStrokes.ModifyDrawingAttributes(new DrawingAttributes(Color.Red));
// invalidate the ink control
inkControl.Invalidate();
// let the Invalidate message process
Application.DoEvents();
// draw the circle we used for the hit test
g.DrawEllipse(Pens.Blue, hitTestRect);
g.Dispose();
プラットフォーム
Windows Vista
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 3.0