다음을 통해 공유


Ink.HitTest 메서드 (array<Point[], Single)

업데이트: 2007년 11월

다중선 경계 내에 들어 있는 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)이거나 매개 변수에 포함된 점 수가 세 개 미만인 경우 이 메서드는 예외를 throw합니다.

예제

이 예제에서는 경계 선택 내에 해당 점의 50% 이상이 들어 있는 InkOverlayStroke 개체가 빨간색으로 변경됩니다. 경계 선택 점은 잉크 컨트롤의 중심을 기준으로 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에서 지원

참고 항목

참조

Ink 클래스

Ink 멤버

HitTest 오버로드

Microsoft.Ink 네임스페이스

Strokes

ExtendedProperties