/// <summary> /// Adds the scarlet box around a line with an error /// </summary> /// <param name="line">Line to add the adornments</param> private void CreateVisuals(SnapshotPoint start, SnapshotPoint end) { IWpfTextViewLineCollection textViewLines = this.view.TextViewLines; SnapshotSpan span = new SnapshotSpan(this.view.TextSnapshot, Span.FromBounds(start, end)); Geometry geometry = textViewLines.GetMarkerGeometry(span); if (geometry != null) { var drawing = new GeometryDrawing(this.brush, this.pen, geometry); drawing.Freeze(); var drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); var image = new Image { Source = drawingImage, }; // Align the image with the top of the bounds of the text geometry Canvas.SetLeft(image, geometry.Bounds.Left); Canvas.SetTop(image, geometry.Bounds.Top); this.layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null); } }
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(this.view.ViewportLeft, line.TextTop), new Point(Math.Max(this.view.ViewportRight - 2, line.TextRight), line.TextBottom) ); this.lineRect.Width = rc.Width; this.lineRect.Height = rc.Height; //Align the image with the top of the bounds of the text geometry Canvas.SetLeft(this.lineRect, rc.Left); Canvas.SetTop(this.lineRect, rc.Top); this.layer.AddAdornment( AdornmentPositioningBehavior.TextRelative, span, CUR_LINE_TAG, this.lineRect, null ); }
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); }
/// <summary> /// Within the given line add the scarlet box behind the a /// </summary> private void CreateVisuals(Span lineSpan) { //grab a reference to the lines in the current TextView IWpfTextViewLineCollection textViewLines = _view.TextViewLines; SnapshotPoint start = textViewLines.ElementAt(lineSpan.Start).Start; SnapshotPoint end = textViewLines.ElementAt(lineSpan.End).Start; SnapshotSpan span = new SnapshotSpan(start, end.Position - start.Position); 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); } }
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; }
/// <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); } } } }
private void CreateSensitiveCodeMarkerVisuals(NormalizedSnapshotSpanCollection sensitiveTextSpans, ITextSnapshot newSnapshot) { _layer.RemoveAllAdornments(); foreach (var span in sensitiveTextSpans) { IWpfTextViewLineCollection textViewLines = _view.TextViewLines; var geometry = textViewLines.GetMarkerGeometry(span); if (geometry != null) { var drawing = new GeometryDrawing(_brush, _pen, geometry); drawing.Freeze(); var drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); var image = new Image { Source = drawingImage, }; // Align the image with the top of the bounds of the text geometry Canvas.SetLeft(image, geometry.Bounds.Left); Canvas.SetTop(image, geometry.Bounds.Top); _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null); } } }
/// <summary> /// 设置单词颜色 /// </summary> private void ColorWords() { IWpfTextViewLineCollection textViewLines = this._view.TextViewLines; foreach (SnapshotSpan snapshotSpan in this.SnapShotsToColor) { try { Geometry markerGeometry = textViewLines.GetMarkerGeometry(snapshotSpan); if (markerGeometry != null) { GeometryDrawing geometryDrawing = new GeometryDrawing(this._brush, this._pen, markerGeometry); geometryDrawing.Freeze(); DrawingImage drawingImage = new DrawingImage(geometryDrawing); drawingImage.Freeze(); Image image = new Image(); image.Source = drawingImage; Canvas.SetLeft(image, markerGeometry.Bounds.Left); Canvas.SetTop(image, markerGeometry.Bounds.Top); this._layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, new SnapshotSpan?(snapshotSpan), null, image, null); } } catch { } } }
/// <summary> /// Adds the scarlet box behind the 'a' characters within the given line /// </summary> /// <param name="line">Line to add the adornments</param> private void CreateVisuals(ITextViewLine line) { IWpfTextViewLineCollection textViewLines = view.TextViewLines; // Loop through each character, and place a box around any 'a' for (int charIndex = line.Start; charIndex < line.End; charIndex++) { if (view.TextSnapshot[charIndex] == 'a') { SnapshotSpan span = new SnapshotSpan(view.TextSnapshot, Span.FromBounds(charIndex, charIndex + 1)); Geometry geometry = textViewLines.GetMarkerGeometry(span); if (geometry != null) { var drawing = new GeometryDrawing(brush, pen, geometry); drawing.Freeze(); var drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); var image = new Image { Source = drawingImage, }; // Align the image with the top of the bounds of the text geometry Canvas.SetLeft(image, geometry.Bounds.Left); Canvas.SetTop(image, geometry.Bounds.Top); layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, this, image, null); } } } }
private void SetBoundary(IWpfTextViewLineCollection textViewLines, SnapshotSpan span) { var g = textViewLines.GetMarkerGeometry(span); if (g == null) { return; } var drawing = new GeometryDrawing(_brush, _pen, g); drawing.Freeze(); var drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); var image = new 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); }
private void AddNavigateToPoint(IWpfTextViewLineCollection textViewLines, SnapshotPoint point, string key) { _navigateMap[key] = point; var resourceDictionary = _editorFormatMap.GetProperties(EasyMotionNavigateFormatDefinition.Name); var span = new SnapshotSpan(point, key.Length); var bounds = textViewLines.GetCharacterBounds(point); var label = new Label(); label.Content = key; label.FontFamily = _classificationFormatMap.DefaultTextProperties.Typeface.FontFamily; label.FontSize = 10.0; label.Foreground = resourceDictionary.GetForegroundBrush(EasyMotionNavigateFormatDefinition.DefaultForegroundBrush); label.Background = resourceDictionary.GetBackgroundBrush(EasyMotionNavigateFormatDefinition.DefaultBackgroundBrush); // textBox.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Canvas.SetTop(label, bounds.TextTop); Canvas.SetLeft(label, bounds.Left); Canvas.SetZIndex(label, 10); _adornmentLayer.AddAdornment(span, _tag, label); }
private void CreateVisualsForLetter(ITextViewLine line) { //grab a reference to the lines in the current TextView IWpfTextViewLineCollection textViewLines = this.textView.TextViewLines; int start = line.Start; int end = line.End; //Loop through each character, and place a box over item for (int i = start; (i < end); ++i) { if (this.textView.TextSnapshot[i].ToString().ToLower() == this.letter) { var span = new SnapshotSpan(this.textView.TextSnapshot, Span.FromBounds(i, i + 1)); Geometry g = textViewLines.GetMarkerGeometry(span); if (g != null) { // save the location of this letterTofind to jump to later string key = this.letterLocationSpans.AddSpan(span.Start); // Align the image with the top of the bounds of the text geometry var letterReference = new LetterReference(key, g.Bounds, 12); Canvas.SetLeft(letterReference, g.Bounds.Left); Canvas.SetTop(letterReference, g.Bounds.Top); this.aceLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, letterReference, null); } } } }
private void CreateVisuals(IWpfTextViewLineCollection textViewLines) { var map = _editorFormatMap.GetProperties(Constants.VsShowCharsFormatDefinitionName); var foregroundBrush = map.GetForegroundBrush(Constants.DefaultForegroundBrush); foreach (var textViewLine in textViewLines) { var span = new SnapshotSpan(textViewLine.End, textViewLine.EndIncludingLineBreak); if (span.Length == 0) { continue; } var text = GetLineBreakText(span.Snapshot, span.Start.Position); if (text == null) { continue; } var adornment = CreateAdornment(text, foregroundBrush); Geometry geometry = textViewLines.GetMarkerGeometry(span); Canvas.SetLeft(adornment, geometry.Bounds.Left); Canvas.SetTop(adornment, geometry.Bounds.Top); _adornmentLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, adornment, null); } }
private void CreateVisuals(ITextViewLine line) { IWpfTextViewLineCollection textViewLines = this.view.TextViewLines; for (int charIndex = line.Start; charIndex < line.End; charIndex++) { if (this.view.TextSnapshot[charIndex] == 'a') { SnapshotSpan span = new SnapshotSpan(this.view.TextSnapshot, Span.FromBounds(charIndex, charIndex + 1)); Geometry geometry = textViewLines.GetMarkerGeometry(span); if (geometry != null) { var drawing = new GeometryDrawing(this.brush, this.pen, geometry); drawing.Freeze(); var drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); var image = new Image { Source = drawingImage, }; Canvas.SetLeft(image, geometry.Bounds.Left); Canvas.SetTop(image, geometry.Bounds.Top); this.layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null); } } } }
private void CreateVisuals(IWpfTextViewLine line) { if (ShouldHighlightEntireLine(line)) { IWpfTextViewLineCollection textViewLines = _view.TextViewLines; var g = new RectangleGeometry(new Rect(0, line.TextTop, _lastWidth, (double)(int)(line.Height + 0.5))); SnapshotSpan span = new SnapshotSpan(line.Snapshot, new Span(line.Start, line.Length)); CreateHighlight(line, g, span); } }
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); } }
/// <summary> /// Retrieves relevant information to pass it to the line decorator /// </summary> /// <param name="line">Line to add the adornments</param> private void CreateVisuals(ITextViewLine line) { IWpfTextViewLineCollection textViewLines = this.view.TextViewLines; int start = line.Start; int end = line.End; string text = line.Snapshot.GetText(); this.decorator.DecorateLine(text, start, end); }
public void CreateVisuals() { layer.RemoveAllAdornments(); IWpfTextViewLineCollection textViewLines = this.view.TextViewLines; if (SelectNextCommandFilter.m_trackList == null) { return; } string currentSelection = view.Selection.SelectedSpans[view.Selection.SelectedSpans.Count - 1].GetText(); for (int i = 0; i < SelectNextCommandFilter.m_trackList.Count; i++) { int position = SelectNextCommandFilter.m_trackList[i].GetPosition(view.TextSnapshot); var trackingMode = SelectNextCommandFilter.m_trackList[i].TrackingMode; int start, end; if (trackingMode == PointTrackingMode.Negative) { start = position; end = position + currentSelection.Length; } else { start = position - currentSelection.Length; end = position; } SnapshotSpan span = new SnapshotSpan(this.view.TextSnapshot, Span.FromBounds(start, end)); Geometry geometry = textViewLines.GetMarkerGeometry(span); if (geometry != null) { var drawing = new GeometryDrawing(this.brush, this.pen, geometry); drawing.Freeze(); var drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); var image = new Image { Source = drawingImage, }; // Align the image with the top of the bounds of the text geometry Canvas.SetLeft(image, geometry.Bounds.Left); Canvas.SetTop(image, geometry.Bounds.Top); this.layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null); } } }
/// <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; foreach (var tag in this._createTagAggregator.GetTags(line.Extent)) { foreach (var span in tag.Span.GetSpans(_view.TextSnapshot)) { SetBoundary(textViewLines, span); } } }
private void AddComment(IWpfTextViewLineCollection textViewLines, SnapshotSpan span, ITextSnapshotLine line, string comment) { var g = textViewLines.GetMarkerGeometry(span); if (g == null) { return; } var commentPopup = new CommentPopup.CommentPopup(new CommentPopupViewModel(comment)); Canvas.SetTop(commentPopup, g.Bounds.Top - 2); Canvas.SetLeft(commentPopup, g.Bounds.Right + 5); _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, line.Extent, null, commentPopup, null); }
/// <summary> /// Adds a box to the end-of-line whitespace on the given line /// </summary> /// <param name="line">Line to add the adornments</param> private void CreateVisuals(ITextViewLine line) { IWpfTextViewLineCollection textViewLines = view.TextViewLines; //Ignore empty lines if (line.Length == 0) { return; } // Loop through each character from end to beginning, and place a box around spaces and tabs at the end of lines for (int charIndex = line.End - 1; charIndex >= line.Start; --charIndex) //for (int charIndex = line.Start; charIndex < line.End; charIndex++) { bool bIsSpace = (view.TextSnapshot[charIndex] == ' '); bool bIsTab = (view.TextSnapshot[charIndex] == '\t'); if (bIsSpace || bIsTab) { SnapshotSpan span = new SnapshotSpan(view.TextSnapshot, Span.FromBounds(charIndex, charIndex + 1)); Geometry geometry = textViewLines.GetMarkerGeometry(span); if (geometry != null) { var drawing = new GeometryDrawing(bIsSpace ? spacesBrush : tabsBrush, bIsSpace ? spacesPen : tabsPen, geometry); drawing.Freeze(); var drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); var image = new Image { Source = drawingImage, }; // Align the image with the top of the bounds of the text geometry Canvas.SetLeft(image, geometry.Bounds.Left); Canvas.SetTop(image, geometry.Bounds.Top); layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null); } } //Unable to find spaces or tabs at the end of the line, ignore the rest else { return; } } }
private void CreateVisuals(ITextViewLine line) { IWpfTextViewLineCollection textViewLines = view.TextViewLines; TryGetText(view, line, out string text); var regex = new Regex(@"\b(?=[а-яА-ЯёЁ]*[a-zA-Z])(?=[a-zA-Z]*[а-яА-ЯёЁ])[\wа-яА-ЯёЁ]+\b"); var match = regex.Match(text); while (match.Success) { var matchStart = line.Start.Position + match.Index; var span = new SnapshotSpan(view.TextSnapshot, Span.FromBounds(matchStart, matchStart + match.Length)); DrawAdornment(textViewLines, span); match = match.NextMatch(); } }
private void CreateVisuals(ITextViewLine line, int errorColumn, int Length) { IWpfTextViewLineCollection textViewLines = view.TextViewLines; int tabSize = this.view.Options.GetTabSize(); var fullSpan = new SnapshotSpan(line.Snapshot, Span.FromBounds(line.Start, line.End)); var snapLine = fullSpan.Start.GetContainingLine(); string text = snapLine.GetText(); int lineNumber = fullSpan.Start.GetContainingLine().LineNumber; int offset = this.GetLineOffsetFromColumn(text, errorColumn - 1, tabSize); // If Error does span on several lines, the length might be negative as we are using Column to calculate length if (Length < 1) { Length = 1; } // var iMax = line.End.Position; var iEnd = line.Start.Position + offset + Length; if (iEnd > iMax) { iEnd = iMax; } var start = line.Start + offset; var end = line.Start + (iEnd - line.Start.Position); var span = new SnapshotSpan(line.Snapshot, Span.FromBounds(start, end)); // Geometry g = textViewLines.GetMarkerGeometry(span); if (g != null) { var border = new Border { Width = g.Bounds.Width, Height = g.Bounds.Height / 8, BorderBrush = Brushes.Red, BorderThickness = new Thickness(0.8, 0, 0.8, 0.8), }; Canvas.SetLeft(border, g.Bounds.Left); Canvas.SetTop(border, g.Bounds.Bottom - g.Bounds.Height / 8); // layer.AddAdornment(span, null, border); } }
private void RenderVisuals(IEnumerable <SnapshotSpan> spans, ITextSnapshot snapshot) { //grab a reference to the lines in the current TextView IWpfTextViewLineCollection textViewLines = _textView.TextViewLines; bool updatedBrushes = false; foreach (var span in spans) { // only draw the existing trailing whitespace spans if (!_wsProvider.Contains(snapshot.GetLineNumberFromPosition(span.Start))) { continue; } Geometry g = textViewLines.GetMarkerGeometry(span); if (g != null) { // the first time we render, get the size of a whitespace character // and render the glyph to that size so we can tile it and it looks good // also do it we font size changes or background color changes if (!updatedBrushes) { var rect = textViewLines.GetMarkerGeometry(new SnapshotSpan(_textView.TextSnapshot, Span.FromBounds(span.Start, span.Start + 1))).Bounds; UpdateGlyphBrush(rect); } 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); } } }
internal void EndorseTextBounds(int lineStart, int lineEnd, int charStart, int charEnd) { if (applied) { throw new InvalidOperationException("This adornment is already applied."); } ITextSnapshot textSnapshot = view.TextSnapshot; ITextSnapshotLine textViewStartLine = textSnapshot.GetLineFromLineNumber(lineStart); ITextSnapshotLine textViewEndLine = textSnapshot.GetLineFromLineNumber(lineEnd); SnapshotSpan span = new SnapshotSpan( view.TextSnapshot, Span.FromBounds( textViewStartLine.Start + charStart, textViewEndLine.Start + charEnd)); IWpfTextViewLineCollection textViewLines = view.TextViewLines; Geometry geometry = textViewLines.GetMarkerGeometry(span); if (geometry != null) { var drawing = new GeometryDrawing(brush, pen, geometry); drawing.Freeze(); var drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); var image = new Image { Source = drawingImage, }; // Align the image with the top of the bounds of the text geometry Canvas.SetLeft(image, geometry.Bounds.Left); Canvas.SetTop(image, geometry.Bounds.Top); layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, this, image, null); } applied = true; }
/// <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 = textView.TextViewLines; int start = line.Start; int end = line.End; List <Geometry> geometries = new List <Geometry>(); var keywordFirstLetters = keywordFormats.Keys .Select(k => k[0]) .Distinct() .ToArray(); // Loop through each character and place a box around any registered keyword for (int i = start; i < end; i++) { if (keywordFirstLetters.Contains(textView.TextSnapshot[i])) // Performance optimisation { foreach (var kvp in keywordFormats) { string keyword = kvp.Key; if (textView.TextSnapshot[i] == keyword[0] && // Performance optimisation i <= end - keyword.Length && textView.TextSnapshot.GetText(i, keyword.Length) == keyword) { SnapshotSpan span = new SnapshotSpan(textView.TextSnapshot, Span.FromBounds(i, i + keyword.Length)); Geometry markerGeometry = textViewLines.GetMarkerGeometry(span); if (markerGeometry != null) { if (!geometries.Any(g => g.FillContainsWithDetail(markerGeometry) > IntersectionDetail.Empty)) { geometries.Add(markerGeometry); AddMarker(span, markerGeometry, kvp.Value); } } } } } } }
private void CreateVisuals(VirtualSnapshotPoint caretPosition) { if (!settings.CurrentColumnHighlightEnabled) { return; // not enabled } IWpfTextViewLineCollection textViewLines = view.TextViewLines; if (textViewLines == null) { return; // not ready yet. } // make sure the caret position is on the right buffer snapshot if (caretPosition.Position.Snapshot != this.view.TextBuffer.CurrentSnapshot) { return; } var line = this.view.GetTextViewLineContainingBufferPosition( caretPosition.Position ); var charBounds = line.GetCharacterBounds(caretPosition); this.columnRect.Width = charBounds.Width; this.columnRect.Height = this.view.ViewportHeight; if (this.columnRect.Height > 2) { this.columnRect.Height -= 2; } // Align the image with the top of the bounds of the text geometry Canvas.SetLeft(this.columnRect, charBounds.Left); Canvas.SetTop(this.columnRect, this.view.ViewportTop); layer.AddAdornment( AdornmentPositioningBehavior.OwnerControlled, null, CUR_COL_TAG, columnRect, null ); }
private void AddNavigateToPoint(IWpfTextViewLineCollection textViewLines, SnapshotSpan span, string key) { _navigateMap[key] = span; var resourceDictionary = _editorFormatMap.GetProperties(EasyMotionNavigateFormatDefinition.Name); var bounds = textViewLines.GetCharacterBounds(span.Start); var textBox = new TextBox(); textBox.Text = key; textBox.FontFamily = _classificationFormatMap.DefaultTextProperties.Typeface.FontFamily; textBox.Foreground = resourceDictionary.GetForegroundBrush(EasyMotionNavigateFormatDefinition.DefaultForegroundBrush); textBox.Background = resourceDictionary.GetBackgroundBrush(EasyMotionNavigateFormatDefinition.DefaultBackgroundBrush); textBox.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Canvas.SetTop(textBox, bounds.TextTop); Canvas.SetLeft(textBox, bounds.Left); Canvas.SetZIndex(textBox, 10); _adornmentLayer.AddAdornment(span, _tag, textBox); }
/// <summary> /// If line contains # region indicators, then add region adornment border to text. /// </summary> private void CreateVisuals(ITextViewLine currentLine) { //grab a reference to the lines in the current TextView IWpfTextViewLineCollection textViewLines = _textView.TextViewLines; for (int i = currentLine.Start; (i + 6 < currentLine.End); ++i) { var matchType = TestRegionStringMatch(i); if (matchType == RegionMatchType.None) { continue; } var textSpan = new SnapshotSpan(_textView.TextSnapshot, Span.FromBounds(i, i + 6)); var spanGeometry = textViewLines.GetMarkerGeometry(textSpan); if (spanGeometry == null) { continue; } AddBorderToText(currentLine, matchType, spanGeometry, textSpan); } }
internal void OnLayoutChanged(object sender, TextViewLayoutChangedEventArgs e) { this.layer.RemoveAllAdornments(); IWpfTextViewLineCollection textViewLines = this.view.TextViewLines; var errors = GetErrorList(); if (errors == null) { return; } foreach (var span in errors) { Geometry geometry = textViewLines.GetMarkerGeometry(span); if (geometry != null) { var drawing = new GeometryDrawing(this.brush, this.pen, geometry); drawing.Freeze(); var drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); var image = new Image { Source = drawingImage, }; // Align the image with the top of the bounds of the text geometry Canvas.SetLeft(image, geometry.Bounds.Left); Canvas.SetTop(image, geometry.Bounds.Top); this.layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null); } } }
private void CreateVisuals(IWpfTextViewLineCollection textViewLines) { foreach (var textViewLine in textViewLines) { var span = new SnapshotSpan(textViewLine.End, textViewLine.EndIncludingLineBreak); if (span.Length == 0) { continue; } var text = GetLineBreakText(span.Snapshot, span.Start.Position); if (text == null) { continue; } var adornment = CreateAdornment(text); Geometry geometry = textViewLines.GetMarkerGeometry(span); Canvas.SetLeft(adornment, geometry.Bounds.Left); Canvas.SetTop(adornment, geometry.Bounds.Top); _adornmentLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, adornment, null); } }
public void AddGlyph(string text, SnapshotSpan span) { IWpfTextViewLineCollection lines = _margin.TextView.TextViewLines; bool visible = _margin.TextView.TextViewLines.IntersectsBufferSpan(span); if (visible) { ITextViewLine line = GetStartingLine(lines, span, returnLastLine: true); if (line != null) { UIElement element = CreatePromptElement(text); element.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); double leftPlacement = (17.0 - element.DesiredSize.Width) / 2; Canvas.SetLeft(element, leftPlacement); GlyphData data = new GlyphData(span, element); data.SetTop(line.TextTop - _margin.TextView.ViewportTop); _glyphs[element] = data; _canvas.Children.Add(element); } } }
private void CreateVisuals(IWpfTextViewLineCollection textViewLines) { foreach (var textViewLine in textViewLines) { var span = new SnapshotSpan(textViewLine.End, textViewLine.EndIncludingLineBreak); if (span.Length == 0) { continue; } var text = GetLineBreakText(span.Snapshot, span.Start.Position); if (text == null) { continue; } var adornment = CreateAdornment(text); Geometry geometry = textViewLines.GetMarkerGeometry(span); Canvas.SetLeft(adornment, geometry.Bounds.Left); Canvas.SetTop(adornment, geometry.Bounds.Top); _adornmentLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, adornment, null); } }
private void DrawAdornment(IWpfTextViewLineCollection textViewLines, SnapshotSpan span) { var geometry = textViewLines.GetMarkerGeometry(span); if (geometry != null) { var drawing = new GeometryDrawing(_brush, _pen, geometry); drawing.Freeze(); var drawingImage = new DrawingImage(drawing); drawingImage.Freeze(); var image = new Image { Source = drawingImage, }; // Align the image with the top of the bounds of the text geometry Canvas.SetLeft(image, geometry.Bounds.Left); Canvas.SetTop(image, geometry.Bounds.Top); _adornmentLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null); } }
private void AddNavigateToPoint(IWpfTextViewLineCollection textViewLines, SnapshotPoint point, string key) { _navigateMap[key] = point; var resourceDictionary = _editorFormatMap.GetProperties(EasyMotionNavigateFormatDefinition.Name); var span = new SnapshotSpan(point, key.Length); var bounds = textViewLines.GetCharacterBounds(point); var label = new Label(); label.Content = key; label.FontFamily = _classificationFormatMap.DefaultTextProperties.Typeface.FontFamily; label.FontSize = 10.0; label.Foreground = resourceDictionary.GetForegroundBrush(EasyMotionNavigateFormatDefinition.DefaultForegroundBrush); label.Background = resourceDictionary.GetBackgroundBrush(EasyMotionNavigateFormatDefinition.DefaultBackgroundBrush); // textBox.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); Canvas.SetTop(label, bounds.TextTop); Canvas.SetLeft(label, bounds.Left); Canvas.SetZIndex(label, 10); _adornmentLayer.AddAdornment(span, _tag, label); }