本文整理汇总了C#中ITextView.GetTextElementSpan方法的典型用法代码示例。如果您正苦于以下问题:C# ITextView.GetTextElementSpan方法的具体用法?C# ITextView.GetTextElementSpan怎么用?C# ITextView.GetTextElementSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextView
的用法示例。
在下文中一共展示了ITextView.GetTextElementSpan方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowColourSwatch
/// <summary>
/// If the text position is within a colour then show that could on the screen
/// </summary>
/// <param name="position"></param>
/// <param name="textPosition"></param>
/// <param name="textView"></param>
private void ShowColourSwatch(int position, IMappingPoint textPosition, ITextView textView)
{
_layer.RemoveAllAdornments();
SnapshotPoint? snapPoint = textPosition.GetPoint(textPosition.AnchorBuffer, PositionAffinity.Predecessor);
if (snapPoint.HasValue)
{
SnapshotSpan charSpan = textView.GetTextElementSpan(snapPoint.Value);
var colourPos = _colourPositions.Find(cp => (cp.Item1 <= charSpan.Start) && (cp.Item2 >= charSpan.Start));
if(colourPos != null)
{
Image image = CreateSwatchImage(colourPos, charSpan);
_layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, charSpan, null, image, null);
Thread t = new Thread(p =>
{
Thread.Sleep(3500);
lock (lockObject)
{
Application.Current.Dispatcher.Invoke(new Action(() =>
{
_layer.RemoveAdornmentsByVisualSpan(charSpan);
}), new object[]{});
}
});
t.Start();
}
}
}