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 (英文) 屬性先前已設定為 WritingRegionNodewritingRegion 的 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
執行緒安全
這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0