返回后代 ContextNode 对象的集合,这些对象与已识别字符串中的指定文本范围相关。
命名空间: System.Windows.Ink
程序集: IAWinFX(在 IAWinFX.dll 中)
语法
声明
Public Function GetNodesFromTextRange ( _
ByRef start As Integer, _
ByRef length As Integer _
) As ContextNodeCollection
用法
Dim instance As RootNode
Dim start As Integer
Dim length As Integer
Dim returnValue As ContextNodeCollection
returnValue = instance.GetNodesFromTextRange(start, _
length)
public ContextNodeCollection GetNodesFromTextRange(
ref int start,
ref int length
)
public:
ContextNodeCollection^ GetNodesFromTextRange(
int% start,
int% length
)
public ContextNodeCollection GetNodesFromTextRange(
/** @ref */int start,
/** @ref */int length
)
public function GetNodesFromTextRange(
start : int,
length : int
) : ContextNodeCollection
参数
- start
类型:System.Int32%
- length
类型:System.Int32%
返回值
类型:System.Windows.Ink.ContextNodeCollection
后代 ContextNode 对象的集合,这些对象与已识别字符串中的指定文本范围相关。
备注
start 和 length 参数为引用值,可以进行更改以指定与返回的 ContextNodeCollection 相关联的整个字符串。例如,GetRecognizedString 的返回值是“I am late”,并且传入的值为 start = 6 和 length = 1(这些参数对应于字母“a”)。因此,ContextNodeCollection 可能只包含一个 ContextNode,即对应于单词“late”的 InkWordNode。在此示例中,start 的值更改为 5,而 length 的值更改为 4(对应于整个单词“late”)。
示例
下面的示例使用 GetNodesFromTextRange 方法标记对应于所选文本的笔画。该示例代码假定名为 theResultsTextBox 的 TextBox 的 Text 属性设置为 GetRecognizedString 方法返回的值,并假定用户已在 theResultsTextBox 中选择了某些文本。此示例还假定存在一个名为 theInkAnalyzer 的 InkAnalyzer。
Dim theRootNode As RootNode = CType(theInkAnalyzer.RootNode, RootNode)
' First, set all strokes to black
For Each stroke As Stroke In theRootNode.Strokes
stroke.DrawingAttributes.Color = Colors.Black
Next stroke
' Find out what's been selected in the text box
Dim selStart As Integer = theResultsTextBox.SelectionStart
Dim selLength As Integer = theResultsTextBox.SelectionLength
' Do nothing if no text is selected.
If selLength = 0 Then
Return
End If
' Get the nodes that correspond to that range
Dim selectedSubNodes As ContextNodeCollection = _
theRootNode.GetNodesFromTextRange(selStart, selLength)
' Use the new start and length value to update the
' selection in the TextBox
theResultsTextBox.SelectionStart = selStart
theResultsTextBox.SelectionLength = selLength
' Next, set all selected sub nodes to red
Dim node As ContextNode
For Each node In selectedSubNodes
Dim stroke As Stroke
For Each stroke In node.Strokes
stroke.DrawingAttributes.Color = Colors.Red
Next stroke
Next node
RootNode theRootNode = (RootNode)theInkAnalyzer.RootNode;
// First, set all strokes to black
foreach (Stroke stroke in theRootNode.Strokes)
stroke.DrawingAttributes.Color = Colors.Black;
// Find out what's been selected in the text box
int selStart = theResultsTextBox.SelectionStart;
int selLength = theResultsTextBox.SelectionLength;
// Do nothing if no text is selected.
if (selLength == 0)
{
return;
}
// Get the nodes that correspond to that range
ContextNodeCollection selectedSubNodes =
theRootNode.GetNodesFromTextRange(ref selStart, ref selLength);
// Use the new start and length value to update the
// selection in the TextBox
theResultsTextBox.SelectionStart = selStart;
theResultsTextBox.SelectionLength = selLength;
// Next, set all selected sub nodes to red
foreach (ContextNode node in selectedSubNodes)
{
foreach (Stroke stroke in node.Strokes)
{
stroke.DrawingAttributes.Color = Colors.Red;
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0