ContextNode.Confirm 메서드
업데이트: 2007년 11월
확인 형식을 설정하여 InkAnalyzer가 노드에 대해 변경할 수 있는 항목을 제한합니다.
네임스페이스: System.Windows.Ink
어셈블리: IAWinFX(IAWinFX.dll)
구문
‘선언
Public Sub Confirm ( _
type As ConfirmationType _
)
‘사용 방법
Dim instance As ContextNode
Dim type As ConfirmationType
instance.Confirm(type)
public void Confirm(
ConfirmationType type
)
public:
void Confirm(
ConfirmationType type
)
public void Confirm(
ConfirmationType type
)
public function Confirm(
type : ConfirmationType
)
매개 변수
- type
형식: System.Windows.Ink.ConfirmationType
노드에 적용되는 ConfirmationType입니다.
설명
Confirm이 호출된 경우 InkAnalyzer에서는 이후 분석을 수행할 때 InkAnalyzer의 해당 스트로크와 연결된 ContextNode 개체를 변경하지 않습니다.
예를 들어 최종 사용자가 "to"라는 단어를 쓴 후에 응용 프로그램이 Analyze를 호출하면 InkAnalyzer에서는 값이 "to"인 InkWord 노드를 만듭니다. 그런 다음 최종 사용자가 "to" 다음에 "me"를 추가하여 한 단어로 만들고 응용 프로그램이 다시 Analyze를 호출하면 InkAnalyzer에서는 값이 "tome"인 InkWord 노드를 하나 만듭니다.
하지만 Analyze를 처음 호출한 후 응용 프로그램에서 "to" 값 NodeTypeAndProperties로 InkWord 노드에 대해 Confirm을 호출한 경우에는 "me"를 추가하더라도 노드가 변경되지 않습니다. InkAnalyzer는 "to me"에 대한 두 InkWord 노드를 인식합니다.
InkWord 및 InkDrawing 형식의 ContextNode 개체만 확인할 수 있습니다. 리프 노드가 아닌 노드에서 Confirm을 호출하려고 하면 InvalidOperationException이 throw됩니다.
InkAnalyzerRemoveStroke(Int32)를 호출할 때 제거될 스트로크가 확인된 ContextNode 개체에 관련된 경우에는 ContextNode 개체가 자동으로 확인되지 않은 것으로 설정됩니다.
ContextNode 개체가 이미 확인된 경우에는 SetStrokes(array<Int32[]) 및 ReparentStroke(Int32, ContextNode)에서 InvalidOperationException을 throw합니다. 소스 또는 대상 노드가 확인된 경우에는 ReparentStroke(Int32, ContextNode)에서 예외를 throw합니다.
예제
다음 예제에서는 사용자가 올바르게 분석된 스트로크를 나타낼 수 있습니다. 이 예제는 이름이 theInkCanvas인 InkCanvas에 대한 PreviewMouseUp 이벤트의 이벤트 처리기입니다. 이름이 confirmMode인 CheckBox를 선택한 경우 사용자는 단어를 클릭하여 해당 단어를 확인합니다(또는 노드가 이미 확인된 경우에는 확인을 해제). 이 예제에서는 StrokeCollection.HitTest(Point) 및 FindNodesOfType을 사용하여 적절한 노드를 찾습니다. 노드를 찾은 후 Confirm을 호출하여 확인 여부를 전환합니다. 마지막으로 TreeView를 다시 빌드하여 확인된 노드를 표시하고 PreviewMouseUp 이벤트를 처리합니다.
Sub theInkCanvas_PreviewMouseDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
If Me.confirmMode.IsChecked Then
' Find the ink word nodes that correspond to those strokes
Dim position As Point = e.GetPosition(theInkCanvas)
Dim hitStrokes As StrokeCollection = theInkCanvas.Strokes.HitTest(position)
Dim selectedNodes As ContextNodeCollection = _
Me.theInkAnalyzer.FindNodesOfType(ContextNodeType.InkWord, _
hitStrokes)
' Toggle the confirmation type on these nodes
Dim selectedNode As ContextNode
For Each selectedNode In selectedNodes
If selectedNode.IsConfirmed(ConfirmationType.NodeTypeAndProperties) Then
selectedNode.Confirm(ConfirmationType.None)
Else
selectedNode.Confirm(ConfirmationType.NodeTypeAndProperties)
End If
Next selectedNode
' Rebuild the TreeView to show which context nodes are confirmed.
Me.BuildTree()
' Handle the MouseDown event to prevent the InkCanvas from
' selecting the stroke.
e.Handled = True
End If
End Sub 'theInkCanvas_PreviewMouseDown
void theInkCanvas_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if ((bool)this.confirmMode.IsChecked)
{
// Find the ink word nodes that correspond to those strokes
Point position = e.GetPosition(theInkCanvas);
StrokeCollection hitStrokes = theInkCanvas.Strokes.HitTest(position);
ContextNodeCollection selectedNodes =
this.theInkAnalyzer.FindNodesOfType(ContextNodeType.InkWord,
hitStrokes);
// Toggle the confirmation type on these nodes
foreach (ContextNode selectedNode in selectedNodes)
{
if (selectedNode.IsConfirmed(ConfirmationType.NodeTypeAndProperties))
{
selectedNode.Confirm(ConfirmationType.None);
}
else
{
selectedNode.Confirm(ConfirmationType.NodeTypeAndProperties);
}
}
// Rebuild the TreeView to show which context nodes are confirmed.
this.BuildTree();
// Handle the MouseDown event to prevent the InkCanvas from
// selecting the stroke.
e.Handled = true;
}
}
플랫폼
Windows Vista
.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
3.0에서 지원
참고 항목
참조
ContextNodeIsNodeTypeAndPropertiesConfirmed()