protected override Size ArrangeOverride(Size finalSize) { var pixelSize = PixelSnapHelpers.GetPixelSize(this); var textView = TextView; _visibleMarkers.Clear(); foreach (var marker in _markers) { RemoveVisualChild(marker); var visualLine = textView.GetVisualLine(marker.Breakpoint.Anchor.Line); if (visualLine == null) { continue; } _visibleMarkers.Add(marker); AddVisualChild(marker); var topLeft = new Point(0, visualLine.VisualTop - textView.VerticalOffset); marker.Arrange(new Rect(PixelSnapHelpers.Round(topLeft, pixelSize), marker.DesiredSize)); } return(base.ArrangeOverride(finalSize)); }
/// <summary> /// Adds the specified segment to the geometry. /// </summary> public void AddSegment(TextView textView, ISegment segment) { if (textView == null) { throw new ArgumentNullException("textView"); } Size pixelSize = PixelSnapHelpers.GetPixelSize(textView); foreach (Rect r in GetRectsForSegment(textView, segment)) { if (AlignToWholePixels) { AddRectangle(PixelSnapHelpers.Round(r.Left, pixelSize.Width), PixelSnapHelpers.Round(r.Top, pixelSize.Height), PixelSnapHelpers.Round(r.Right, pixelSize.Width), PixelSnapHelpers.Round(r.Bottom, pixelSize.Height)); } else if (AlignToMiddleOfPixels) { AddRectangle(PixelSnapHelpers.PixelAlign(r.Left, pixelSize.Width), PixelSnapHelpers.PixelAlign(r.Top, pixelSize.Height), PixelSnapHelpers.PixelAlign(r.Right, pixelSize.Width), PixelSnapHelpers.PixelAlign(r.Bottom, pixelSize.Height)); } else { AddRectangle(r.Left, r.Top, r.Right, r.Bottom); } } }
public override void Render(DrawingContext drawingContext) { base.Render(drawingContext); if (_isVisible && _blink) { var caretBrush = CaretBrush ?? TextView.GetValue(TextBlock.ForegroundProperty); if (_textArea.OverstrikeMode) { if (caretBrush is ISolidColorBrush scBrush) { var brushColor = scBrush.Color; var newColor = Color.FromArgb(100, brushColor.R, brushColor.G, brushColor.B); caretBrush = new SolidColorBrush(newColor); } } var r = new Rect(_caretRectangle.X - TextView.HorizontalOffset, _caretRectangle.Y - TextView.VerticalOffset, _caretRectangle.Width, _caretRectangle.Height); drawingContext.FillRectangle(caretBrush, PixelSnapHelpers.Round(r, PixelSnapHelpers.GetPixelSize(this))); } }
protected override void OnRender(DrawingContext drawingContext) { var renderSize = RenderSize; drawingContext.DrawRectangle(SystemColors.ControlBrush, null, new Rect(0, 0, renderSize.Width, renderSize.Height)); drawingContext.DrawLine(new Pen(SystemColors.ControlDarkBrush, 1), new Point(renderSize.Width - 0.5, 0), new Point(renderSize.Width - 0.5, renderSize.Height)); var textView = TextView; if (textView == null || !textView.VisualLinesValid) { return; } // create a dictionary line number => first bookmark var bookmarkDict = new Dictionary <int, IBookmark>(); foreach (var bm in _manager.Bookmarks) { var line = bm.LineNumber; IBookmark existingBookmark; if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder) { bookmarkDict[line] = bm; } } var pixelSize = PixelSnapHelpers.GetPixelSize(this); Rect rect; foreach (var line in textView.VisualLines) { var lineNumber = line.FirstDocumentLine.LineNumber; IBookmark bm; if (!bookmarkDict.TryGetValue(lineNumber, out bm)) { continue; } var lineMiddle = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextMiddle) - textView.VerticalOffset; rect = new Rect(0, PixelSnapHelpers.Round(lineMiddle - 8, pixelSize.Height), 16, 16); if (_dragDropBookmark == bm && _dragStarted) { drawingContext.PushOpacity(0.5); } drawingContext.DrawImage((bm.Image ?? BookmarkBase.defaultBookmarkImage).Bitmap, rect); if (_dragDropBookmark == bm && _dragStarted) { drawingContext.Pop(); } } if (_dragDropBookmark == null || !_dragStarted) { return; } rect = new Rect(0, PixelSnapHelpers.Round(_dragDropCurrentPoint - 8, pixelSize.Height), 16, 16); drawingContext.DrawImage((_dragDropBookmark.Image ?? BookmarkBase.defaultBookmarkImage).ImageSource, rect); }
protected override void OnRender(DrawingContext drawingContext) { FoldingMargin margin = VisualParent as FoldingMargin; Pen activePen = new Pen(margin.SelectedFoldingMarkerBrush, 1); Pen inactivePen = new Pen(margin.FoldingMarkerBrush, 1); activePen.StartLineCap = inactivePen.StartLineCap = PenLineCap.Square; activePen.EndLineCap = inactivePen.EndLineCap = PenLineCap.Square; Size pixelSize = PixelSnapHelpers.GetPixelSize(this); Rect rect = new Rect(pixelSize.Width / 2, pixelSize.Height / 2, this.RenderSize.Width - pixelSize.Width, this.RenderSize.Height - pixelSize.Height); drawingContext.DrawRectangle( IsMouseDirectlyOver ? margin.SelectedFoldingMarkerBackgroundBrush : margin.FoldingMarkerBackgroundBrush, IsMouseDirectlyOver ? activePen : inactivePen, rect); double middleX = rect.Left + rect.Width / 2; double middleY = rect.Top + rect.Height / 2; double space = PixelSnapHelpers.Round(rect.Width / 8, pixelSize.Width) + pixelSize.Width; drawingContext.DrawLine(activePen, new Point(rect.Left + space, middleY), new Point(rect.Right - space, middleY)); if (!isExpanded) { drawingContext.DrawLine(activePen, new Point(middleX, rect.Top + space), new Point(middleX, rect.Bottom - space)); } }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); if (isVisible && blink) { Brush caretBrush = this.CaretBrush; if (caretBrush == null) { caretBrush = (Brush)textView.GetValue(TextBlock.ForegroundProperty); } if (this.textArea.OverstrikeMode) { SolidColorBrush scBrush = caretBrush as SolidColorBrush; if (scBrush != null) { Color brushColor = scBrush.Color; Color newColor = Color.FromArgb(100, brushColor.R, brushColor.G, brushColor.B); caretBrush = new SolidColorBrush(newColor); caretBrush.Freeze(); } } Rect r = new Rect(caretRectangle.X - textView.HorizontalOffset, caretRectangle.Y - textView.VerticalOffset, caretRectangle.Width, caretRectangle.Height); drawingContext.DrawRectangle(caretBrush, null, PixelSnapHelpers.Round(r, PixelSnapHelpers.GetPixelSize(this))); } }
protected override void OnRender(DrawingContext drawingContext) { Pen blackPen = new Pen(Brushes.Black, 1); blackPen.StartLineCap = PenLineCap.Square; blackPen.EndLineCap = PenLineCap.Square; Size pixelSize = PixelSnapHelpers.GetPixelSize(this); Rect rect = new Rect(pixelSize.Width / 2, pixelSize.Height / 2, this.RenderSize.Width - pixelSize.Width, this.RenderSize.Height - pixelSize.Height); drawingContext.DrawRectangle(Brushes.White, IsMouseDirectlyOver ? blackPen : new Pen(Brushes.Gray, 1), rect); double middleX = rect.Left + rect.Width / 2; double middleY = rect.Top + rect.Height / 2; double space = PixelSnapHelpers.Round(rect.Width / 8, pixelSize.Width) + pixelSize.Width; drawingContext.DrawLine(blackPen, new Point(rect.Left + space, middleY), new Point(rect.Right - space, middleY)); if (!isExpanded) { drawingContext.DrawLine(blackPen, new Point(middleX, rect.Top + space), new Point(middleX, rect.Bottom - space)); } }
void DrawLineForInsertionPoint(int index, Pen pen, DrawingContext drawingContext) { var pos = GetLinePosition(index); var endPos = new Point(pos.X + editor.TextView.ActualWidth * 0.6, pos.Y); var pixelSize = PixelSnapHelpers.GetPixelSize(this); drawingContext.DrawLine(pen, PixelSnapHelpers.Round(pos, pixelSize), PixelSnapHelpers.Round(endPos, pixelSize)); }
public void Render(DrawingContext drawingContext, VisualLine line, Size pixelSize) { var lineMiddle = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextMiddle) - _textView.VerticalOffset; var rect = new Rect(3, PixelSnapHelpers.Round(lineMiddle - 8, pixelSize.Height) + 1, 14, 14); drawingContext.DrawRoundedRectangle(Brushes.DarkRed, null, rect, 8, 8); }
protected override void OnRender(DrawingContext drawingContext) { Size renderSize = this.RenderSize; drawingContext.DrawRectangle(SystemColors.ControlBrush, null, new Rect(0, 0, renderSize.Width, renderSize.Height)); drawingContext.DrawLine(new Pen(SystemColors.ControlDarkBrush, 1), new Point(renderSize.Width - 0.5, 0), new Point(renderSize.Width - 0.5, renderSize.Height)); TextView textView = this.TextView; if (textView != null && textView.VisualLinesValid) { // create a dictionary line number => first bookmark Dictionary <int, BookmarkBase> bookmarkDict = new Dictionary <int, BookmarkBase>(); foreach (var bm in BookmarkManager.Bookmarks) { if (DebugData.DecompiledMemberReferences == null || DebugData.DecompiledMemberReferences.Count == 0 || !DebugData.DecompiledMemberReferences.ContainsKey(bm.MemberReference.MetadataToken.ToInt32())) { continue; } int line = bm.LineNumber; BookmarkBase existingBookmark; if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder) { bookmarkDict[line] = bm; } } Size pixelSize = PixelSnapHelpers.GetPixelSize(this); foreach (VisualLine line in textView.VisualLines) { int lineNumber = line.FirstDocumentLine.LineNumber; BookmarkBase bm; if (bookmarkDict.TryGetValue(lineNumber, out bm)) { Rect rect = new Rect(0, PixelSnapHelpers.Round(line.VisualTop - textView.VerticalOffset, pixelSize.Height), 16, 16); if (dragDropBookmark == bm && dragStarted) { drawingContext.PushOpacity(0.5); } drawingContext.DrawImage(bm.Image, rect); if (dragDropBookmark == bm && dragStarted) { drawingContext.Pop(); } } } if (dragDropBookmark != null && dragStarted) { Rect rect = new Rect(0, PixelSnapHelpers.Round(dragDropCurrentPoint - 8, pixelSize.Height), 16, 16); drawingContext.DrawImage(dragDropBookmark.Image, rect); } } }
protected override void OnRender(DrawingContext drawingContext) { Size renderSize = this.RenderSize; var theme = themeManager.Theme; var bgColor = (theme.GetColor(ColorType.IconBar).Background as SolidColorBrush).Color; drawingContext.DrawRectangle(theme.GetColor(ColorType.IconBar).Background, null, new Rect(0, 0, renderSize.Width, renderSize.Height)); drawingContext.DrawLine(new Pen(theme.GetColor(ColorType.IconBarBorder).Background, 1), new Point(renderSize.Width - 0.5, 0), new Point(renderSize.Width - 0.5, renderSize.Height)); TextView textView = this.TextView; if (textView != null && textView.VisualLinesValid) { // create a dictionary line number => first bookmark Dictionary <int, List <IIconBarObject> > bookmarkDict = new Dictionary <int, List <IIconBarObject> >(); foreach (var obj in textLineObjectManager.GetObjectsOfType <IIconBarObject>()) { if (!obj.IsVisible(uiContext)) { continue; } int line = obj.GetLineNumber(uiContext); List <IIconBarObject> list; if (!bookmarkDict.TryGetValue(line, out list)) { bookmarkDict[line] = list = new List <IIconBarObject>(); } list.Add(obj); } const double imagePadding = 1.0; Size pixelSize = PixelSnapHelpers.GetPixelSize(this); foreach (VisualLine line in textView.VisualLines) { int lineNumber = line.FirstDocumentLine.LineNumber; List <IIconBarObject> list; if (!bookmarkDict.TryGetValue(lineNumber, out list)) { continue; } list.Sort((a, b) => a.ZOrder.CompareTo(b.ZOrder)); foreach (var bm in list) { Rect rect = new Rect(imagePadding, PixelSnapHelpers.Round(line.VisualTop - textView.VerticalOffset, pixelSize.Height), 16, 16); var imgRef = bm.ImageReference; if (imgRef != null) { drawingContext.DrawImage(imageManager.GetImage(imgRef.Value.Assembly, imgRef.Value.Name, bgColor), rect); } } } } }
protected override void OnRender(DrawingContext drawingContext) { Size renderSize = this.RenderSize; drawingContext.DrawRectangle(SystemColors.ControlBrush, null, new Rect(0, 0, renderSize.Width, renderSize.Height)); drawingContext.DrawLine(new Pen(SystemColors.ControlDarkBrush, 1), new Point(renderSize.Width - 0.5, 0), new Point(renderSize.Width - 0.5, renderSize.Height)); TextView textView = this.TextView; if (textView != null && textView.VisualLinesValid) { // create a dictionary line number => first bookmark Dictionary <int, IBookmark> bookmarkDict = new Dictionary <int, IBookmark>(); foreach (IBookmark bm in manager.Bookmarks) { int line = bm.LineNumber; IBookmark existingBookmark; if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder) { bookmarkDict[line] = bm; } } Size pixelSize = PixelSnapHelpers.GetPixelSize(this); foreach (VisualLine line in textView.VisualLines) { int lineNumber = line.FirstDocumentLine.LineNumber; IBookmark bm; if (bookmarkDict.TryGetValue(lineNumber, out bm)) { double lineMiddle = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextMiddle) - textView.VerticalOffset; Rect rect = new Rect(0, PixelSnapHelpers.Round(lineMiddle - 8, pixelSize.Height), 16, 16); if (dragDropBookmark == bm && dragStarted) { drawingContext.PushOpacity(0.5); } drawingContext.DrawImage((bm.Image ?? DefaultBookmarkImage), rect); if (dragDropBookmark == bm && dragStarted) { drawingContext.Pop(); } } } if (dragDropBookmark != null && dragStarted) { Rect rect = new Rect(0, PixelSnapHelpers.Round(dragDropCurrentPoint - 8, pixelSize.Height), 16, 16); drawingContext.DrawImage((dragDropBookmark.Image ?? DefaultBookmarkImage), rect); } } }
protected override void OnRender(DrawingContext drawingContext) { Size renderSize = this.RenderSize; var theme = Themes.Theme; var bgColor = theme.GetColor(ColorType.IconBar).InheritedColor.Background.GetColor(null).Value; drawingContext.DrawRectangle(theme.GetColor(ColorType.IconBar).InheritedColor.Background.GetBrush(null), null, new Rect(0, 0, renderSize.Width, renderSize.Height)); drawingContext.DrawLine(new Pen(theme.GetColor(ColorType.IconBarBorder).InheritedColor.Background.GetBrush(null), 1), new Point(renderSize.Width - 0.5, 0), new Point(renderSize.Width - 0.5, renderSize.Height)); ICSharpCode.AvalonEdit.Rendering.TextView textView = this.TextView; if (textView != null && textView.VisualLinesValid) { // create a dictionary line number => first bookmark Dictionary <int, List <IIconBarObject> > bookmarkDict = new Dictionary <int, List <IIconBarObject> >(); foreach (var obj in TextLineObjectManager.Instance.GetObjectsOfType <IIconBarObject>()) { if (!obj.IsVisible(decompilerTextView)) { continue; } int line = obj.GetLineNumber(decompilerTextView); List <IIconBarObject> list; if (!bookmarkDict.TryGetValue(line, out list)) { bookmarkDict[line] = list = new List <IIconBarObject>(); } list.Add(obj); } const double imagePadding = 1.0; Size pixelSize = PixelSnapHelpers.GetPixelSize(this); foreach (VisualLine line in textView.VisualLines) { int lineNumber = line.FirstDocumentLine.LineNumber; List <IIconBarObject> list; if (!bookmarkDict.TryGetValue(lineNumber, out list)) { continue; } list.Sort((a, b) => a.ZOrder.CompareTo(b.ZOrder)); foreach (var bm in list) { Rect rect = new Rect(imagePadding, PixelSnapHelpers.Round(line.VisualTop - textView.VerticalOffset, pixelSize.Height), 16, 16); drawingContext.DrawImage(bm.GetImage(bgColor), rect); } } } }
private void AddRectangle(Size pixelSize, Rect r) { if (AlignToWholePixels) { var halfBorder = 0.5 * BorderThickness; AddRectangle(PixelSnapHelpers.Round(r.X - halfBorder, pixelSize.Width) + halfBorder, PixelSnapHelpers.Round(r.Y - halfBorder, pixelSize.Height) + halfBorder, PixelSnapHelpers.Round(r.Right + halfBorder, pixelSize.Width) - halfBorder, PixelSnapHelpers.Round(r.Bottom + halfBorder, pixelSize.Height) - halfBorder); } else { AddRectangle(r.X, r.Y, r.Right, r.Bottom); } }
/// <inheritdoc/> protected override Size ArrangeOverride(Size finalSize) { Size pixelSize = PixelSnapHelpers.GetPixelSize(this); foreach (FoldingMarginMarker m in markers) { int visualColumn = m.VisualLine.GetVisualColumn(m.FoldingSection.StartOffset - m.VisualLine.FirstDocumentLine.Offset); TextLine textLine = m.VisualLine.GetTextLine(visualColumn); double yPos = m.VisualLine.GetTextLineVisualYPosition(textLine, VisualYPosition.LineTop) - TextView.VerticalOffset; yPos += (textLine.Height - m.DesiredSize.Height) / 2; double xPos = (finalSize.Width - m.DesiredSize.Width) / 2; m.Arrange(new Rect(PixelSnapHelpers.Round(new Point(xPos, yPos), pixelSize), m.DesiredSize)); } return(base.ArrangeOverride(finalSize)); }
void AddRectangle(Size pixelSize, Rect r) { if (AlignToWholePixels) { double halfBorder = 0.5 * BorderThickness; AddRectangle(PixelSnapHelpers.Round(r.Left - halfBorder, pixelSize.Width) + halfBorder, PixelSnapHelpers.Round(r.Top - halfBorder, pixelSize.Height) + halfBorder, PixelSnapHelpers.Round(r.Right + halfBorder, pixelSize.Width) - halfBorder, PixelSnapHelpers.Round(r.Bottom + halfBorder, pixelSize.Height) - halfBorder); //Debug.WriteLine(r.ToString() + " -> " + new Rect(lastLeft, lastTop, lastRight-lastLeft, lastBottom-lastTop).ToString()); } else { AddRectangle(r.Left, r.Top, r.Right, r.Bottom); } }
void AddRectangle(Size pixelSize, Rect r) { if (AlignToWholePixels) { AddRectangle(PixelSnapHelpers.Round(r.Left, pixelSize.Width), PixelSnapHelpers.Round(r.Top + 1, pixelSize.Height), PixelSnapHelpers.Round(r.Right, pixelSize.Width), PixelSnapHelpers.Round(r.Bottom + 1, pixelSize.Height)); } else if (AlignToMiddleOfPixels) { AddRectangle(PixelSnapHelpers.PixelAlign(r.Left, pixelSize.Width), PixelSnapHelpers.PixelAlign(r.Top + 1, pixelSize.Height), PixelSnapHelpers.PixelAlign(r.Right, pixelSize.Width), PixelSnapHelpers.PixelAlign(r.Bottom + 1, pixelSize.Height)); } else { AddRectangle(r.Left, r.Top + 1, r.Right, r.Bottom + 1); } }
private void AddRectangle(Size pixelSize, Rect r) { if (AlignToWholePixels) { var halfBorder = 0.5 * BorderThickness; AddRectangle(PixelSnapHelpers.Round(r.X - halfBorder, pixelSize.Width) + halfBorder, PixelSnapHelpers.Round(r.Y - halfBorder, pixelSize.Height) + halfBorder, PixelSnapHelpers.Round(r.Right + halfBorder, pixelSize.Width) - halfBorder, PixelSnapHelpers.Round(r.Bottom + halfBorder, pixelSize.Height) - halfBorder); Debug.WriteLine($"{r} -> {new Rect(_lastLeft, _lastTop, _lastRight - _lastLeft, _lastBottom - _lastTop)}"); } else { AddRectangle(r.X, r.Y, r.Right, r.Bottom); } }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); if (isVisible && blink) { Brush caretBrush = this.CaretBrush; if (caretBrush == null) { caretBrush = (Brush)textView.GetValue(TextBlock.ForegroundProperty); } Rect r = new Rect(caretRectangle.X - textView.HorizontalOffset, caretRectangle.Y - textView.VerticalOffset, caretRectangle.Width, caretRectangle.Height); drawingContext.DrawRectangle(caretBrush, null, PixelSnapHelpers.Round(r, PixelSnapHelpers.GetPixelSize(this))); } }
protected override void OnRender(DrawingContext drawingContext) { Size renderSize = this.RenderSize; drawingContext.DrawRectangle(new SolidColorBrush(Colors.White), null, new Rect(0, 0, renderSize.Width, renderSize.Height)); if (manager != null) { TextView textView = this.TextView; if (textView != null && textView.VisualLinesValid) { // create a dictionary line number => first bookmark Dictionary <int, IBookmark> bookmarkDict = new Dictionary <int, IBookmark>(); foreach (IBookmark bm in manager.Bookmarks) { int line = bm.LineNumber; IBookmark existingBookmark; if (!bookmarkDict.TryGetValue(line, out existingBookmark)) { bookmarkDict.Add(line, bm); } } Size pixelSize = PixelSnapHelpers.GetPixelSize(this); foreach (VisualLine line in textView.VisualLines) { int lineNumber = line.FirstDocumentLine.LineNumber; IBookmark bm; if (bookmarkDict.TryGetValue(lineNumber, out bm)) { double lineMiddle = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextMiddle) - textView.VerticalOffset; Rect rect = new Rect(0, PixelSnapHelpers.Round(lineMiddle - 8, pixelSize.Height), 16, 16); ImageSourceConverter isc = new ImageSourceConverter(); var img = isc.ConvertFrom("pack://siteoforigin:,,,/" + (bm.Image ?? BookmarkBase.DefaultBookmarkImage)) as ImageSource; drawingContext.DrawImage(img, rect); } } } } }
protected override void OnRender(DrawingContext drawingContext) { Size renderSize = this.RenderSize; drawingContext.DrawRectangle(SystemColors.ControlBrush, null, new Rect(0, 0, renderSize.Width, renderSize.Height)); drawingContext.DrawLine(new Pen(SystemColors.ControlDarkBrush, 1), new Point(renderSize.Width - 0.5, 0), new Point(renderSize.Width - 0.5, renderSize.Height)); TextView textView = this.TextView; if (textView != null && textView.VisualLinesValid) { Size pixelSize = PixelSnapHelpers.GetPixelSize(this); foreach (VisualLine line in textView.VisualLines) { int lineNumber = line.FirstDocumentLine.LineNumber; bool arr = lineNumber == currPC; bool bp = breakpoints.ContainsKey(lineNumber) ? breakpoints[lineNumber] : false; double lineMiddle = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextMiddle) - textView.VerticalOffset; Rect rect = new Rect(0, PixelSnapHelpers.Round(lineMiddle - 8, pixelSize.Height), 16, 16); if (bp && arr) { drawingContext.DrawImage(img_Combined, rect); } else if (bp) { drawingContext.DrawImage(img_Breakpoint, rect); } else if (arr) { drawingContext.DrawImage(img_Arrow, rect); } } } }
protected override void OnRender(DrawingContext drawingContext) { Size renderSize = this.RenderSize; drawingContext.DrawRectangle(SystemColors.ControlBrush, null, new Rect(0, 0, renderSize.Width, renderSize.Height)); drawingContext.DrawLine(new Pen(SystemColors.ControlDarkBrush, 1), new Point(renderSize.Width - 0.5, 0), new Point(renderSize.Width - 0.5, renderSize.Height)); ICSharpCode.AvalonEdit.Rendering.TextView textView = this.TextView; if (textView != null && textView.VisualLinesValid) { // create a dictionary line number => first bookmark Dictionary <int, IBookmark> bookmarkDict = new Dictionary <int, IBookmark>(); foreach (var bm in BookmarkManager.Bookmarks) { if (bm is BreakpointBookmark) { if (DebugInformation.CodeMappings == null || DebugInformation.CodeMappings.Count == 0 || !DebugInformation.CodeMappings.ContainsKey(((BreakpointBookmark)bm).FunctionToken)) { continue; } } int line = bm.LineNumber; IBookmark existingBookmark; if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder) { bookmarkDict[line] = bm; } } foreach (var bm in manager.Bookmarks) { int line = bm.LineNumber; IBookmark existingBookmark; if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder) { bookmarkDict[line] = bm; } } const double imagePadding = 1.0; Size pixelSize = PixelSnapHelpers.GetPixelSize(this); foreach (VisualLine line in textView.VisualLines) { int lineNumber = line.FirstDocumentLine.LineNumber; IBookmark bm; if (bookmarkDict.TryGetValue(lineNumber, out bm)) { Rect rect = new Rect(imagePadding, PixelSnapHelpers.Round(line.VisualTop - textView.VerticalOffset, pixelSize.Height), 16, 16); if (dragDropBookmark == bm && dragStarted) { drawingContext.PushOpacity(0.5); } drawingContext.DrawImage(bm.Image, rect); if (dragDropBookmark == bm && dragStarted) { drawingContext.Pop(); } } } if (dragDropBookmark != null && dragStarted) { Rect rect = new Rect(imagePadding, PixelSnapHelpers.Round(dragDropCurrentPoint - 8, pixelSize.Height), 16, 16); drawingContext.DrawImage(dragDropBookmark.Image, rect); } } }
protected override void OnRender(DrawingContext drawingContext) { Size renderSize = this.RenderSize; var theme = Themes.Theme; var bgColor = theme.GetColor(ColorType.IconBar).InheritedColor.Background.GetColor(null).Value; drawingContext.DrawRectangle(theme.GetColor(ColorType.IconBar).InheritedColor.Background.GetBrush(null), null, new Rect(0, 0, renderSize.Width, renderSize.Height)); drawingContext.DrawLine(new Pen(theme.GetColor(ColorType.IconBarBorder).InheritedColor.Background.GetBrush(null), 1), new Point(renderSize.Width - 0.5, 0), new Point(renderSize.Width - 0.5, renderSize.Height)); ICSharpCode.AvalonEdit.Rendering.TextView textView = this.TextView; if (textView != null && textView.VisualLinesValid) { // create a dictionary line number => first bookmark Dictionary <int, List <IBookmark> > bookmarkDict = new Dictionary <int, List <IBookmark> >(); var cm = decompilerTextView.CodeMappings; foreach (var bm in BookmarkManager.Bookmarks) { if (bm is BreakpointBookmark) { if (cm == null || cm.Count == 0 || !cm.ContainsKey(((BreakpointBookmark)bm).MethodKey)) { continue; } } int line = bm.GetLineNumber(decompilerTextView); List <IBookmark> list; if (!bookmarkDict.TryGetValue(line, out list)) { bookmarkDict[line] = list = new List <IBookmark>(); } list.Add(bm); } foreach (var bm in manager.Bookmarks) { int line = BookmarkBase.GetLineNumber(bm, decompilerTextView); List <IBookmark> list; if (!bookmarkDict.TryGetValue(line, out list)) { bookmarkDict[line] = list = new List <IBookmark>(); } list.Add(bm); } const double imagePadding = 1.0; Size pixelSize = PixelSnapHelpers.GetPixelSize(this); foreach (VisualLine line in textView.VisualLines) { int lineNumber = line.FirstDocumentLine.LineNumber; List <IBookmark> list; if (!bookmarkDict.TryGetValue(lineNumber, out list)) { continue; } list.Sort((a, b) => a.ZOrder.CompareTo(b.ZOrder)); foreach (var bm in list) { Rect rect = new Rect(imagePadding, PixelSnapHelpers.Round(line.VisualTop - textView.VerticalOffset, pixelSize.Height), 16, 16); drawingContext.DrawImage(bm.GetImage(bgColor), rect); } } } }