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
参数
- selectionRectangle
类型:System.Drawing.Rectangle
选择矩形,采用墨迹空间 坐标。
- percentIntersect
类型:System.Single
用于确定 Strokes 集合中包含哪些 Stroke 对象的百分比值。如果矩形中包含的 Stroke 对象中的点百分比大于或等于传递到 percentIntersect 参数的百分比,则与矩形相交的 Stroke 对象包含在 Strokes 集合中。
返回值
类型:Microsoft.Ink.Strokes
指定的区域中所包含的 Strokes 集合。
备注
若要确定已知 Stroke 对象的哪些点与命中测试区域相交,请调用 Stroke.GetRectangleIntersections 方法,该方法返回 Stroke 对象与已知 Rectangle 相交的点。
示例
在此示例中,InkOverlay 中至少 75% 的点位于墨迹控件的左上 2000 x 2000 HIMETRIC 单位所定义的矩形内的所有 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