다음을 통해 공유


Ink.HitTest 메서드 (Point, Single)

업데이트: 2007년 11월

알려진 원 안에 완전히 포함되거나 해당 원과 교차하는 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

매개 변수

  • radius
    형식: System.Single
    잉크 공간 좌표의 적중 테스트 원 반지름입니다.

반환 값

형식: Microsoft.Ink.Strokes
지정된 영역 안에 들어 있는 Strokes 컬렉션입니다.

설명

Stroke 개체가 원과 교차하는 경우 전체 Stroke가 반환됩니다.

이 메서드에서는 Width, FitToCurve 속성이 true인지 false인지 여부, PenTip 속성 값 같은 Stroke 개체에 적용되는 DrawingAttributes의 전체 집합을 고려하여 교차를 계산합니다.

Stroke 개체 또는 Strokes 컬렉션에 대해 회전 또는 기울이기 변환을 수행한 후에는 변환된 X 및 Y 좌표의 중심이 원래 좌표와 달라지게 됩니다. 따라서 반지름 매개 변수는 X 또는 Y 좌표에서 계산되지 않습니다.

적중 테스트 영역과 교차하는 알려진 Stroke 개체의 점을 확인하려면 Stroke.HitTest 메서드를 호출합니다.

예제

이 예제에서는 중심점이 잉크 컨트롤의 중간에 있고 반지름이 120픽셀인 원과 교차하는 InkOverlayStroke 개체가 빨간색으로 변경됩니다. 색상 변경 사항에 맞추기 위해 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에서 지원

참고 항목

참조

Ink 클래스

Ink 멤버

HitTest 오버로드

Microsoft.Ink 네임스페이스

Strokes

ExtendedProperties