ノードに変更を加えることができる InkAnalyzerBase を制限する確認の型を設定します。
名前空間 : System.Windows.Ink.AnalysisCore
アセンブリ : IACore (IACore.dll 内)
構文
'宣言
Public Sub Confirm ( _
type As ConfirmationType _
)
'使用
Dim instance As ContextNodeBase
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.AnalysisCore.ConfirmationType
ノードに適用される ConfirmationType。
解説
InkAnalyzerBase がストロークを正しく分析したことをエンド ユーザーが確認できるようにするには、Confirm を使用します。Confirm が呼び出されると、InkAnalyzerBase はそれ以降の分析時にそれらのストロークの ContextNodeBase オブジェクトを変更しなくなります。
たとえば、エンド ユーザーが "to" という語を書き込んで、アプリケーションが Analyze を呼び出した場合、InkAnalyzerBase は値が "to" の InkWord ノードを作成します。次に、エンド ユーザーが "to" の後に "me" を 1 つの語として追加した場合、アプリケーションが Analyze をもう一度呼び出して、InkAnalyzerBase は値が "tome" の InkWord ノードを 1 つ作成します。ただし、Analyze の最初の呼び出しの後、アプリケーションが値 NodeTypeAndProperties が設定された "to" の InkWord ノードで Confirm を呼び出した場合、別の動作が行われます。エンド ユーザーが "me" を追加して、アプリケーションが Analyze をもう一度呼び出すと、"to" ノードは変更されません。InkAnalyzerBase は、"to me" の 2 つの InkWord ノードを認識します。
InkWord 型および InkDrawing 型の ContextNodeBase オブジェクトのみ確認できます。リーフ ノードではないノードで Confirm を呼び出そうとした場合、InvalidOperationException がスローされます。
InkAnalyzerBase.RemoveStroke を呼び出すと、削除されるストロークが、確認済みの ContextNodeBase オブジェクトに関連する場合は、ContextNodeBase オブジェクトが自動的に未確認に設定されます。
ContextNodeBase オブジェクトが既に確認済みの場合、SetStrokes、SetStrokeType、および SetStrokesType は、InvalidOperationException をスローします。リンク元ノードまたはリンク先ノードのどちらかが確認済みの場合、ReparentStrokes は例外をスローします。
例
次の例では、theInkCollector という名前の InkCollector によってインクを収集する、theNotesPanel という名前の Panel の MouseUp イベントのイベント ハンドラを示します。アプリケーションには、confirmMenuItem という名前の MenuItem によって設定される、confirmMode という名前の Boolean 値が設定されています。"確認" モードの場合、ユーザーは単語をクリックして確認します (または、ノードが既に確認済みの場合は確認を無効にします)。次の例では、マウスアップ イベントをインク座標に変換し、HitTest および FindNodesOfType を使用して適切なノードを検索します。ノードが見つかったら、Confirm が呼び出されて確認が切り替えられます。最後に、アプリケーションの "確認" モードが終了します。
Private Sub theNotesPanel_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles theNotesPanel.MouseUp
If Me.confirmMode = True Then
' Translate coordinates into ink dimensions
Dim hitPoint As New Point(e.X, e.Y)
Dim panelGraphics As Graphics = Me.theNotesPanel.CreateGraphics()
Me.theInkCollector.Renderer.PixelToInkSpace(panelGraphics, hitPoint)
panelGraphics.Dispose()
' Find the strokes that the user selected
Dim selectedStrokes As Strokes = Me.theInkCollector.Ink.HitTest(hitPoint, 10)
' The integer array must be exactly the right size. Arrays
' begin at zero, so the upper bound is selectedStrokes.Count - 1.
Dim selectedStrokeIds(selectedStrokes.Count - 1) As Integer
For i As Integer = 0 To selectedStrokes.Count - 1
selectedStrokeIds(i) = selectedStrokes(i).Id
Next
' Find the ink word nodes that correspond to those strokes
Dim selectedNodes As ContextNodeBaseCollection = _
Me.theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.InkWord, _
selectedStrokeIds)
' Toggle the confirmation type on these nodes
Dim selectedNode As ContextNodeBase
For Each selectedNode In selectedNodes
If selectedNode.IsConfirmed( _
Windows.Ink.AnalysisCore.ConfirmationType.NodeTypeAndProperties) Then
selectedNode.Confirm(System.Windows.Ink.AnalysisCore.ConfirmationType.None)
Else
selectedNode.Confirm(System.Windows.Ink.AnalysisCore.ConfirmationType.NodeTypeAndProperties)
End If
Next selectedNode
' No longer in "confirm" mode
Me.confirmMode = False
Me.ConfirmMenuItem.Checked = False
Me.theInkCollector.Enabled = True
End If
End Sub
private void theNotesPanel_MouseUp(object sender, MouseEventArgs e)
{
if (this.confirmMode)
{
// Translate coordinates into ink dimensions
Point hitPoint = new Point(e.X, e.Y);
Graphics panelGraphics = this.theNotesPanel.CreateGraphics();
this.theInkCollector.Renderer.PixelToInkSpace(panelGraphics, ref hitPoint);
panelGraphics.Dispose();
// Find the strokes that the user selected
Strokes selectedStrokes = this.theInkCollector.Ink.HitTest(hitPoint, 10);
int[] selectedStrokeIds = new int[selectedStrokes.Count];
for (int i = 0; i < selectedStrokes.Count; i++)
{
selectedStrokeIds[i] = selectedStrokes[i].Id;
}
// Find the ink word nodes that correspond to those strokes
ContextNodeBaseCollection selectedNodes =
this.theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.InkWord,
selectedStrokeIds);
// Toggle the confirmation type on these nodes
foreach (ContextNodeBase selectedNode in selectedNodes)
{
if (selectedNode.IsConfirmed(
System.Windows.Ink.AnalysisCore.ConfirmationType.NodeTypeAndProperties))
{
selectedNode.Confirm(System.Windows.Ink.AnalysisCore.ConfirmationType.None);
}
else
{
selectedNode.Confirm(System.Windows.Ink.AnalysisCore.ConfirmationType.NodeTypeAndProperties);
}
}
// No longer in "confirm" mode
this.confirmMode = false;
this.confirmMenuItem.Checked = false;
this.theInkCollector.Enabled = true;
}
}
プラットフォーム
Windows Vista, Windows XP SP2, Windows Server 2003
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 3.0