本文整理汇总了C#中ITextRunConstructionContext类的典型用法代码示例。如果您正苦于以下问题:C# ITextRunConstructionContext类的具体用法?C# ITextRunConstructionContext怎么用?C# ITextRunConstructionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITextRunConstructionContext类属于命名空间,在下文中一共展示了ITextRunConstructionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Colorize
protected override void Colorize(ITextRunConstructionContext context)
{
// if SelectionForeground is null, keep the existing foreground color
if (textArea.SelectionForeground == null)
return;
int lineStartOffset = context.VisualLine.FirstDocumentLine.Offset;
int lineEndOffset = context.VisualLine.LastDocumentLine.Offset + context.VisualLine.LastDocumentLine.TotalLength;
foreach (SelectionSegment segment in textArea.Selection.Segments) {
int segmentStart = segment.StartOffset;
int segmentEnd = segment.EndOffset;
if (segmentEnd <= lineStartOffset)
continue;
if (segmentStart >= lineEndOffset)
continue;
int startColumn;
if (segmentStart < lineStartOffset)
startColumn = 0;
else
startColumn = context.VisualLine.ValidateVisualColumn(segment.StartOffset, segment.StartVisualColumn, textArea.Selection.EnableVirtualSpace);
int endColumn;
if (segmentEnd > lineEndOffset)
endColumn = textArea.Selection.EnableVirtualSpace ? int.MaxValue : context.VisualLine.VisualLengthWithEndOfLineMarker;
else
endColumn = context.VisualLine.ValidateVisualColumn(segment.EndOffset, segment.EndVisualColumn, textArea.Selection.EnableVirtualSpace);
ChangeVisualElements(
startColumn, endColumn,
element => {
element.TextRunProperties.SetForegroundBrush(textArea.SelectionForeground);
});
}
}
示例2: Colorize
protected override void Colorize(ITextRunConstructionContext context)
{
// if SelectionForeground is null, keep the existing foreground color
if (textArea.SelectionForeground == null)
return;
int lineStartOffset = context.VisualLine.FirstDocumentLine.Offset;
int lineEndOffset = context.VisualLine.LastDocumentLine.Offset + context.VisualLine.LastDocumentLine.TotalLength;
foreach (ISegment segment in textArea.Selection.Segments) {
int segmentStart = segment.Offset;
int segmentEnd = segment.Offset + segment.Length;
if (segmentEnd <= lineStartOffset)
continue;
if (segmentStart >= lineEndOffset)
continue;
int startColumn = context.VisualLine.GetVisualColumn(Math.Max(0, segmentStart - lineStartOffset));
int endColumn = context.VisualLine.GetVisualColumn(segmentEnd - lineStartOffset);
ChangeVisualElements(
startColumn, endColumn,
element => {
element.TextRunProperties.SetForegroundBrush(textArea.SelectionForeground);
});
}
}
示例3: CreateTextRun
/// <inheritdoc/>
public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
{
if (context == null)
throw new ArgumentNullException("context");
return new InlineObjectRun(1, this.TextRunProperties, this.Element);
}
示例4: CreateTextRun
public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
{
this.TextRunProperties.SetTextDecorations(TextDecorations.Underline);
if (this._options.ErrorDecoration != null && !this._options.ErrorDecoration.Equals(String.Empty))
{
switch (this._options.ErrorDecoration)
{
case "Baseline":
this.TextRunProperties.SetTextDecorations(TextDecorations.Baseline);
break;
case "OverLine":
this.TextRunProperties.SetTextDecorations(TextDecorations.OverLine);
break;
case "Strikethrough":
this.TextRunProperties.SetTextDecorations(TextDecorations.Strikethrough);
break;
case "Underline":
this.TextRunProperties.SetTextDecorations(TextDecorations.Underline);
break;
}
}
this.TextRunProperties.SetBackgroundBrush(new SolidColorBrush(this._options.ErrorBackground));
this.TextRunProperties.SetForegroundBrush(new SolidColorBrush(this._options.ErrorForeground));
if (this._options.ErrorFontFace != null)
{
this.TextRunProperties.SetTypeface(new Typeface(this._options.ErrorFontFace, new FontStyle(), new FontWeight(), new FontStretch()));
}
return base.CreateTextRun(startVisualColumn, context);
}
示例5: CreateTextRun
/// <inheritdoc/>
public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
{
this.TextRunProperties.SetForegroundBrush(context.TextView.LinkTextForegroundBrush);
this.TextRunProperties.SetBackgroundBrush(context.TextView.LinkTextBackgroundBrush);
this.TextRunProperties.SetTextDecorations(TextDecorations.Underline);
return base.CreateTextRun(startVisualColumn, context);
}
示例6: Colorize
/// <inheritdoc/>
protected override void Colorize(ITextRunConstructionContext context)
{
if (context == null)
throw new ArgumentNullException(nameof(context));
CurrentContext = context;
currentDocumentLine = context.VisualLine.FirstDocumentLine;
firstLineStart = currentDocumentLineStartOffset = currentDocumentLine.Offset;
currentDocumentLineEndOffset = currentDocumentLineStartOffset + currentDocumentLine.Length;
if (context.VisualLine.FirstDocumentLine == context.VisualLine.LastDocumentLine)
{
ColorizeLine(currentDocumentLine);
}
else
{
ColorizeLine(currentDocumentLine);
// ColorizeLine modifies the visual line elements, loop through a copy of the line elements
foreach (VisualLineElement e in context.VisualLine.Elements.ToArray())
{
int elementOffset = firstLineStart + e.RelativeTextOffset;
if (elementOffset >= currentDocumentLineEndOffset)
{
currentDocumentLine = context.Document.GetLineByOffset(elementOffset);
currentDocumentLineStartOffset = currentDocumentLine.Offset;
currentDocumentLineEndOffset = currentDocumentLineStartOffset + currentDocumentLine.Length;
ColorizeLine(currentDocumentLine);
}
}
}
currentDocumentLine = null;
CurrentContext = null;
}
示例7: GetColor
/// <summary>
/// Gets the color of the brush.
/// </summary>
/// <param name="context">The construction context. context can be null!</param>
public virtual Color? GetColor(ITextRunConstructionContext context)
{
SolidColorBrush scb = GetBrush(context) as SolidColorBrush;
if (scb != null)
return scb.Color;
else
return null;
}
示例8: CreateTextRun
/// <inheritdoc/>
public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
{
if (context == null)
throw new ArgumentNullException("context");
int relativeOffset = startVisualColumn - VisualColumn;
string text = context.Document.GetText(context.VisualLine.FirstDocumentLine.Offset + RelativeTextOffset + relativeOffset, DocumentLength - relativeOffset);
return new TextCharacters(text, 0, text.Length, this.TextRunProperties);
}
示例9: CreateTextRun
/// <inheritdoc/>
public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
{
if (textLine == null) {
var formatter = TextFormatterFactory.Create(context.TextView);
textLine = PrepareText(formatter, this.text, this.TextRunProperties);
this.text = null;
}
return new FormattedTextRun(this, this.TextRunProperties);
}
示例10: GetPrecedingText
/// <inheritdoc/>
public override TextSpan<CultureSpecificCharacterBufferRange> GetPrecedingText(int visualColumnLimit, ITextRunConstructionContext context)
{
if (context == null)
throw new ArgumentNullException(nameof(context));
int relativeOffset = visualColumnLimit - VisualColumn;
StringSegment text = context.GetText(context.VisualLine.FirstDocumentLine.Offset + RelativeTextOffset, relativeOffset);
CharacterBufferRange range = new CharacterBufferRange(text.Text, text.Offset, text.Count);
return new TextSpan<CultureSpecificCharacterBufferRange>(range.Length, new CultureSpecificCharacterBufferRange(TextRunProperties.CultureInfo, range));
}
示例11: StartGeneration
/// <inheritdoc/>
public override void StartGeneration(ITextRunConstructionContext context)
{
base.StartGeneration(context);
if (foldingManager != null) {
if (!foldingManager.textViews.Contains(context.TextView))
throw new ArgumentException("Invalid TextView");
if (context.Document != foldingManager.document)
throw new ArgumentException("Invalid document");
}
}
示例12: LineIsCode
private bool LineIsCode(ITextRunConstructionContext context, SortedList<int, object> content)
{
if (content.IsNull())
return false;
var codeLines = content.Where(x => !(x.Value is string)).Select(x => x.Key);
var line = context.VisualLine.LastDocumentLine.LineNumber;
if (codeLines.Contains(line))
return true;
return false;
}
示例13: CreateTextRun
/// <inheritdoc/>
public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
{
if (context == null)
throw new ArgumentNullException("context");
// remove inline object if its already added, can happen e.g. when recreating textrun for word-wrapping
// TODO: certainly the text view should handle this internally? external code might want to use InlineObjectRun,
// but doesn't have access to textLayer.RemoveInlineObject
context.TextView.textLayer.RemoveInlineObject(this.Element);
return new InlineObjectRun(1, this.TextRunProperties, this.Element);
}
示例14: Transform
/// <summary>
/// <see cref="IVisualLineTransformer.Transform"/> implementation.
/// Sets <see cref="CurrentElements"/> and calls <see cref="Colorize"/>.
/// </summary>
public void Transform(ITextRunConstructionContext context, IList<VisualLineElement> elements)
{
if (elements == null)
throw new ArgumentNullException("elements");
if (this.CurrentElements != null)
throw new InvalidOperationException("Recursive Transform() call");
this.CurrentElements = elements;
try {
Colorize(context);
} finally {
this.CurrentElements = null;
}
}
示例15: Transform
public void Transform(ITextRunConstructionContext context, IList<VisualLineElement> elements)
{
foreach (VisualLineElement element in elements)
{
//if (element is EscapeSequenceElement)
//{
// currentEscapeSequence = (EscapeSequenceElement)element;
//}
//else if (currentEscapeSequence != null)
//{
// element.TextRunProperties.SetForegroundBrush(currentEscapeSequence.ForegroundBrush);
//}
}
}