Browse Source

add toolbar to WatchPad

pull/59/merge
Siegfried Pammer 13 years ago
parent
commit
929eba3630
  1. 10
      src/AddIns/Debugger/Debugger.AddIn/Pads/AutoCompleteTextBox.cs
  2. 49
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs
  3. 2
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadCommands.cs
  4. 2
      src/AddIns/Debugger/Debugger.Core/PdbSymbolSource.cs

10
src/AddIns/Debugger/Debugger.AddIn/Pads/AutoCompleteTextBox.cs

@ -85,8 +85,10 @@ namespace Debugger.AddIn.Pads.Controls
void editor_TextArea_PreviewKeyDown(object sender, KeyEventArgs e) void editor_TextArea_PreviewKeyDown(object sender, KeyEventArgs e)
{ {
if (e.Key == Key.Return || e.Key == Key.Escape) { if (e.Key == Key.Return || e.Key == Key.Escape) {
if (e.Key == Key.Return) if (e.Key == Key.Return) {
this.Text = this.editor.Text; this.Text = this.editor.Text;
editor.SelectionStart = this.Text.Length;
}
e.Handled = true; e.Handled = true;
} }
@ -124,5 +126,11 @@ namespace Debugger.AddIn.Pads.Controls
// editorAdapter.ShowCompletionWindow(new DotCodeCompletionItemProvider().GenerateCompletionListForResolveResult(rr, expr.Context)); // editorAdapter.ShowCompletionWindow(new DotCodeCompletionItemProvider().GenerateCompletionListForResolveResult(rr, expr.Context));
// } // }
} }
public void FocusEditor()
{
editor.TextArea.Focus();
editor.SelectAll();
}
} }
} }

49
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs

@ -2,10 +2,12 @@
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt) // This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading; using System.Windows.Threading;
using Debugger; using Debugger;
@ -22,10 +24,12 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{ {
public class WatchPad : AbstractPadContent public class WatchPad : AbstractPadContent
{ {
DockPanel panel;
ToolBar toolBar;
SharpTreeView tree; SharpTreeView tree;
public override object Control { public override object Control {
get { return tree; } get { return panel; }
} }
public SharpTreeView Tree { public SharpTreeView Tree {
@ -41,18 +45,24 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
var res = new CommonResources(); var res = new CommonResources();
res.InitializeComponent(); res.InitializeComponent();
panel = new DockPanel();
toolBar = ToolBarService.CreateToolBar(toolBar, this, "/SharpDevelop/Pads/WatchPad/ToolBar");
toolBar.SetValue(DockPanel.DockProperty, Dock.Top);
panel.Children.Add(toolBar);
tree = new SharpTreeView(); tree = new SharpTreeView();
tree.Root = new WatchRootNode(); tree.Root = new WatchRootNode();
tree.ShowRoot = false; tree.ShowRoot = false;
tree.View = (GridView)res["variableGridView"]; tree.View = (GridView)res["variableGridView"];
tree.SetValue(GridViewColumnAutoSize.AutoWidthProperty, "50%;25%;25%"); tree.SetValue(GridViewColumnAutoSize.AutoWidthProperty, "50%;25%;25%");
tree.ContextMenu = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/WatchPad/ContextMenu"); //tree.ContextMenu = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/WatchPad/ContextMenu");
tree.MouseDoubleClick += delegate(object sender, MouseButtonEventArgs e) { tree.MouseDoubleClick += delegate(object sender, MouseButtonEventArgs e) {
if (this.tree.SelectedItem == null) { if (this.tree.SelectedItem == null) {
AddWatchCommand cmd = new AddWatchCommand { Owner = this }; AddWatch(focus: true);
cmd.Run();
} }
}; };
panel.Children.Add(tree);
// ProjectService.SolutionLoaded += delegate { LoadNodes(); }; // ProjectService.SolutionLoaded += delegate { LoadNodes(); };
// ProjectService.SolutionClosing += delegate { SaveNodes(); }; // ProjectService.SolutionClosing += delegate { SaveNodes(); };
@ -83,10 +93,22 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
// } // }
// } // }
public void AddWatch(string expression = null) public void AddWatch(string expression = null, bool focus = false)
{ {
var node = MakeNode(expression); var node = MakeNode(expression);
this.Items.Add(node); this.Items.Add(node);
if (focus) {
var view = tree.View as SharpGridView;
tree.Dispatcher.BeginInvoke(
DispatcherPriority.Input, (Action)delegate {
var container = tree.ItemContainerGenerator.ContainerFromItem(node) as SharpTreeViewItem;
if (container == null) return;
var textBox = container.NodeView.FindAncestor<StackPanel>().FindName("name") as AutoCompleteTextBox;
if (textBox == null) return;
textBox.FocusEditor();
});
}
} }
SharpTreeNodeAdapter MakeNode(string name) SharpTreeNodeAdapter MakeNode(string name)
@ -156,4 +178,21 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
WindowsDebugger.RefreshPads(); WindowsDebugger.RefreshPads();
} }
} }
static class WpfExtensions
{
public static T FindAncestor<T>(this DependencyObject d) where T : class
{
return AncestorsAndSelf(d).OfType<T>().FirstOrDefault();
}
public static IEnumerable<DependencyObject> AncestorsAndSelf(this DependencyObject d)
{
while (d != null) {
yield return d;
d = VisualTreeHelper.GetParent(d);
}
}
}
} }

2
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadCommands.cs

@ -20,7 +20,7 @@ namespace Debugger.AddIn
{ {
if (this.Owner is WatchPad) { if (this.Owner is WatchPad) {
WatchPad pad = (WatchPad)this.Owner; WatchPad pad = (WatchPad)this.Owner;
pad.AddWatch(); pad.AddWatch(focus: true);
} }
} }
} }

2
src/AddIns/Debugger/Debugger.Core/PdbSymbolSource.cs

@ -207,12 +207,10 @@ namespace Debugger
symDoc = symDoc ?? symDocs.FirstOrDefault(d => string.Equals(GetSourceCodePath(module.Process, d.GetURL()), filename, StringComparison.OrdinalIgnoreCase)); symDoc = symDoc ?? symDocs.FirstOrDefault(d => string.Equals(GetSourceCodePath(module.Process, d.GetURL()), filename, StringComparison.OrdinalIgnoreCase));
if (symDoc == null) yield break; // Document not found if (symDoc == null) yield break; // Document not found
ISymUnmanagedMethod symMethod2;
ISymUnmanagedMethod[] symMethods; ISymUnmanagedMethod[] symMethods;
try { try {
uint validLine = symDoc.FindClosestLine((uint)line); uint validLine = symDoc.FindClosestLine((uint)line);
symMethods = symReader.GetMethodsFromDocumentPosition(symDoc, validLine, (uint)column); symMethods = symReader.GetMethodsFromDocumentPosition(symDoc, validLine, (uint)column);
symMethod2 = symReader.GetMethodFromDocumentPosition(symDoc, (uint)validLine, (uint)column);
} catch { } catch {
yield break; //Not found yield break; //Not found
} }

Loading…
Cancel
Save