From 723ed39a8a686a41dfa518326b348448458b47ea Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 27 Apr 2012 18:23:49 +0200 Subject: [PATCH] fix http://community.sharpdevelop.net/forums/t/15745.aspx - Delete variable in watch window --- .../Pads/Controls/TreeNodeWrapper.cs | 10 ++++++++++ .../Debugger/Debugger.AddIn/Pads/WatchPad.cs | 17 ++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeNodeWrapper.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeNodeWrapper.cs index 6c8dd6ac225..048c0a26b2d 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeNodeWrapper.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeNodeWrapper.cs @@ -39,6 +39,16 @@ public TreeNodeWrapper(TreeNode node) get { return Node.HasChildNodes; } } + public override bool CanDelete() + { + return Parent is WatchRootNode; + } + + public override void Delete() + { + Parent.Children.Remove(this); + } + protected override void LoadChildren() { if (Node.HasChildNodes) { diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs index 77da1ed9f58..f4b9e6241fc 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs @@ -55,12 +55,11 @@ protected override void InitializeComponents() watchList = new WatchList(WatchListType.Watch); watchList.ContextMenu = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/WatchPad/ContextMenu"); - watchList.MouseDoubleClick += watchList_DoubleClick; - watchList.KeyUp += watchList_KeyUp; + watchList.MouseDoubleClick += WatchListDoubleClick; watchList.WatchItems.CollectionChanged += OnWatchItemsCollectionChanged; panel.Children.Add(watchList); - panel.KeyUp += new KeyEventHandler(panel_KeyUp); + panel.KeyDown += PanelKeyDown; // wire events that influence the items LoadSavedNodes(); @@ -122,23 +121,15 @@ Properties GetSavedVariablesProperties() #endregion - void panel_KeyUp(object sender, KeyEventArgs e) + void PanelKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Insert) { AddNewWatch(); e.Handled = true; } } - - void watchList_KeyUp(object sender, KeyEventArgs e) - { - if (e.Key == Key.Delete) { - RemoveWatchCommand cmd = new RemoveWatchCommand { Owner = this }; - cmd.Run(); - } - } - void watchList_DoubleClick(object sender, MouseEventArgs e) + void WatchListDoubleClick(object sender, MouseEventArgs e) { if (watchList.SelectedNode == null) {