ポリライン選択境界に含まれている Strokes コレクションを返します。
名前空間 : Microsoft.Ink
アセンブリ : Microsoft.Ink (Microsoft.Ink.dll 内)
構文
'宣言
Public Function HitTest ( _
points As Point(), _
percentIntersect As Single _
) As Strokes
'使用
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
パラメータ
- points
型 : array<System.Drawing.Point[]
Stroke オブジェクトを選択するために選択境界内で使用されるポイント。選択領域は選択境界内の領域で、境界はこの領域内で最初に自身と交差します。
- percentIntersect
型 : System.Single
ストロークのポイントのパーセンテージ。ヒットしたと見なされるためには、ストロークが選択境界含まれていることが必要です。
戻り値
型 : Microsoft.Ink.Strokes
指定された領域に含まれる Strokes コレクション。
解説
選択境界がそれ自体と交差しない場合、HitTest メソッドは配列の最後にポイントを追加して最初のポイントと最後のポイントをつなぐ直線を作成します。境界が直線で、選択境界内に領域を持たない場合は、Stroke オブジェクトは選択されません。
ポイント パラメータが nullnull 参照 (Visual Basic では Nothing) (Microsoft Visual Basic.NET の場合は Nothing) であるか、含まれるポイントが 2 つ以下の場合、このメソッドは例外をスローします。
例
この例では、InkOverlay において、選択境界の内側に 50% 以上のポイントがあるすべての Stroke オブジェクトが赤色に変更されます。選択境界のポイントは、インク コントロールの中心を基準に 45 度回転された四角形となります。選択境界は、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 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();
プラットフォーム
Windows Vista
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 3.0