確認の型を設定して、これにより 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" を 1 つの語として追加した場合、アプリケーションが Analyze をもう一度呼び出して、InkAnalyzer は値が "tome" の InkWord ノードを 1 つ作成します。
ただし、Analyze の最初の呼び出しの後、アプリケーションが値 NodeTypeAndProperties が設定された "to" の InkWord ノードで Confirm を呼び出した場合、"me" を追加してもノードは変更されません。InkAnalyzer は、"to me" の 2 つの InkWord ノードを認識します。
InkWord 型および InkDrawing 型の ContextNode オブジェクトのみ確認できます。リーフ ノードではないノードで Confirm を呼び出そうとした場合、InvalidOperationException がスローされます。
InkAnalyzerRemoveStroke(Int32) を呼び出す場合、削除されるストロークが、確認済みの ContextNode オブジェクトに関連するときは、ContextNode オブジェクトが自動的に未確認に設定されます。
ContextNode オブジェクトが既に確認済みの場合、SetStrokes(array<Int32[]) と ReparentStroke(Int32, ContextNode) は InvalidOperationException をスローします。リンク元ノードまたはリンク先ノードのどちらかが確認済みの場合、ReparentStroke(Int32, ContextNode) は例外をスローします。
例
次の例では、ユーザーは正常に分析されているストロークを指定できます。この例は、InkCanvas、theInkCanvas での PreviewMouseUp イベントのイベント ハンドラです。CheckBox、confirmMode がオンの場合、ユーザーは単語をクリックして確認します (または、ノードが既に確認済みの場合は確認を無効にします)。この例では、StrokeCollection.HitTest(Point) および FindNodesOfType を使用して、適切なノードを検索します。ノードが見つかったら、Confirm が呼び出されて確認が切り替えられます。最後に、確認されたノードと、PreviewMouseUp イベントが処理されることを示す TreeView が再構築されます。
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()