次の方法で共有


Ink.HitTest メソッド (Rectangle, Single)

既知の Rectangle に含まれている Strokes コレクションを返します。

名前空間 :  Microsoft.Ink
アセンブリ :  Microsoft.Ink (Microsoft.Ink.dll 内)

構文

'宣言
Public Function HitTest ( _
    selectionRectangle As Rectangle, _
    percentIntersect As Single _
) As Strokes
'使用
Dim instance As Ink
Dim selectionRectangle As Rectangle
Dim percentIntersect As Single
Dim returnValue As Strokes

returnValue = instance.HitTest(selectionRectangle, _
    percentIntersect)
public Strokes HitTest(
    Rectangle selectionRectangle,
    float percentIntersect
)
public:
Strokes^ HitTest(
    Rectangle selectionRectangle, 
    float percentIntersect
)
public Strokes HitTest(
    Rectangle selectionRectangle,
    float percentIntersect
)
public function HitTest(
    selectionRectangle : Rectangle, 
    percentIntersect : float
) : Strokes

パラメータ

  • percentIntersect
    型 : System.Single
    Strokes コレクションに含める Stroke オブジェクトを決定するパーセンテージの値。四角形に含まれる Stroke オブジェクトのポイントのパーセンテージが percentIntersect パラメータに渡されるパーセンテージ以上である場合は、四角形と交差する Stroke オブジェクトが Strokes コレクションに含まれます。

戻り値

型 : Microsoft.Ink.Strokes
指定された領域に含まれる Strokes コレクション。

解説

既知の Stroke オブジェクトのどのポイントがヒット テスト領域と交差するかを判断するには、Stroke.GetRectangleIntersections メソッドを呼び出します。このメソッドは、Stroke オブジェクトが既知の Rectangle と交差するポイントを返します。

この例では、InkOverlay において、インク コントロールの左上隅にある 2000 x 2000 HIMETRIC 単位で定義される四角形の内側に 75% 以上のポイントがあるすべての Stroke オブジェクトが赤色に変更されます。この四角形は、Stroke オブジェクトを作成するための選択ポイントを使用して表示できます。

Const RectSideInkUnits As Integer = 2000
' get the control. InkOverlay.AttachedControl must be set
Dim inkControl As Control = mInkOverlay.AttachedControl
' create the rectangle used for the hit test
Dim hitTestRect As Rectangle = New Rectangle(0, 0, RectSideInkUnits, RectSideInkUnits)
' create boundary points in order to show the rectangle by creating a stroke
Dim boundaryPts() As Point = _
    { _
        New Point(RectSideInkUnits, 0), _
        New Point(RectSideInkUnits, RectSideInkUnits), _
        New Point(0, RectSideInkUnits) _
    }

' show the rectangle by creating a stroke
mInkOverlay.Ink.CreateStroke(boundaryPts)
' Find strokes that fall at least 75% within the rectangle
Dim hitStrokes As Strokes = mInkOverlay.Ink.HitTest(hitTestRect, 75.0F)
' change the found strokes to red
hitStrokes.ModifyDrawingAttributes(New DrawingAttributes(Color.Red))
' invalidate the ink control
inkControl.Invalidate()
const int RectSideInkUnits = 2000;
// get the control. InkOverlay.AttachedControl must be set
Control inkControl = mInkOverlay.AttachedControl;
// create the rectangle used for the hit test
Rectangle hitTestRect = new Rectangle(0, 0, RectSideInkUnits, RectSideInkUnits);
// create boundary points in order to show the rectangle by creating a stroke
Point[] boundaryPts = new Point[3] 
    {
        new Point(RectSideInkUnits, 0),
        new Point(RectSideInkUnits, RectSideInkUnits),
        new Point(0, RectSideInkUnits)
    };

// show the rectangle by creating a stroke
mInkOverlay.Ink.CreateStroke(boundaryPts);
// Find strokes that fall at least 75% within the rectangle
Strokes hitStrokes = mInkOverlay.Ink.HitTest(hitTestRect, 75.0f);
// change the found strokes 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

参照

参照

Ink クラス

Ink メンバ

HitTest オーバーロード

Microsoft.Ink 名前空間

Strokes

ExtendedProperties