WritingRegionNode 类

表示一组具有相似方向的段落。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.dll 中)

语法

声明
Public NotInheritable Class WritingRegionNode _
    Inherits ContextNode
用法
Dim instance As WritingRegionNode
public sealed class WritingRegionNode : ContextNode
public ref class WritingRegionNode sealed : public ContextNode
public final class WritingRegionNode extends ContextNode
public final class WritingRegionNode extends ContextNode

备注

每个书写区域都有唯一的阅读顺序,如从上到下的顺序。

同一文档的同一页面中可以同时存在多个具有不同方向的书写区域。例如,如果用户主要在水平方向书写笔记,但随后在角落里斜着随意写了几个单词,那么这几个斜向的单词被视为具有不同的方向。将为这些斜向文本创建一个新的 WritingRegion

WritingRegionNode 对象可包含以下类型的子元素:

  • 任意数目的 ParagraphNode 对象。

  • 任意数目的具有未知 Guid 值的节点。

有关更多信息,请参见有关 WritingRegion 和 AlignmentLevel 的概念性主题。

示例

下面的示例使用一个 TextBox (selectedResultsTextBox),其 Text 属性事先设置为由 WritingRegionNode (writingRegion) 的 GetRecognizedString 返回的值。用户已经选中了 TextBox 中的部分文本。该示例代码标记与所选内容对应的 Strokes

' Find out what's been selected in the text box
Dim selectionStart As Integer = selectedResultsTextBox.SelectionStart
Dim selectionLength As Integer = selectedResultsTextBox.SelectionLength

' Return if no text is selected.
' selectionLength must be > 0 or GetNodesFromTextRange(...) 
' will throw an ArgumentOutOfRangeException
If selectionLength = 0 Then
    Return
End If

' Get the nodes that correspond to that range
Dim selectedRegionSubNodes As ContextNodeCollection = _
    writingRegion.GetNodesFromTextRange(selectionStart, selectionLength)

' Use the new start and length value to update the
' selection in the TextBox
selectedResultsTextBox.SelectionStart = selectionStart
selectedResultsTextBox.SelectionLength = selectionLength

' First, set all strokes to black
Dim inkStroke As Stroke
For Each inkStroke In writingRegion.Strokes
    inkStroke.DrawingAttributes = New DrawingAttributes(Color.Black)
Next inkStroke
' Next, set all selected sub nodes to red
Dim node As ContextNode
For Each node In selectedRegionSubNodes
    For Each inkStroke In node.Strokes
        inkStroke.DrawingAttributes = New DrawingAttributes(Color.Red)
    Next inkStroke
Next node
                    // Find out what's been selected in the text box
                    int selectionStart = selectedResultsTextBox.SelectionStart;
                    int selectionLength = selectedResultsTextBox.SelectionLength;

                    // Return if no text is selected.
                    // selectionLength must be > 0 or GetNodesFromTextRange(...) 
                    // will throw an ArgumentOutOfRangeException
                    if (selectionLength == 0)
                        return;

                    // Get the nodes that correspond to that range
                    ContextNodeCollection selectedRegionSubNodes =
                            writingRegion.GetNodesFromTextRange(ref selectionStart, ref selectionLength);


                    // Use the new start and length value to update the
                    // selection in the TextBox
                    selectedResultsTextBox.SelectionStart = selectionStart;
                    selectedResultsTextBox.SelectionLength = selectionLength;

                    // First, set all strokes to black
                    foreach (Stroke stroke in writingRegion.Strokes)
                        stroke.DrawingAttributes =
                                    new DrawingAttributes(Color.Black);
                    // Next, set all selected sub nodes to red
                    foreach (ContextNode node in selectedRegionSubNodes)
                    {
                        foreach (Stroke stroke in node.Strokes)
                        {
                            stroke.DrawingAttributes =
                                    new DrawingAttributes(Color.Red);
                        }
                    }

继承层次结构

System.Object
  Microsoft.Ink.ContextNode
    Microsoft.Ink.WritingRegionNode

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

WritingRegionNode 成员

Microsoft.Ink 命名空间