Exemple #1
0
        IBookmark GetBookmarkFromLine(int line)
        {
            var          cm     = decompilerTextView.CodeMappings;
            BookmarkBase result = null;

            foreach (BookmarkBase bm in BookmarkManager.Bookmarks)
            {
                if (bm.GetLineNumber(decompilerTextView) != line)
                {
                    continue;
                }
                if (bm is BreakpointBookmark)
                {
                    if (cm == null || cm.Count == 0 || !cm.ContainsKey(((BreakpointBookmark)bm).MethodKey))
                    {
                        continue;
                    }
                }

                if (result == null || bm.ZOrder > result.ZOrder)
                {
                    return(result);
                }
            }

            return(manager.Bookmarks.FirstOrDefault(b => BookmarkBase.GetLineNumber(b, decompilerTextView) == line));
        }
Exemple #2
0
        List <IBookmark> GetBookmark(IList <IBookmark> bookmarks, int line)
        {
            var list = new List <IBookmark>();

            foreach (var b in bookmarks)
            {
                if (BookmarkBase.GetLineNumber(b, textView) != line)
                {
                    continue;
                }
                if (!b.HasImage)
                {
                    continue;
                }
                list.Add(b);
            }
            list.Sort((a, b) => b.ZOrder.CompareTo(a.ZOrder));
            return(list);
        }
Exemple #3
0
        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);
                    }
                }
            }
        }