共用方式為


ContextNode.Confirm 方法

設定確認型別,限制 InkAnalyzer 能夠變更的節點內容。

命名空間:  Microsoft.Ink
組件:  Microsoft.Ink.Analysis (在 Microsoft.Ink.Analysis.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
)

參數

備註

Confirm 可以用來讓使用者確認 InkAnalyzer 已正確分析筆劃。呼叫 Confirm 之後,InkAnalyzer 將不會在稍後分析時變更這些筆劃的 ContextNode 物件。

例如,如果使用者書寫 "to" 這個字,然後應用程式呼叫 Analyze,則 InkAnalyzer 將會建立 InkWord 節點並且包含 "to" 這個值。如果使用者接著在 "to" 後面加入 "me" 做為一個字,而且應用程式再次呼叫 Analyze,則 InkAnalyzer 可能會建立一個 InkWord 節點並且包含 "tome" 這個值。不過,如果在第一次呼叫 Analyze 之後,應用程式針對具有 NodeTypeAndProperties 值的 "to" 在 InkWord 節點上呼叫 Confirm,則會發生不同的行為。當使用者加入 "me" 而且應用程式再次呼叫 Analyze 時,"to" 節點不會變更。InkAnalyzer 可能會辨識兩個 "to me" 的 InkWord 節點。

您只能確認 InkWordInkDrawing 型別的 ContextNode 物件。如果嘗試在不是分葉節點的節點上呼叫 Confirm,則會擲回 InvalidOperationException (英文)。

如果您呼叫 InkAnalyzer.RemoveStroke,而移除的筆劃與確認的 ContextNode 物件相關,則 ContextNode 物件會自動設定為未確認。

如果 ContextNode 物件已經過確認,SetStrokesInkAnalyzer.SetStrokesTypeInkAnalyzer.SetStrokeType 會擲回 InvalidOperationException (英文)。如果來源或目的節點已經過確認,ReparentStrokes 會擲回例外狀況。

範例

下列範例是 Panel (英文) (變數名稱為 theNotesPanel) 上 Control.MouseUp (英文) 事件的處理常式,它會透過 InkCollector (變數名稱為 theInkCollector) 收集筆墨。應用程式有 Boolean (變數名稱為 confirmMode),是由 MenuItem (變數名稱為 confirmMenuItem) 設定。在「確認」模式中時,使用者按一下文字即可加以確認 (或在節點已確認時關閉確認)。這個範例會將放開滑鼠事件轉換成筆墨座標,並使用 HitTestFindNodesOfType 找出適當的節點。找到節點之後,就會呼叫 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)

        ' Find the ink word nodes that correspond to those strokes
        Dim selectedNodes As ContextNodeCollection = _
            Me.theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.InkWord, _
            selectedStrokes)

        ' Toggle the confirmation type on these nodes
        Dim selectedNode As ContextNode
        For Each selectedNode In selectedNodes
            If selectedNode.IsConfirmed(ConfirmationType.NodeTypeAndProperties) = True Then
                selectedNode.Confirm(Microsoft.Ink.ConfirmationType.None)
            Else
                selectedNode.Confirm(Microsoft.Ink.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);

        // Find the ink word nodes that correspond to those strokes
        ContextNodeCollection selectedNodes =
            this.theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.InkWord,
            selectedStrokes);

        // Toggle the confirmation type on these nodes
        foreach (ContextNode selectedNode in selectedNodes)
        {
            if (selectedNode.IsConfirmed(ConfirmationType.NodeTypeAndProperties))
            {
                selectedNode.Confirm(Microsoft.Ink.ConfirmationType.None);
            }
            else
            {
                selectedNode.Confirm(Microsoft.Ink.ConfirmationType.NodeTypeAndProperties);
            }
        }

        // No longer in "confirm" mode
        this.confirmMode = false;
        this.confirmMenuItem.Checked = false;
        this.theInkCollector.Enabled = true;
    }

}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求

版本資訊

.NET Framework

支援版本:3.0

請參閱

參考

ContextNode 類別

ContextNode 成員

Microsoft.Ink 命名空間