ContextNode.IsConfirmed 方法
获取一个值,该值指示 ContextNode 对象是否已确认。InkAnalyzer 不能更改已确认对象的节点类型和关联的笔画。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.dll 中)
语法
声明
Public Function IsConfirmed ( _
type As ConfirmationType _
) As Boolean
用法
Dim instance As ContextNode
Dim type As ConfirmationType
Dim returnValue As Boolean
returnValue = instance.IsConfirmed(type)
public bool IsConfirmed(
ConfirmationType type
)
public:
bool IsConfirmed(
ConfirmationType type
)
public boolean IsConfirmed(
ConfirmationType type
)
public function IsConfirmed(
type : ConfirmationType
) : boolean
参数
- type
类型:Microsoft.Ink.ConfirmationType
要检查的确认类型。
返回值
类型:System.Boolean
如果节点类型已确认,则为 true;否则为 false。
示例
下面的示例使用 IsConfirmed() 方法切换 ContextNode 的确认状态。该示例是 Panel (theNotesPanel) 上的 Control.MouseUp 事件的事件处理程序,它在通过 InkCollector (theInkCollector) 收集墨迹。应用程序有一个 Boolean (confirmMode),它由 MenuItem (confirmMenuItem) 设置。在“确认”模式下,用户单击一个词进行确认(或者,如果该节点已确认,则关闭确认)。该示例将鼠标释放事件转换为墨迹坐标。它使用 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)
' 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