Пример #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));
        }
Пример #2
0
        IBookmark GetBookmarkFromLine(int line)
        {
            BookmarkBase result = null;

            foreach (BookmarkBase bm in BookmarkManager.Bookmarks)
            {
                if (bm.LineNumber != line)
                {
                    continue;
                }
                if (bm is BreakpointBookmark)
                {
                    if (DebugInformation.CodeMappings == null || DebugInformation.CodeMappings.Count == 0 ||
                        !DebugInformation.CodeMappings.ContainsKey(((BreakpointBookmark)bm).FunctionToken))
                    {
                        continue;
                    }
                }

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

            return(manager.Bookmarks.FirstOrDefault(b => b.LineNumber == line));
        }
            void on_cellrender_edited(object sender, EditedArgs args)
            {
                // root group can't be edited
                if (selected_id == root_group.ID)
                {
                    return;
                }

                BookmarkBase bk = null;

                BookmarkManager.GetBookmarkBase(root_group, selected_id, ref bk);

                if (bk == null)
                {
                    Console.WriteLine("error, could not retrieve bookmark:{0}", selected_id);
                    return;
                }

                // it is not a bookmark
                bk.Name = args.NewText;


                //refreshing tree_view
                BookmarkManager.Refresh();
                BuildTreeView();
            }
Пример #4
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                this.dragStartPoint = null;
            }

            if (this.dragStartPoint.HasValue)
            {
                ActivityTypeEnum typeEnum = Nsun.Workflow.Core.EnumExt.EnumHelper.GetEnumByString <ActivityTypeEnum>
                                                ((this.Content as ToolBoxItemExt).BookmarkType);

                BookmarkBase bookmark   = BookmarkFactory.GetBookmark(typeEnum);
                string       xamlString = XElement.Parse(bookmark.GetSerialContent()).Value;

                DragObject dataObject = new DragObject();
                dataObject.Xaml = xamlString;

                WrapPanel panel = VisualTreeHelper.GetParent(this) as WrapPanel;
                if (panel != null)
                {
                    dataObject.DesiredSize = new Size(bookmark.Size.Key, bookmark.Size.Value);
                }

                DragDrop.DoDragDrop(this, dataObject, DragDropEffects.Copy);

                e.Handled = true;
            }
        }
        /// <summary> Recursively finds a bookmarkbase </summary>
        public static void GetBookmarkBase(BookmarkGroup bookmarks, string ID, ref BookmarkBase retval)
        {
            foreach (object i in bookmarks.Members)
            {
                if (((BookmarkBase)i).ID == ID)
                {
                    retval = i as BookmarkBase;
                    return;
                }

                if (i is BookmarkGroup)
                {
                    GetBookmarkBase((BookmarkGroup)i, ID, ref retval);
                }
            }
        }
Пример #6
0
        void GoToBookmark(BookmarkBase bm)
        {
            if (null == bm)
            {
                return;
            }
            if (Keyboard.Modifiers == ModifierKeys.Control || Keyboard.Modifiers == ModifierKeys.Shift)
            {
                MainWindow.Instance.OpenNewEmptyTab();
            }
            var textView = MainWindow.Instance.SafeActiveTextView;

            if (DebugUtils.JumpToReference(textView, bm.MemberReference, () => bm.GetLocation(textView)))
            {
                MainWindow.Instance.SetTextEditorFocus(textView);
            }
        }
Пример #7
0
        BookmarkBase GetBookmarkFromLine(int line)
        {
            BookmarkBase result = null;

            foreach (BookmarkBase bm in BookmarkManager.Bookmarks)
            {
                if (bm.LineNumber == line &&
                    DebugData.DecompiledMemberReferences != null && DebugData.DecompiledMemberReferences.ContainsKey(bm.MemberReference.MetadataToken.ToInt32()))
                {
                    if (result == null || bm.ZOrder > result.ZOrder)
                    {
                        result = bm;
                    }
                }
            }
            return(result);
        }
Пример #8
0
        IBookmark GetBookmarkFromLine(int line)
        {
            BookmarkBase result = null;

            foreach (BookmarkBase bm in BookmarkManager.Bookmarks)
            {
                if (bm.LineNumber == line &&
                    this.DecompiledMembers != null && this.DecompiledMembers.Contains(bm.MemberReference))
                {
                    if (result == null || bm.ZOrder > result.ZOrder)
                    {
                        return(result);
                    }
                }
            }

            return(manager.Bookmarks.FirstOrDefault(b => b.LineNumber == line));
        }
Пример #9
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);
        }
        static void on_bookmark_activated(object sender, EventArgs e)
        {
            // finding the inner label
            BookmarkBase bk = null;

            GetBookmarkBase(root_group, menu_to_id[(MenuItem)sender] as string, ref bk);

            if (bk != null)
            {
                if (bk is  Bookmark)
                {
                    _Browser.LoadUrl(((Bookmark)bk).Url);
                }
            }
            else
            {
                Console.WriteLine("Bookmark error -> could not load bookmark");
            }
        }
Пример #11
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);
                    }
                }
            }
        }
Пример #12
0
		/// <summary> Recursively finds a bookmarkbase </summary>
		public static void GetBookmarkBase (BookmarkGroup bookmarks, string ID, ref BookmarkBase retval) {
			
			foreach (object i in bookmarks.Members) {
				if (((BookmarkBase)i).ID == ID) {
					retval = i as BookmarkBase;
					return;
				}
				
				if (i is BookmarkGroup)
					GetBookmarkBase ((BookmarkGroup)i,ID,ref retval);
			}
		}
Пример #13
0
        protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            base.OnMouseUp(e);
            int line = GetLineFromMousePosition(e);

            if (!e.Handled && dragDropBookmark != null)
            {
                if (dragStarted)
                {
                    if (line != 0)
                    {
                        dragDropBookmark.Drop(line);
                    }
                    e.Handled = true;
                }
                CancelDragDrop();
            }
            if (!e.Handled && line != 0)
            {
                BookmarkBase bm = GetBookmarkFromLine(line);
                if (bm != null)
                {
                    bm.MouseUp(e);

                    if (bm.CanToggle)
                    {
                        BookmarkManager.RemoveMark(bm);
                        InvalidateVisual();
                    }

                    if (e.Handled)
                    {
                        return;
                    }
                }
                if (e.ChangedButton == MouseButton.Left)
                {
                    if (DebugData.CodeMappings != null && DebugData.CodeMappings.Count > 0)
                    {
                        // check if the codemappings exists for this line
                        var storage = DebugData.CodeMappings;
                        int token   = 0;
                        foreach (var key in storage.Keys)
                        {
                            var instruction = storage[key].GetInstructionByLineNumber(line, out token);

                            if (instruction == null)
                            {
                                continue;
                            }

                            // no bookmark on the line: create a new breakpoint
                            DebuggerService.ToggleBreakpointAt(
                                DebugData.DecompiledMemberReferences[key],
                                line,
                                instruction.ILInstructionOffset,
                                DebugData.Language);
                            break;
                        }

                        if (token == 0)
                        {
                            MessageBox.Show(string.Format("Missing code mappings at line {0}.", line),
                                            "Code mappings", MessageBoxButton.OK, MessageBoxImage.Information);
                            return;
                        }
                    }
                }
                InvalidateVisual();
            }
        }