ContextNode.Confirm - метод
Обновлен: Ноябрь 2007
Sets the confirmation type, which restricts what the InkAnalyzer can change about the node.
Пространство имен: 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
)
Параметры
- type
Тип: Microsoft.Ink.ConfirmationType
The ConfirmationType that is applied to the node.
Заметки
Use Confirm to enable the end user to confirm that the InkAnalyzer has correctly analyzed the strokes. After Confirm has been called, the InkAnalyzer will not change the ContextNode objects for those strokes during later analysis.
For example, if the end user writes the word "to" and then your application calls Analyze, the InkAnalyzer will create an InkWord node with the value of "to". If the end user then adds "me" after "to" as one word and the application makes another call to Analyze, the InkAnalyzer would likely create one InkWord node with the value "tome". However, if after the first call to Analyze, the application calls Confirm on the InkWord node for "to" with the value NodeTypeAndProperties, a different behavior occurs. When the end user adds the "me" and the application makes another call to Analyze, the "to" node is not changed. The InkAnalyzer would recognize two InkWord nodes for "to me".
You can confirm only ContextNode objects of type InkWord and InkDrawing. If you attempt to call Confirm on a node that is not a leaf node, an InvalidOperationException is thrown.
If you call InkAnalyzer.RemoveStroke, the ContextNode object is automatically set to unconfirmed if the stroke being removed is related to a confirmed ContextNode object.
SetStrokes, InkAnalyzer.SetStrokesType, and InkAnalyzer.SetStrokeType, throw an InvalidOperationException if the ContextNode object is already confirmed. ReparentStrokes throws the exception if either source or destination node is confirmed.
Примеры
The following example is an event handler for the Control.MouseUp event on a Panel, theNotesPanel, which is collecting ink through an InkCollector, theInkCollector. The application has a Boolean, confirmMode, which is set by a MenuItem, confirmMenuItem. When in "confirm" mode, the user clicks on a word to confirm it (or to turn off confirmation if the node is already confirmed). The example converts the mouse up event into ink coordinates, uses HitTest and FindNodesOfType to find the appropriate nodes. After the nodes are found, Confirm is called to toggle the confirmation. Finally, the application is taken out of "confirm" mode.
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