InkOverlay.HitTestSelection 메서드
업데이트: 2007년 11월
선택 영역에서 적중 테스트 도중 적중된 부분(있는 경우)을 나타내는 값을 반환합니다.
네임스페이스: Microsoft.Ink
어셈블리: Microsoft.Ink(Microsoft.Ink.dll)
구문
‘선언
Public Function HitTestSelection ( _
X As Integer, _
Y As Integer _
) As SelectionHitResult
‘사용 방법
Dim instance As InkOverlay
Dim X As Integer
Dim Y As Integer
Dim returnValue As SelectionHitResult
returnValue = instance.HitTestSelection(X, _
Y)
public SelectionHitResult HitTestSelection(
int X,
int Y
)
public:
SelectionHitResult HitTestSelection(
int X,
int Y
)
public SelectionHitResult HitTestSelection(
int X,
int Y
)
public function HitTestSelection(
X : int,
Y : int
) : SelectionHitResult
매개 변수
- X
형식: System.Int32
적중 테스트의 X 위치(픽셀 단위)입니다.
- Y
형식: System.Int32
적중 테스트의 Y 위치(픽셀 단위)입니다.
반환 값
형식: Microsoft.Ink.SelectionHitResult
선택 영역에서 적중 테스트 도중 적중된 부분(있는 경우)을 지정하는 SelectionHitResult 열거형의 멤버입니다.
설명
이 메서드는 InkOverlay.EditingMode 속성이 Select로 설정된 경우에만 유용합니다.
참고
120dpi로 설정된 Windows XP 데스크톱 컴퓨터에서 잉크 응용 프로그램을 실행할 경우 HitTestSelection 메서드는 지정된 포인트가 잉크 공간에서 픽셀 공간으로 변환될 때 배율 인수에 의해 해제됩니다.
예제
이 예제에서는 MouseDown 이벤트가 발생할 때 EditingMode가 Select로 설정되어 있는지 확인합니다. 확인에 성공하면 HitTestSelection 메서드를 호출하여 선택 영역에서 적중된 부분(있는 경우)을 확인합니다. SelectionHitResult 열거형에 지정된 대로 네 가지 주요 컴퍼스 방향에서 적중이 발생한 경우 선택된 스트로크 개체가 다른 색으로 변경됩니다.
Private Sub mInkObject_MouseDown(ByVal sender As Object, ByVal e As CancelMouseEventArgs)
If InkOverlayEditingMode.Select = mInkObject.EditingMode Then
Select Case mInkObject.HitTestSelection(e.X, e.Y)
Case SelectionHitResult.North
ChangeSelectionColor(Color.Green)
Case SelectionHitResult.East
ChangeSelectionColor(Color.Red)
Case SelectionHitResult.South
ChangeSelectionColor(Color.Purple)
Case SelectionHitResult.West
ChangeSelectionColor(Color.Blue)
End Select
End If
End Sub
Private Sub ChangeSelectionColor(ByVal color As Color)
Dim DA As DrawingAttributes = mInkObject.DefaultDrawingAttributes.Clone()
DA.Color = color
mInkObject.Selection.ModifyDrawingAttributes(DA)
Using G As Graphics = CreateGraphics()
' Get the bounding box of the selection. The default is
' to include the width of the strokes in the calculation.
' The returned rectangle is measured in ink units.
Dim rInkUnits As Rectangle = mInkObject.Selection.GetBoundingBox()
' In selection mode, the selected strokes are drawn inflated
' GetBoundingBox() does not take this into account
' Rectangle rInkUnits is inflated to compensate
rInkUnits.Inflate(53, 53)
Dim topLeft As Point = rInkUnits.Location
Dim bottomRight As Point = rInkUnits.Location + rInkUnits.Size
' get a Renderer object to make the conversion
Dim R As Renderer = New Renderer()
' convert the points to pixels
R.InkSpaceToPixel(G, topLeft)
R.InkSpaceToPixel(G, bottomRight)
' create a rectangle that is in pixels
Dim rPixelUnits As Rectangle = _
New Rectangle(topLeft, New Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y))
' Redraw the strokes
mInkObject.Draw(rPixelUnits)
End Using
End Sub
private void mInkObject_MouseDown(object sender, CancelMouseEventArgs e)
{
if (InkOverlayEditingMode.Select == mInkObject.EditingMode)
{
switch (mInkObject.HitTestSelection(e.X, e.Y))
{
case SelectionHitResult.North:
ChangeSelectionColor(Color.Green);
break;
case SelectionHitResult.East:
ChangeSelectionColor(Color.Red);
break;
case SelectionHitResult.South:
ChangeSelectionColor(Color.Purple);
break;
case SelectionHitResult.West:
ChangeSelectionColor(Color.Blue);
break;
}
}
}
private void ChangeSelectionColor(Color color)
{
DrawingAttributes DA = mInkObject.DefaultDrawingAttributes.Clone();
DA.Color = color;
mInkObject.Selection.ModifyDrawingAttributes(DA);
using (Graphics G = CreateGraphics())
{
// Get the bounding box of the selection. The default is
// to include the width of the strokes in the calculation.
// The returned rectangle is measured in ink units.
Rectangle rInkUnits = mInkObject.Selection.GetBoundingBox();
// In selection mode, the selected strokes are drawn inflated
// GetBoundingBox() does not take this into account
// Rectangle rInkUnits is inflated to compensate
rInkUnits.Inflate(53, 53);
Point topLeft = rInkUnits.Location;
Point bottomRight = rInkUnits.Location + rInkUnits.Size;
// get a Renderer object to make the conversion
Renderer R = new Renderer();
// convert the points to pixels
R.InkSpaceToPixel(G, ref topLeft);
R.InkSpaceToPixel(G, ref bottomRight);
// create a rectangle that is in pixels
Rectangle rPixelUnits =
new Rectangle(topLeft, new Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y));
// Redraw the strokes
mInkObject.Draw(rPixelUnits);
}
}
플랫폼
Windows Vista
.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
3.0에서 지원