diff --git a/SharpDevelop.Tests.sln b/SharpDevelop.Tests.sln
index 82e2c8b543..b229e91189 100644
--- a/SharpDevelop.Tests.sln
+++ b/SharpDevelop.Tests.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-# SharpDevelop 4.2.0.8564-beta
+# SharpDevelop 4.2.0.8717-Beta 2
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj
index dd26d194bf..0500991393 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj
+++ b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj
@@ -111,17 +111,10 @@
-
-
+
+
ConditionCell.xaml
-
-
- WatchList.xaml
-
-
- WatchListAutoCompleteCell.xaml
-
DrawSurface.xaml
@@ -135,10 +128,6 @@
ThreadStack.xaml
Code
-
- WatchInputBox.xaml
- Code
-
@@ -182,6 +171,7 @@
VisualizerPicker.xaml
+
@@ -352,12 +342,10 @@
-
-
-
+
+
-
@@ -379,7 +367,7 @@
-
+
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Commands/WatchPadCommands.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Commands/WatchPadCommands.cs
index dbbf5bbab1..14ff79c339 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Commands/WatchPadCommands.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/Commands/WatchPadCommands.cs
@@ -20,30 +20,9 @@ namespace Debugger.AddIn
{
if (this.Owner is WatchPad) {
WatchPad pad = (WatchPad)this.Owner;
-
- var inputWindow = new WatchInputBox(StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.AddWatch}"),
- StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.EnterExpression}"));
- inputWindow.Owner = ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWindow;
- var result = inputWindow.ShowDialog();
- if (!result.HasValue || !result.Value)
- return;
-
- string input = inputWindow.CommandText;
-
- if (!string.IsNullOrEmpty(input)) {
- // get language
- if (ProjectService.CurrentProject == null) return;
-
- string language = ProjectService.CurrentProject.Language;
-
- var text = new TreeNode(input, null).ToSharpTreeNode();
- var list = pad.WatchList;
-
- if(!list.WatchItems.Any(n => text.Node.Name == ((TreeNodeWrapper)n).Node.Name))
- list.WatchItems.Add(text);
- }
-
- WindowsDebugger.RefreshPads();
+ var node = new TreeNode(string.Empty, null).ToSharpTreeNode();
+ pad.Items.Add(node);
+ pad.Tree.FocusNode(node);
}
}
}
@@ -54,50 +33,19 @@ namespace Debugger.AddIn
{
if (this.Owner is WatchPad) {
WatchPad pad = (WatchPad)this.Owner;
- var list = pad.WatchList;
- var node = list.SelectedNode;
-
- if (node == null)
- return;
-
- list.WatchItems.Remove(node);
-
+ pad.Items.Remove(pad.Tree.SelectedItem as SharpTreeNodeAdapter);
WindowsDebugger.RefreshPads();
}
}
}
- public class RefreshWatchesCommand : AbstractMenuCommand
- {
- public override void Run()
- {
- WindowsDebugger.RefreshPads();
- }
- }
-
public class ClearWatchesCommand : AbstractMenuCommand
{
public override void Run()
{
if (this.Owner is WatchPad) {
WatchPad pad = (WatchPad)this.Owner;
- var list = pad.WatchList;
- list.WatchItems.Clear();
- }
- }
- }
-
- public class CopyToClipboardCommand : AbstractMenuCommand
- {
- public override void Run()
- {
- if (this.Owner is WatchPad) {
- WatchPad pad = (WatchPad)this.Owner;
- var node = pad.WatchList.SelectedNode;
- if (node != null && node.Node is ValueNode) {
- string text = ((ValueNode)node.Node).FullText;
- ClipboardWrapper.SetText(text);
- }
+ pad.Items.Clear();
}
}
}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Common/AutoCompleteTextBox.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Common/AutoCompleteTextBox.cs
new file mode 100644
index 0000000000..3d88d0130f
--- /dev/null
+++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/Common/AutoCompleteTextBox.cs
@@ -0,0 +1,120 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Threading;
+using ICSharpCode.AvalonEdit;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
+using ICSharpCode.SharpDevelop.Editor;
+using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
+using ICSharpCode.SharpDevelop.Project;
+using ICSharpCode.SharpDevelop.Services;
+
+namespace Debugger.AddIn.Pads.Controls
+{
+ public class AutoCompleteTextBox : UserControl
+ {
+ TextEditor editor;
+ ITextEditor editorAdapter;
+
+ public static readonly DependencyProperty TextProperty =
+ DependencyProperty.Register("Text", typeof(string), typeof(AutoCompleteTextBox),
+ new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, TextChanged));
+
+ public static readonly DependencyProperty IsEditableProperty =
+ DependencyProperty.Register("IsEditable", typeof(bool), typeof(AutoCompleteTextBox),
+ new FrameworkPropertyMetadata(true, IsEditableChanged));
+
+ public string Text {
+ get { return (string)GetValue(TextProperty); }
+ set { SetValue(TextProperty, value); }
+ }
+
+ public bool IsEditable {
+ get { return (bool)GetValue(IsEditableProperty); }
+ set { SetValue(IsEditableProperty, value); }
+ }
+
+ static void TextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ ((AutoCompleteTextBox)d).editor.Text = (string)e.NewValue;
+ }
+
+ static void IsEditableChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ ((AutoCompleteTextBox)d).editor.IsReadOnly = !(bool)e.NewValue;
+ }
+
+ public AutoCompleteTextBox()
+ {
+ object tmp;
+ this.editorAdapter = EditorControlService.CreateEditor(out tmp);
+ this.editor = (TextEditor)tmp;
+
+ this.editor.Background = Brushes.Transparent;
+ this.editor.ShowLineNumbers = false;
+ this.editor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
+ this.editor.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
+ this.editor.TextArea.GotKeyboardFocus += delegate {
+ this.Background = Brushes.White;
+ };
+ this.editor.TextArea.LostKeyboardFocus += delegate {
+ this.Background = Brushes.Transparent;
+ this.Text = this.editor.Text;
+ this.editor.Select(0, 0);
+ };
+ this.editor.TextArea.PreviewKeyDown += editor_TextArea_PreviewKeyDown;
+ this.editor.TextArea.TextEntered += editor_TextArea_TextEntered;
+
+ this.Content = this.editor;
+ }
+
+ void editor_TextArea_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Return || e.Key == Key.Escape) {
+ if (e.Key == Key.Return)
+ this.Text = this.editor.Text;
+
+ e.Handled = true;
+ }
+ }
+
+ void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs e)
+ {
+ StackFrame frame = WindowsDebugger.CurrentStackFrame;
+ if (e.Text == "." && frame != null)
+ ShowDotCompletion(frame, this.editor.Text);
+ }
+
+ private void ShowDotCompletion(StackFrame frame, string currentText)
+ {
+ string language = ProjectService.CurrentProject == null ? "C#" : ProjectService.CurrentProject.Language;
+ NRefactoryResolver resolver = new NRefactoryResolver(LanguageProperties.GetLanguage(language));
+
+ var seg = frame.NextStatement;
+
+ var expressionFinder = ParserService.GetExpressionFinder(seg.Filename);
+ var info = ParserService.GetParseInformation(seg.Filename);
+
+ string text = ParserService.GetParseableFileContent(seg.Filename).Text;
+
+ int currentOffset = this.editor.CaretOffset;
+
+ var expr = expressionFinder.FindExpression(currentText, currentOffset);
+
+ expr.Region = new DomRegion(seg.StartLine, seg.StartColumn, seg.EndLine, seg.EndColumn);
+
+ var rr = resolver.Resolve(expr, info, text);
+
+ if (rr != null) {
+ editorAdapter.ShowCompletionWindow(new DotCodeCompletionItemProvider().GenerateCompletionListForResolveResult(rr, expr.Context));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Common/CommonResources.xaml b/src/AddIns/Debugger/Debugger.AddIn/Pads/Common/CommonResources.xaml
new file mode 100644
index 0000000000..9d47aa3e6f
--- /dev/null
+++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/Common/CommonResources.xaml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/ConditionCell.xaml b/src/AddIns/Debugger/Debugger.AddIn/Pads/Common/ConditionCell.xaml
similarity index 100%
rename from src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/ConditionCell.xaml
rename to src/AddIns/Debugger/Debugger.AddIn/Pads/Common/ConditionCell.xaml
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/ConditionCell.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Common/ConditionCell.xaml.cs
similarity index 100%
rename from src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/ConditionCell.xaml.cs
rename to src/AddIns/Debugger/Debugger.AddIn/Pads/Common/ConditionCell.xaml.cs
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/Converters.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/Converters.cs
deleted file mode 100644
index 2283a4cca2..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/Converters.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
-// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
-
-using System;
-using System.Globalization;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Media;
-
-namespace Debugger.AddIn.Pads.Controls
-{
- public class BoolToVisibilityConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType,
- object parameter, CultureInfo culture)
- {
- bool val = bool.Parse(parameter.ToString());
- return val == (bool.Parse(values[0].ToString()) && bool.Parse(values[1].ToString())) ? Visibility.Visible : Visibility.Collapsed;
- }
-
- public object[] ConvertBack(object value, Type[] targetTypes,
- object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml
deleted file mode 100644
index d88e84eef2..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml.cs
deleted file mode 100644
index ca00a62a5a..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
-// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
-
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Input;
-using Debugger.AddIn.TreeModel;
-using ICSharpCode.Core.Presentation;
-using ICSharpCode.SharpDevelop.Gui;
-using ICSharpCode.SharpDevelop.Gui.Pads;
-using ICSharpCode.SharpDevelop.Services;
-using ICSharpCode.TreeView;
-
-namespace Debugger.AddIn.Pads.Controls
-{
- public enum WatchListType
- {
- LocalVar,
- Watch
- }
-
- public partial class WatchList : UserControl
- {
- public WatchList(WatchListType type)
- {
- InitializeComponent();
- WatchType = type;
- if (type == WatchListType.Watch)
- myList.Root = new WatchRootNode();
- else
- myList.Root = new SharpTreeNode();
- }
-
- public WatchListType WatchType { get; private set; }
-
- public SharpTreeNodeCollection WatchItems {
- get { return myList.Root.Children; }
- }
-
- public TreeNodeWrapper SelectedNode {
- get { return myList.SelectedItem as TreeNodeWrapper; }
- }
-
- void OnValueTextBoxKeyUp(object sender, KeyEventArgs e)
- {
- if (e.Key != Key.Enter && e.Key != Key.Escape) {
- e.Handled = true;
- return;
- }
-
- if (e.Key == Key.Enter) {
- if(SelectedNode.Node is ValueNode) {
- var node = (ValueNode)SelectedNode.Node;
- node.Value = ((TextBox)sender).Text;
- }
- }
- if (e.Key == Key.Enter || e.Key == Key.Escape) {
- myList.UnselectAll();
- WindowsDebugger.RefreshPads();
- }
- }
-
- void WatchListAutoCompleteCellCommandEntered(object sender, EventArgs e)
- {
- if (SelectedNode == null) return;
- if (WatchType != WatchListType.Watch) return;
-
- var cell = ((WatchListAutoCompleteCell)sender);
-
- SelectedNode.Node.Name = cell.CommandText;
- myList.UnselectAll();
- if (WatchType == WatchListType.Watch && WatchPad.Instance != null) {
- WindowsDebugger.RefreshPads();
- }
- SelectedNode.IsEditing = false;
- }
-
- void MyListPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
- {
- if (SelectedNode == null) return;
- if (WatchType != WatchListType.Watch)
- return;
- SelectedNode.IsEditing = true;
- }
- }
-}
\ No newline at end of file
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.cs
deleted file mode 100644
index f14430b083..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.cs
+++ /dev/null
@@ -1,169 +0,0 @@
-// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
-// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
-
-using System;
-using System.IO;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-
-using ICSharpCode.AvalonEdit;
-using ICSharpCode.Core;
-using ICSharpCode.NRefactory;
-using ICSharpCode.SharpDevelop;
-using ICSharpCode.SharpDevelop.Debugging;
-using ICSharpCode.SharpDevelop.Dom;
-using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
-using ICSharpCode.SharpDevelop.Editor;
-using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
-using ICSharpCode.SharpDevelop.Gui;
-using ICSharpCode.SharpDevelop.Gui.Pads;
-using ICSharpCode.SharpDevelop.Project;
-using ICSharpCode.SharpDevelop.Services;
-
-namespace Debugger.AddIn.Pads.Controls
-{
- public partial class WatchListAutoCompleteCell : UserControl
- {
- private string language;
-
- protected ConsoleControl console;
-
- public static readonly DependencyProperty CommandTextProperty =
- DependencyProperty.Register("CommandText", typeof(string), typeof(WatchListAutoCompleteCell),
- new UIPropertyMetadata(null, new PropertyChangedCallback(OnCommandTextChanged)));
-
- private NRefactoryResolver resolver;
-
- public event EventHandler CommandEntered;
-
- public WatchListAutoCompleteCell()
- {
- InitializeComponent();
-
- console = new ConsoleControl();
- console.TextAreaTextEntered += new TextCompositionEventHandler(consoleControl_TextAreaTextEntered);
- console.TextAreaPreviewKeyDown += new KeyEventHandler(console_TextAreaPreviewKeyDown);
- console.LostFocus += new RoutedEventHandler(console_LostFocus);
- console.HideScrollBar();
- ConsolePanel.Content = console;
-
- // get language
- if (ProjectService.CurrentProject == null)
- language = "C#";
- else
- language = ProjectService.CurrentProject.Language;
- resolver = new NRefactoryResolver(LanguageProperties.GetLanguage(language));
-
- // FIXME set language
- if (language == "VB" || language == "VBNet") {
- console.SetHighlighting("VBNET");
- }
- else {
- console.SetHighlighting("C#");
- }
-
- // get process
- WindowsDebugger debugger = (WindowsDebugger)DebuggerService.CurrentDebugger;
- }
-
- ///
- /// Gets/sets the command text displayed at the command prompt.
- ///
- public string CommandText {
- get { return console.CommandText.Trim(); }
- set { console.CommandText = value; }
- }
-
- private ITextEditor TextEditor {
- get {
- return console.TextEditor;
- }
- }
-
- private void console_TextAreaPreviewKeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Return || e.Key == Key.Escape) {
-
- if (e.Key == Key.Escape)
- CommandText = string.Empty;
- else {
- if(!CheckSyntax())
- return;
- }
-
- if (CommandEntered != null)
- CommandEntered(this, EventArgs.Empty);
-
- e.Handled = true;
- }
- }
-
- private void console_LostFocus(object sender, RoutedEventArgs e)
- {
- if (string.IsNullOrEmpty(CommandText) || !this.CheckSyntax())
- return;
-
- if (CommandEntered != null)
- CommandEntered(this, EventArgs.Empty);
- }
-
- private bool CheckSyntax()
- {
- string command = CommandText;
-
- // FIXME workaround the NRefactory issue that needs a ; at the end
- if (language == "C#" || language == "CSharp") {
- if(!command.EndsWith(";"))
- command += ";";
- // FIXME only one string should be available; highlighting expects C#, supproted language, CSharp
- language = "CSharp";
- }
-
- SupportedLanguage supportedLanguage = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), language.ToString(), true);
- using (var parser = ParserFactory.CreateParser(supportedLanguage, new StringReader(command))) {
- parser.ParseExpression();
- if (parser.Errors.Count > 0) {
- MessageService.ShowError(parser.Errors.ErrorOutput);
- return false;
- }
- }
-
- return true;
- }
-
- private void consoleControl_TextAreaTextEntered(object sender, TextCompositionEventArgs e)
- {
- StackFrame frame = WindowsDebugger.CurrentStackFrame;
- if (e.Text == "." && frame != null)
- ShowDotCompletion(frame, console.CommandText);
- }
-
- private void ShowDotCompletion(StackFrame frame, string currentText)
- {
- var seg = frame.NextStatement;
-
- var expressionFinder = ParserService.GetExpressionFinder(seg.Filename);
- var info = ParserService.GetParseInformation(seg.Filename);
-
- string text = ParserService.GetParseableFileContent(seg.Filename).Text;
-
- int currentOffset = TextEditor.Caret.Offset - console.CommandOffset - 1;
-
- var expr = expressionFinder.FindExpression(currentText, currentOffset);
-
- expr.Region = new DomRegion(seg.StartLine, seg.StartColumn, seg.EndLine, seg.EndColumn);
-
- var rr = resolver.Resolve(expr, info, text);
-
- if (rr != null) {
- TextEditor.ShowCompletionWindow(new DotCodeCompletionItemProvider().GenerateCompletionListForResolveResult(rr, expr.Context));
- }
- }
-
- private static void OnCommandTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
- var cell = d as WatchListAutoCompleteCell;
- cell.CommandText = e.NewValue.ToString();
- }
- }
-}
\ No newline at end of file
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.xaml b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.xaml
deleted file mode 100644
index 6148d1da83..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.xaml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/LocalVarPad.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/LocalVarPad.cs
index 6031eb0aa6..cdc918cf61 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/LocalVarPad.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/LocalVarPad.cs
@@ -1,59 +1,54 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
-using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Threading;
using Debugger;
-using Debugger.AddIn.Pads.Controls;
using Debugger.AddIn.TreeModel;
-using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Services;
-using Exception = System.Exception;
-using TreeNode = Debugger.AddIn.TreeModel.TreeNode;
+using ICSharpCode.TreeView;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
public class LocalVarPad : AbstractPadContent
{
- DockPanel panel;
- WatchList localVarList;
- static LocalVarPad instance;
+ SharpTreeView tree;
public override object Control {
- get { return panel; }
+ get { return tree; }
+ }
+
+ SharpTreeNodeCollection Items {
+ get { return tree.Root.Children; }
}
public LocalVarPad()
{
- this.panel = new DockPanel();
- instance = this;
+ var res = new CommonResources();
+ res.InitializeComponent();
- localVarList = new WatchList(WatchListType.LocalVar);
- panel.Children.Add(localVarList);
+ this.tree = new SharpTreeView();
+ this.tree.Root = new SharpTreeNode();
+ this.tree.ShowRoot = false;
+ this.tree.View = (GridView)res["variableGridView"];
WindowsDebugger.RefreshingPads += RefreshPad;
RefreshPad();
}
- /// Always check if Instance is null, might be null if pad is not opened!
- public static LocalVarPad Instance {
- get { return instance; }
- }
-
void RefreshPad()
{
StackFrame frame = WindowsDebugger.CurrentStackFrame;
if (frame == null) {
- localVarList.WatchItems.Clear();
+ this.Items.Clear();
} else {
- localVarList.WatchItems.Clear();
+ this.Items.Clear();
frame.Process.EnqueueForEach(
Dispatcher.CurrentDispatcher,
ValueNode.GetLocalVariables().ToList(),
- n => localVarList.WatchItems.Add(n.ToSharpTreeNode())
+ n => this.Items.Add(n.ToSharpTreeNode())
);
}
}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml
deleted file mode 100644
index 96473894e2..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml.cs
deleted file mode 100644
index bf6688adf1..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
-// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
-
-using System;
-using System.IO;
-using System.Windows;
-using System.Windows.Input;
-
-using ICSharpCode.AvalonEdit;
-using ICSharpCode.Core;
-using ICSharpCode.NRefactory;
-using ICSharpCode.SharpDevelop;
-using ICSharpCode.SharpDevelop.Debugging;
-using ICSharpCode.SharpDevelop.Dom;
-using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
-using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
-using ICSharpCode.SharpDevelop.Gui.Pads;
-using ICSharpCode.SharpDevelop.Project;
-using ICSharpCode.SharpDevelop.Services;
-
-namespace Debugger.AddIn.Pads
-{
- ///
- /// Interaction logic for WatchBox.xaml
- ///
- public partial class WatchInputBox : BaseWatchBox
- {
- private NRefactoryResolver resolver;
- private string language;
-
- public WatchInputBox(string text, string caption) : base()
- {
- InitializeComponent();
-
- // UI
- text = StringParser.Parse(text);
- this.Title = StringParser.Parse(caption);
- this.ConsolePanel.Content = console;
-
- if (ProjectService.CurrentProject == null) return;
-
- // get language
- language = ProjectService.CurrentProject.Language;
- resolver = new NRefactoryResolver(LanguageProperties.GetLanguage(language));
-
- // FIXME set language
- if (language == "VB" || language == "VBNet") {
- console.SetHighlighting("VBNET");
- } else {
- language = "C#";
- console.SetHighlighting("C#");
- }
- }
-
- protected override void AbstractConsolePadTextEntered(object sender, TextCompositionEventArgs e)
- {
- StackFrame frame = WindowsDebugger.CurrentStackFrame;
- if (e.Text == "." && frame != null)
- ShowDotCompletion(frame, console.CommandText);
- }
-
- private void ShowDotCompletion(StackFrame frame, string currentText)
- {
- var seg = frame.NextStatement;
-
- var expressionFinder = ParserService.GetExpressionFinder(seg.Filename);
- var info = ParserService.GetParseInformation(seg.Filename);
-
- string text = ParserService.GetParseableFileContent(seg.Filename).Text;
-
- int currentOffset = TextEditor.Caret.Offset - console.CommandOffset - 1;
-
- var expr = expressionFinder.FindExpression(currentText, currentOffset);
-
- expr.Region = new DomRegion(seg.StartLine, seg.StartColumn, seg.EndLine, seg.EndColumn);
-
- var rr = resolver.Resolve(expr, info, text);
-
- if (rr != null) {
- TextEditor.ShowCompletionWindow(new DotCodeCompletionItemProvider().GenerateCompletionListForResolveResult(rr, expr.Context));
- }
- }
-
- private bool CheckSyntax()
- {
- string command = console.CommandText.Trim();
-
- // FIXME workaround the NRefactory issue that needs a ; at the end
- if (language == "C#") {
- if(!command.EndsWith(";"))
- command += ";";
- // FIXME only one string should be available; highlighting expects C#, supproted language, CSharp
- language = "CSharp";
- }
-
- SupportedLanguage supportedLanguage = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), language, true);
- using (var parser = ParserFactory.CreateParser(supportedLanguage, new StringReader(command))) {
- parser.ParseExpression();
- if (parser.Errors.Count > 0) {
- MessageService.ShowError(parser.Errors.ErrorOutput);
- return false;
- }
- }
-
- return true;
- }
-
- private void AcceptButton_Click(object sender, RoutedEventArgs e)
- {
- if (!this.CheckSyntax())
- return;
-
- this.DialogResult = true;
- this.Close();
- }
-
- private void CancelButton_Click(object sender, RoutedEventArgs e)
- {
- DialogResult = false;
- this.Close();
- }
- }
-}
\ No newline at end of file
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs
index ced18372ca..159ac265dc 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs
@@ -2,15 +2,10 @@
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
using System.Linq;
-using System.Windows;
using System.Windows.Controls;
-using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Threading;
-using System.Xml.Serialization;
using Debugger;
using Debugger.AddIn;
using Debugger.AddIn.Pads.Controls;
@@ -18,191 +13,111 @@ using Debugger.AddIn.TreeModel;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.NRefactory;
-using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Visitors;
-using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Services;
-using Exception = System.Exception;
+using ICSharpCode.TreeView;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
public class WatchPad : AbstractPadContent
{
- DockPanel panel;
- WatchList watchList;
-
- static WatchPad instance;
+ SharpTreeView tree;
public override object Control {
- get { return panel; }
+ get { return tree; }
}
- /// Always check if Instance is null, might be null if pad is not opened!
- public static WatchPad Instance {
- get { return instance; }
+ public SharpTreeView Tree {
+ get { return tree; }
}
- public WatchList WatchList {
- get {
- return watchList;
- }
+ public SharpTreeNodeCollection Items {
+ get { return tree.Root.Children; }
}
public WatchPad()
{
- this.panel = new DockPanel();
-
- instance = this;
-
- watchList = new WatchList(WatchListType.Watch);
- watchList.ContextMenu = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/WatchPad/ContextMenu");
-
- watchList.MouseDoubleClick += watchList_DoubleClick;
- watchList.KeyUp += watchList_KeyUp;
- watchList.WatchItems.CollectionChanged += OnWatchItemsCollectionChanged;
-
- panel.Children.Add(watchList);
- panel.KeyUp += new KeyEventHandler(panel_KeyUp);
-
- // wire events that influence the items
- LoadSavedNodes();
- ProjectService.SolutionClosed += delegate { watchList.WatchItems.Clear(); };
- ProjectService.ProjectAdded += delegate { LoadSavedNodes(); };
- ProjectService.SolutionLoaded += delegate { LoadSavedNodes(); };
-
- WindowsDebugger.RefreshingPads += RefreshPad;
- RefreshPad();
- }
-
- #region Saved nodes
-
- void LoadSavedNodes()
- {
- var props = GetSavedVariablesProperties();
- if (props == null)
- return;
-
- foreach (var element in props.Elements) {
- watchList.WatchItems.Add(new TreeNode(element, null).ToSharpTreeNode());
- }
- }
-
- void OnWatchItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- var props = GetSavedVariablesProperties();
- if (props == null) return;
-
- if (e.Action == NotifyCollectionChangedAction.Add) {
- // add to saved data
- foreach(var data in e.NewItems.OfType()) {
- props.Set(data.Name, (object)null);
+ var res = new CommonResources();
+ res.InitializeComponent();
+
+ this.tree = new SharpTreeView();
+ this.tree.Root = new SharpTreeNode();
+ this.tree.ShowRoot = false;
+ this.tree.View = (GridView)res["variableGridView"];
+ this.tree.ContextMenu = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/WatchPad/ContextMenu");
+ this.tree.KeyUp += delegate(object sender, KeyEventArgs e) {
+ if (e.Key == Key.Delete) {
+ RemoveWatchCommand cmd = new RemoveWatchCommand { Owner = this };
+ cmd.Run();
}
- }
-
- if (e.Action == NotifyCollectionChangedAction.Remove) {
- // remove from saved data
- foreach(var data in e.OldItems.OfType()) {
- props.Remove(data.Name);
+ };
+ this.tree.MouseDoubleClick += delegate(object sender, MouseButtonEventArgs e) {
+ if (this.tree.SelectedItem == null) {
+ AddWatchCommand cmd = new AddWatchCommand { Owner = this };
+ cmd.Run();
}
- }
- }
-
- Properties GetSavedVariablesProperties()
- {
- if (ProjectService.CurrentProject == null)
- return null;
- if (ProjectService.CurrentProject.ProjectSpecificProperties == null)
- return null;
+ };
- var props = ProjectService.CurrentProject.ProjectSpecificProperties.Get("watchVars") as Properties;
- if (props == null) {
- ProjectService.CurrentProject.ProjectSpecificProperties.Set("watchVars", new Properties());
- }
+ ProjectService.SolutionLoaded += delegate { LoadNodes(); };
+ ProjectService.SolutionClosing += delegate { SaveNodes(); };
+ LoadNodes();
- return ProjectService.CurrentProject.ProjectSpecificProperties.Get("watchVars") as Properties;
+ WindowsDebugger.RefreshingPads += RefreshPad;
+ RefreshPad();
}
- #endregion
-
- void panel_KeyUp(object sender, KeyEventArgs e)
+ void LoadNodes()
{
- if (e.Key == Key.Insert) {
- AddNewWatch();
- e.Handled = true;
+ if (ProjectService.OpenSolution != null &&
+ ProjectService.OpenSolution.Preferences != null &&
+ ProjectService.OpenSolution.Preferences.Properties != null)
+ {
+ var props = ProjectService.OpenSolution.Preferences.Properties.Get("Watches", new Properties());
+ foreach(var element in props.Elements) {
+ this.Items.Add(new TreeNode(element, null).ToSharpTreeNode());
+ }
}
}
- void watchList_KeyUp(object sender, KeyEventArgs e)
+ void SaveNodes()
{
- if (e.Key == Key.Delete) {
- RemoveWatchCommand cmd = new RemoveWatchCommand { Owner = this };
- cmd.Run();
- }
- }
-
- void watchList_DoubleClick(object sender, MouseEventArgs e)
- {
- if (watchList.SelectedNode == null)
+ if (ProjectService.OpenSolution != null &&
+ ProjectService.OpenSolution.Preferences != null &&
+ ProjectService.OpenSolution.Preferences.Properties != null)
{
- AddNewWatch();
+ var props = new Properties();
+ ProjectService.OpenSolution.Preferences.Properties.Set("Watches", props);
+ foreach(var node in this.Items.OfType()) {
+ props.Set(node.Name, (object)null);
+ }
}
}
- void AddNewWatch()
- {
- AddWatchCommand command = new AddWatchCommand { Owner = this };
- command.Run();
- }
-
- void ResetPad(object sender, EventArgs e)
- {
- string language = "CSharp";
-
- if (ProjectService.CurrentProject != null)
- language = ProjectService.CurrentProject.Language;
-
- // rebuild list
- var nodes = new List();
- foreach (var nod in watchList.WatchItems.OfType())
- nodes.Add(new TreeNode(nod.Node.Name, null).ToSharpTreeNode());
-
- watchList.WatchItems.Clear();
- foreach (var nod in nodes)
- watchList.WatchItems.Add(nod);
- }
-
- TreeNodeWrapper UpdateNode(TreeNodeWrapper node, Process process)
+ SharpTreeNodeAdapter MakeNode(string name)
{
+ LoggingService.Info("Evaluating watch: " + name);
+ TreeNode node;
try {
- LoggingService.Info("Evaluating: " + (string.IsNullOrEmpty(node.Node.Name) ? "is null or empty!" : node.Node.Name));
-
- ValueNode valNode = new ValueNode(null, node.Node.Name, () => ExpressionEvaluator.Evaluate(node.Node.Name, SupportedLanguage.CSharp, WindowsDebugger.CurrentStackFrame));
- return valNode.ToSharpTreeNode();
- } catch (GetValueException) {
- string error = String.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.InvalidExpression}"), node.Node.Name);
- TreeNode infoNode = new TreeNode("Icons.16x16.Error", node.Node.Name, error, string.Empty, null);
- return infoNode.ToSharpTreeNode();
+ node = new ValueNode(null, name, () => ExpressionEvaluator.Evaluate(name, SupportedLanguage.CSharp, WindowsDebugger.CurrentStackFrame));
+ } catch (GetValueException e) {
+ node = new TreeNode("Icons.16x16.Error", name, e.Message, string.Empty, null);
}
+ node.CanSetName = true;
+ node.PropertyChanged += (s, e) => { if (e.PropertyName == "Name") WindowsDebugger.RefreshPads(); };
+ return node.ToSharpTreeNode();
}
protected void RefreshPad()
{
- Process debuggedProcess = WindowsDebugger.CurrentProcess;
-
- ResetPad(null, null);
-
- if (debuggedProcess == null || debuggedProcess.IsRunning)
- return;
-
- using(new PrintTimes("Watch Pad refresh")) {
- var nodes = watchList.WatchItems.OfType().ToArray();
- watchList.WatchItems.Clear();
-
- debuggedProcess.EnqueueForEach(
+ Process process = WindowsDebugger.CurrentProcess;
+ if (process != null) {
+ var names = this.Items.OfType().Select(n => n.Node.Name).ToList();
+ this.Items.Clear();
+ process.EnqueueForEach(
Dispatcher.CurrentDispatcher,
- nodes,
- n => watchList.WatchItems.Add(UpdateNode(n, debuggedProcess))
+ names,
+ name => this.Items.Add(MakeNode(name))
);
}
}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeNodeWrapper.cs b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/SharpTreeNodeAdapter.cs
similarity index 86%
rename from src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeNodeWrapper.cs
rename to src/AddIns/Debugger/Debugger.AddIn/TreeModel/SharpTreeNodeAdapter.cs
index 230a1a6130..c49c09a947 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeNodeWrapper.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/SharpTreeNodeAdapter.cs
@@ -15,24 +15,20 @@ using ICSharpCode.TreeView;
namespace Debugger.AddIn.Pads.Controls
{
- public class TreeNodeWrapper : SharpTreeNode
+ public class SharpTreeNodeAdapter : SharpTreeNode
{
- public TreeNodeWrapper(TreeNode node)
+ public SharpTreeNodeAdapter(TreeNode node)
{
if (node == null)
throw new ArgumentNullException("node");
- Node = node;
- LazyLoading = true;
+ this.Node = node;
+ this.LazyLoading = true;
}
public TreeNode Node { get; private set; }
- public override object Text {
- get { return this.Node.Name; }
- }
-
public override object Icon {
- get { return this.Node.Image.ImageSource; }
+ get { return this.Node.Image != null ? this.Node.Image.ImageSource : null; }
}
public override bool ShowExpander {
@@ -46,10 +42,8 @@ namespace Debugger.AddIn.Pads.Controls
process.EnqueueWork(Dispatcher.CurrentDispatcher, () => Children.AddRange(this.Node.GetChildren().Select(node => node.ToSharpTreeNode())));
}
}
- }
-
- public class WatchRootNode : SharpTreeNode
- {
+
+ /*
public override bool CanDrop(System.Windows.DragEventArgs e, int index)
{
e.Effects = DragDropEffects.None;
@@ -72,10 +66,11 @@ namespace Debugger.AddIn.Pads.Controls
var text = new TreeNode(e.Data.GetData(DataFormats.StringFormat).ToString(), null);
var node = text.ToSharpTreeNode();
- if (!WatchPad.Instance.WatchList.WatchItems.Any(n => text.Name == ((TreeNodeWrapper)n).Node.Name))
+ if (!WatchPad.Instance.WatchList.WatchItems.Any(n => text.Name == ((SharpTreeNodeAdapter)n).Node.Name))
WatchPad.Instance.WatchList.WatchItems.Add(node);
WindowsDebugger.RefreshPads();
}
+ */
}
}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/TreeNode.cs b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/TreeNode.cs
index b90a7745ec..de334bb9c4 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/TreeNode.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/TreeNode.cs
@@ -19,7 +19,7 @@ namespace Debugger.AddIn.TreeModel
public class TreeNode : INotifyPropertyChanged
{
public event EventHandler PropertyRead;
- public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+ public event PropertyChangedEventHandler PropertyChanged;
IImage image;
string name;
@@ -52,7 +52,7 @@ namespace Debugger.AddIn.TreeModel
}
}
- public bool CanSetName { get; protected set; }
+ public bool CanSetName { get; set; }
public string Value {
get {
@@ -67,7 +67,7 @@ namespace Debugger.AddIn.TreeModel
}
}
- public bool CanSetValue { get; protected set; }
+ public bool CanSetValue { get; set; }
public string Type {
get {
diff --git a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/Utils.cs b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/Utils.cs
index 1119d36c7a..cf83f852b9 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/Utils.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/Utils.cs
@@ -122,9 +122,9 @@ namespace Debugger.AddIn.TreeModel
public static class ExtensionMethods
{
- public static TreeNodeWrapper ToSharpTreeNode(this TreeNode node)
+ public static SharpTreeNodeAdapter ToSharpTreeNode(this TreeNode node)
{
- return new TreeNodeWrapper(node);
+ return new SharpTreeNodeAdapter(node);
}
}
}