PageRenderTime 31ms CodeModel.GetById 12ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/Debugger/ILSpy.Debugger/UI/BreakpointPanel.xaml.cs

http://github.com/icsharpcode/ILSpy
C# | 110 lines | 93 code | 12 blank | 5 comment | 16 complexity | ddcd94d85b4edda0ccdd78c498203842 MD5 | raw file
  1// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
  2// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
  3using System;
  4using System.Collections.Generic;
  5using System.ComponentModel;
  6using System.Linq;
  7using System.Text;
  8using System.Windows;
  9using System.Windows.Controls;
 10using System.Windows.Data;
 11using System.Windows.Documents;
 12using System.Windows.Input;
 13using System.Windows.Media;
 14
 15using ICSharpCode.ILSpy;
 16using ICSharpCode.ILSpy.Bookmarks;
 17using ICSharpCode.ILSpy.Debugger.Bookmarks;
 18using ICSharpCode.ILSpy.Options;
 19
 20namespace ICSharpCode.ILSpy.Debugger.UI
 21{
 22    /// <summary>
 23    /// Interaction logic for BreakpointPanel.xaml
 24    /// </summary>
 25    public partial class BreakpointPanel : UserControl, IPane
 26    {
 27        static BreakpointPanel s_instance;
 28        
 29        public static BreakpointPanel Instance
 30        {
 31            get {
 32                if (null == s_instance)
 33                {
 34					App.Current.VerifyAccess();
 35                    s_instance = new BreakpointPanel();
 36                }
 37                return s_instance;
 38            }
 39        }
 40        
 41        private BreakpointPanel()
 42        {
 43          InitializeComponent();
 44        }
 45        
 46		public void Show()
 47		{
 48			if (!IsVisible)
 49			{
 50                SetItemSource();
 51                
 52			    MainWindow.Instance.ShowInBottomPane("Breakpoints", this);
 53			    
 54                BookmarkManager.Added += delegate { SetItemSource(); };
 55                BookmarkManager.Removed += delegate { SetItemSource(); };
 56                DebuggerSettings.Instance.PropertyChanged += 
 57                	delegate(object s, PropertyChangedEventArgs e) { if (e.PropertyName == "ShowAllBookmarks") SetItemSource(); };
 58			}
 59		}
 60		
 61		private void SetItemSource()
 62		{
 63          	view.ItemsSource = null;
 64          	if (DebuggerSettings.Instance.ShowAllBookmarks)
 65				view.ItemsSource = BookmarkManager.Bookmarks;
 66          	else
 67          		view.ItemsSource = BookmarkManager.Bookmarks.Where(b => b is BreakpointBookmark);
 68		}
 69        
 70        public void Closed()
 71        {
 72        	BookmarkManager.Added -= delegate { SetItemSource(); };
 73        	BookmarkManager.Removed -= delegate { SetItemSource(); };
 74        	DebuggerSettings.Instance.PropertyChanged -= 
 75        		delegate(object s, PropertyChangedEventArgs e) { if (e.PropertyName == "ShowAllBookmarks") SetItemSource(); };
 76        }
 77        
 78		void view_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 79		{
 80            if (MouseButton.Left != e.ChangedButton)
 81                return;
 82            var selectedItem = view.SelectedItem as BookmarkBase;
 83            if (null == selectedItem)
 84                return;
 85            MainWindow.Instance.JumpToReference(selectedItem.MemberReference);
 86            MainWindow.Instance.TextView.UnfoldAndScroll(selectedItem.LineNumber);
 87            e.Handled = true;
 88		}
 89        
 90        void view_KeyUp(object sender, KeyEventArgs e)
 91        {
 92            if (e.Key != Key.Delete)
 93                return;
 94            var selectedItem = view.SelectedItem as BookmarkBase;
 95            if (null == selectedItem)
 96                return;
 97            BookmarkManager.RemoveMark(selectedItem);
 98            e.Handled = true;
 99        }
100    }
101
102    [ExportMainMenuCommand(Menu="_Debugger", Header="Show _Breakpoints", MenuCategory="View", MenuOrder=8)]
103    public class BookmarkManagerPanelCommand : SimpleCommand
104    {
105        public override void Execute(object parameter)
106        {
107            BreakpointPanel.Instance.Show();
108        }
109    }
110}