本文整理汇总了C#中ITextViewLine类的典型用法代码示例。如果您正苦于以下问题:C# ITextViewLine类的具体用法?C# ITextViewLine怎么用?C# ITextViewLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITextViewLine类属于命名空间,在下文中一共展示了ITextViewLine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateAndAddAdornment
void CreateAndAddAdornment(ITextViewLine line, SnapshotSpan span, Brush brush, bool extendToRight)
{
var markerGeometry = _view.TextViewLines.GetMarkerGeometry(span);
double left = 0;
double width = _view.ViewportWidth + _view.MaxTextRightCoordinate;
if (markerGeometry != null)
{
left = markerGeometry.Bounds.Left;
if (!extendToRight) width = markerGeometry.Bounds.Width;
}
Rect rect = new Rect(left, line.Top, width, line.Height);
RectangleGeometry geometry = new RectangleGeometry(rect);
GeometryDrawing drawing = new GeometryDrawing(brush, new Pen(), geometry);
drawing.Freeze();
DrawingImage drawingImage = new DrawingImage(drawing);
drawingImage.Freeze();
Image image = new Image();
image.Source = drawingImage;
Canvas.SetLeft(image, geometry.Bounds.Left);
Canvas.SetTop(image, geometry.Bounds.Top);
_layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
}
开发者ID:ijprest,项目名称:BackgroundColorFix,代码行数:30,代码来源:BackgroundColorVisualManager.cs
示例2: CreateVisuals
/// <summary>
/// Within the given line add the scarlet box behind the a
/// </summary>
private void CreateVisuals(ITextViewLine line)
{
//grab a reference to the lines in the current TextView
IWpfTextViewLineCollection textViewLines = _view.TextViewLines;
int start = line.Start;
int end = line.End;
//Loop through each character, and place a box around any a
for (int i = start; (i < end); ++i)
{
if (_view.TextSnapshot[i] == 'a')
{
SnapshotSpan span = new SnapshotSpan(_view.TextSnapshot, Span.FromBounds(i, i + 1));
Geometry g = textViewLines.GetMarkerGeometry(span);
if (g != null)
{
GeometryDrawing drawing = new GeometryDrawing(_brush, _pen, g);
drawing.Freeze();
DrawingImage drawingImage = new DrawingImage(drawing);
drawingImage.Freeze();
Image image = new Image();
image.Source = drawingImage;
//Align the image with the top of the bounds of the text geometry
Canvas.SetLeft(image, g.Bounds.Left);
Canvas.SetTop(image, g.Bounds.Top);
_layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
}
}
}
}
开发者ID:AlmatoolboxCE,项目名称:AlmaStyleFix,代码行数:37,代码来源:TextAdornment1.cs
示例3: UpdateVisual
/// <summary>
/// Store <paramref name="timeStamp"/> and updates the text for the visual.
/// </summary>
/// <param name="timeStamp">Time of the event.</param>
/// <param name="line">The line that this time stamp corresponds to.</param>
/// <param name="view">The <see cref="IWpfTextView"/> to whom the <paramref name="line"/> belongs.</param>
/// <param name="formatting">Properties for the time stamp text.</param>
/// <param name="marginWidth">Used to calculate the horizontal offset for <see cref="OnRender(DrawingContext)"/>.</param>
/// <param name="verticalOffset">Used to calculate the vertical offset for <see cref="OnRender(DrawingContext)"/>.</param>
/// <param name="showHours">Option to show hours on the time stamp.</param>
/// <param name="showMilliseconds">Option to show milliseconds on the time stamp.</param>
internal void UpdateVisual(DateTime timeStamp, ITextViewLine line, IWpfTextView view, TextRunProperties formatting, double marginWidth, double verticalOffset,
bool showHours, bool showMilliseconds)
{
this.LineTag = line.IdentityTag;
if (timeStamp != this.TimeStamp)
{
this.TimeStamp = timeStamp;
string text = GetFormattedTime(timeStamp, showHours, showMilliseconds);
TextFormattingMode textFormattingMode = view.FormattedLineSource.UseDisplayMode ? TextFormattingMode.Display : TextFormattingMode.Ideal;
_text = new FormattedText(text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight,
formatting.Typeface, formatting.FontRenderingEmSize, formatting.ForegroundBrush,
InvariantNumberSubstitution, textFormattingMode);
_horizontalOffset = Math.Round(marginWidth - _text.Width);
this.InvalidateVisual(); // force redraw
}
double newVerticalOffset = line.TextTop - view.ViewportTop + verticalOffset;
if (newVerticalOffset != _verticalOffset)
{
_verticalOffset = newVerticalOffset;
this.InvalidateVisual(); // force redraw
}
}
开发者ID:xornand,项目名称:VS-PPT,代码行数:36,代码来源:TimeStampVisual.cs
示例4: Update
internal void Update(
string text,
ITextViewLine line,
IWpfTextView view,
TextRunProperties formatting,
double marginWidth,
double verticalOffset)
{
LineTag = line.IdentityTag;
if (_text == null || !string.Equals(_text, text, StringComparison.Ordinal))
{
_text = text;
_formattedText = new FormattedText(
_text,
CultureInfo.InvariantCulture,
FlowDirection.LeftToRight,
formatting.Typeface,
formatting.FontRenderingEmSize,
formatting.ForegroundBrush);
_horizontalOffset = Math.Round(marginWidth - _formattedText.Width);
InvalidateVisual();
}
var num = line.TextTop - view.ViewportTop + verticalOffset;
// ReSharper disable once CompareOfFloatsByEqualityOperator
if (num == _verticalOffset) return;
_verticalOffset = num;
InvalidateVisual();
}
开发者ID:kazu46,项目名称:VSColorOutput,代码行数:31,代码来源:TimeStampVisual.cs
示例5: CreateVisuals
/// <summary>
/// Adds the adornment behind the "TODO"s within the given line
/// </summary>
/// <param name="line"></param>
private void CreateVisuals(ITextViewLine line)
{
var textViewLines = _wpfTextView.TextViewLines;
var text = line.Extent.GetText();
// TODO: Add support for block comments
var todoRegex = new Regex(@"\/\/\s*TODO\b", RegexOptions.IgnoreCase);
var match = todoRegex.Match(text);
while (match.Success)
{
var matchStart = match.Index;
var lineStart = line.Extent.Start.Position;
var span = new SnapshotSpan(_wpfTextView.TextSnapshot, Span.FromBounds(matchStart + lineStart, matchStart + lineStart + match.Length));
DrawAdornment(textViewLines, span);
match = match.NextMatch();
}
// TODO: Evaluate the performance of below algo and RegEx
/*// Loop through each character
for (int charIndex = line.Start; charIndex < line.End; charIndex++)
{
// Check if the current letter is 'T' and the buffer is large enough so that a "TODO" may exist
if (_wpfTextView.TextSnapshot[charIndex] == 'T' && charIndex + 4 < line.End)
{
// Get a string of 4 characters starting from the 'T'
string snapshot = _wpfTextView.TextSnapshot.GetText(charIndex, 4);
// Is the string a TODO?
if (snapshot.Equals("TODO"))
{
SnapshotSpan span = new SnapshotSpan(_wpfTextView.TextSnapshot, Span.FromBounds(charIndex, charIndex + 4));
DrawAdornment(textViewLines, span);
}
}
}*/
}
开发者ID:hashhar,项目名称:VS-Task-Tags,代码行数:37,代码来源:Highlighter.cs
示例6: GetPositionedCodeTag
private UIElement GetPositionedCodeTag(ITextViewLine line, IWpfTextViewLineCollection textViewLines, Geometry geometry)
{
int lineNumber = _view.TextSnapshot.GetLineNumberFromPosition(line.Start.Position) + 1;
UIElement codeTagElement = CodeLine.ElementAt(lineNumber, GetFilename);
PlaceVisualNextToGeometry(geometry, codeTagElement);
return codeTagElement;
}
开发者ID:halllo,项目名称:MTSS12,代码行数:7,代码来源:CodeTagsEditorAdornment.cs
示例7: CreateVisuals
private void CreateVisuals(ITextViewLine line)
{
IWpfTextViewLineCollection textViewLines = _view.TextViewLines;
SnapshotSpan span = new SnapshotSpan(_view.TextSnapshot, Span.FromBounds(line.Start, line.End));
if (span.GetText().IsMethodDefinition())
AddAdornmentToMethod(line, textViewLines, span);
}
开发者ID:halllo,项目名称:MTSS12,代码行数:7,代码来源:CodeTagsEditorAdornment.cs
示例8: CreateVisuals
private void CreateVisuals(ITextViewLine line)
{
IWpfTextViewLineCollection textViewLines = view.TextViewLines;
if ( textViewLines == null )
return; // not ready yet.
SnapshotSpan span = line.Extent;
Rect rc = new Rect(
new Point(line.Left, line.Top),
new Point(Math.Max(view.ViewportRight - 2, line.Right), line.Bottom)
);
if ( NeedsNewImage(rc) ) {
Geometry g = new RectangleGeometry(rc, 1.0, 1.0);
GeometryDrawing drawing = new GeometryDrawing(fillBrush, borderPen, g);
drawing.Freeze();
DrawingImage drawingImage = new DrawingImage(drawing);
drawingImage.Freeze();
Image image = new Image();
// work around WPF rounding bug
image.UseLayoutRounding = false;
image.Source = drawingImage;
currentHighlight = image;
}
//Align the image with the top of the bounds of the text geometry
Canvas.SetLeft(currentHighlight, rc.Left);
Canvas.SetTop(currentHighlight, rc.Top);
layer.AddAdornment(
AdornmentPositioningBehavior.TextRelative, span,
CUR_LINE_TAG, currentHighlight, null
);
}
开发者ID:tomasr,项目名称:LineAdornments,代码行数:33,代码来源:LineHighlight.cs
示例9: Draw
public void Draw(ITextViewLine line, Rect lineRect)
{
if (executionProvider.Running)
return;
if (line.LineNumber == executionProvider.Location.LineNumber - 1)
Draw (lineRect);
}
开发者ID:shana,项目名称:debugger,代码行数:7,代码来源:ExecutingLineAdornment.cs
示例10: CreateVisuals
private void CreateVisuals(ITextViewLine line)
{
if ( !IsEnabled() ) {
return; // not enabled
}
IWpfTextViewLineCollection textViewLines = view.TextViewLines;
if ( textViewLines == null )
return; // not ready yet.
SnapshotSpan span = line.Extent;
Rect rc = new Rect(
new Point(view.ViewportLeft, line.TextTop),
new Point(Math.Max(view.ViewportRight - 2, line.TextRight), line.TextBottom)
);
lineRect.Width = rc.Width;
lineRect.Height = rc.Height;
//Align the image with the top of the bounds of the text geometry
Canvas.SetLeft(lineRect, rc.Left);
Canvas.SetTop(lineRect, rc.Top);
layer.AddAdornment(
AdornmentPositioningBehavior.TextRelative, span,
CUR_LINE_TAG, lineRect, null
);
}
开发者ID:ssatta,项目名称:viasfora,代码行数:26,代码来源:CurrentLineAdornment.cs
示例11: GetLineTransform
public LineTransform GetLineTransform(ITextViewLine line, double yPosition, ViewRelativePosition placement) {
var transform = removeExtraTextLineVerticalPixels ?
new LineTransform(0, 0, line.DefaultLineTransform.VerticalScale, line.DefaultLineTransform.Right) :
line.DefaultLineTransform;
foreach (var source in lineTransformSources)
transform = LineTransform.Combine(transform, source.GetLineTransform(line, yPosition, placement));
return transform;
}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:8,代码来源:LineTransformProviderService.cs
示例12: Repaint
public void Repaint(ITextViewLine line, Rect marginRect)
{
var breakpoint = GetBreakpoint (line);
if (breakpoint != null)
Draw (marginRect,
breakpointProvider.IsBound (breakpoint), breakpoint.Enabled
);
}
开发者ID:shana,项目名称:debugger,代码行数:8,代码来源:BreakPointMargin.cs
示例13: AddAdornmentToMethod
private void AddAdornmentToMethod(ITextViewLine line, IWpfTextViewLineCollection textViewLines, SnapshotSpan span)
{
Geometry geometry = textViewLines.GetMarkerGeometry(span);
if (geometry != null)
{
UIElement codeTagElement = GetPositionedCodeTag(line, textViewLines, geometry);
_layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, codeTagElement, null);
}
}
开发者ID:halllo,项目名称:MTSS12,代码行数:9,代码来源:CodeTagsEditorAdornment.cs
示例14: GetSpan
public VirtualSnapshotSpan GetSpan(ITextViewLine line) {
if (textSelection.TextView.TextSnapshot != textSnapshot)
throw new InvalidOperationException();
var start = line.GetInsertionBufferPositionFromXCoordinate(xLeft);
var end = line.GetInsertionBufferPositionFromXCoordinate(xRight);
if (start <= end)
return new VirtualSnapshotSpan(start, end);
return new VirtualSnapshotSpan(end, start);
}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:9,代码来源:BoxSelectionHelper.cs
示例15: MouseLocation
MouseLocation(ITextViewLine textViewLine, VirtualSnapshotPoint position, Point point) {
if (textViewLine == null)
throw new ArgumentNullException(nameof(textViewLine));
TextViewLine = textViewLine;
Position = position;
Affinity = textViewLine.IsLastTextViewLineForSnapshotLine || position.Position != textViewLine.End ? PositionAffinity.Successor : PositionAffinity.Predecessor;
Debug.Assert(position.VirtualSpaces == 0 || Affinity == PositionAffinity.Successor);
Point = point;
}
开发者ID:0xd4d,项目名称:dnSpy,代码行数:9,代码来源:MouseLocation.cs
示例16: Repaint
public void Repaint(ITextViewLine line, Rect marginRect)
{
if (Event.current.type != EventType.repaint)
return;
var orgColor = GUI.color;
GUI.color = _appearance.LineNumberColor;
_appearance.LineNumber.Draw(marginRect, (line.LineNumber + 1).ToString(), false, false, false, false);
GUI.color = orgColor;
}
开发者ID:madsnyholm,项目名称:CodeEditor,代码行数:10,代码来源:LineNumberMargin.cs
示例17: HandleInputEvent
public void HandleInputEvent(ITextViewLine line, Rect marginRect)
{
if (Event.current.type != EventType.mouseDown)
return;
if (!marginRect.Contains(Event.current.mousePosition))
return;
SetBreakPoint(line);
}
开发者ID:Smilediver,项目名称:debugger,代码行数:10,代码来源:BreakPointMargin.cs
示例18: GetLineNumber
protected override int? GetLineNumber(ITextViewLine viewLine, ref LineNumberState state) {
if (!viewLine.IsFirstTextViewLineForSnapshotLine)
return null;
if (state == null)
state = new LineNumberState();
if (state.SnapshotLine == null || state.SnapshotLine.EndIncludingLineBreak != viewLine.Start)
state.SnapshotLine = viewLine.Start.GetContainingLine();
else
state.SnapshotLine = state.SnapshotLine.Snapshot.GetLineFromLineNumber(state.SnapshotLine.LineNumber + 1);
return state.SnapshotLine.LineNumber + 1;
}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:11,代码来源:LineNumberMargin.cs
示例19: DoAddAdornment
private void DoAddAdornment(ITextViewLine line, Rect area)
{
IWpfTextViewLineCollection textViewLines = m_view.TextViewLines;
// Align the image with the top of the bounds of the text geometry
Canvas.SetLeft(m_adornment, area.Left);
Canvas.SetTop(m_adornment, area.Top);
m_layer.AddAdornment(
AdornmentPositioningBehavior.TextRelative, line.Extent,
AdornmentName, m_adornment, null);
}
开发者ID:gramcha,项目名称:XFeatures,代码行数:12,代码来源:HighlightLine.cs
示例20: GetStartPositionAfterLines
internal static int GetStartPositionAfterLines(this ITextView textView, ITextViewLine line, int currentLineDifference)
{
var lineNumber = textView.TextBuffer.GetLineNumber(line.Start) + currentLineDifference;
if (lineNumber >= textView.TextBuffer.CurrentSnapshot.LineCount)
{
lineNumber = textView.TextBuffer.CurrentSnapshot.LineCount - 1;
}
var currentLine = textView.TextSnapshot.GetLineFromLineNumber(lineNumber);
return currentLine.Start.Position;
}
开发者ID:ActualAdam,项目名称:EmacsKeys,代码行数:12,代码来源:IVsTextViewExtensions.cs
注:本文中的ITextViewLine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论