diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj index a40434d2d0..2ca7f637c2 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj @@ -133,7 +133,7 @@ - + @@ -141,6 +141,7 @@ + @@ -175,6 +176,7 @@ + TextVisualizerWindow.xaml Code diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ExpressionNodeVisualizerCommand.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ExpressionVisualizerCommand.cs similarity index 85% rename from src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ExpressionNodeVisualizerCommand.cs rename to src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ExpressionVisualizerCommand.cs index 68775ef96f..a42bcb5969 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ExpressionNodeVisualizerCommand.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ExpressionVisualizerCommand.cs @@ -17,11 +17,11 @@ namespace Debugger.AddIn.Visualizers /// Visualizer command for /// // should we make visualizer command available for Expression, or any TreeNode? - public abstract class ExpressionNodeVisualizerCommand : IVisualizerCommand + public abstract class ExpressionVisualizerCommand : IVisualizerCommand { public Expression Expression { get; private set; } - public ExpressionNodeVisualizerCommand(Expression expression) + public ExpressionVisualizerCommand(Expression expression) { this.Expression = expression; } diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/GridVisualizerCommand.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/GridVisualizerCommand.cs index 5ee71c5848..ee88fab70d 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/GridVisualizerCommand.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/GridVisualizerCommand.cs @@ -21,7 +21,7 @@ namespace Debugger.AddIn.Visualizers public bool IsVisualizerAvailable(DebugType type) { DebugType collectionType, itemType; - // Visualizer available for IEnumerable + // Visualizer available for IEnumerable (that means also IList) return type.ResolveIEnumerableImplementation(out collectionType, out itemType); } @@ -34,7 +34,7 @@ namespace Debugger.AddIn.Visualizers /// /// Shows grid visualizer for a node. /// - public class GridVisualizerCommand : ExpressionNodeVisualizerCommand + public class GridVisualizerCommand : ExpressionVisualizerCommand { public GridVisualizerCommand(Expression expression) :base(expression) diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ObjectGraphVisualizerCommand.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ObjectGraphVisualizerCommand.cs index 0690eab831..b209ea6242 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ObjectGraphVisualizerCommand.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/ObjectGraphVisualizerCommand.cs @@ -33,7 +33,7 @@ namespace Debugger.AddIn.Visualizers /// /// Shows object graph visualizer for a node. /// - public class ObjectGraphVisualizerCommand : ExpressionNodeVisualizerCommand + public class ObjectGraphVisualizerCommand : ExpressionVisualizerCommand { public ObjectGraphVisualizerCommand(Expression expression) :base(expression) diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/TextVisualizerCommand.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/TextVisualizerCommand.cs index bf0c97cc1d..671a21d080 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/TextVisualizerCommand.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/TextVisualizerCommand.cs @@ -32,7 +32,7 @@ namespace Debugger.AddIn.Visualizers /// /// Description of TextVisualizerCommand. /// - public class TextVisualizerCommand : ExpressionNodeVisualizerCommand + public class TextVisualizerCommand : ExpressionVisualizerCommand { public TextVisualizerCommand(Expression expression) :base(expression) @@ -54,6 +54,7 @@ namespace Debugger.AddIn.Visualizers { var textVisualizerWindow = new TextVisualizerWindow( this.Expression.PrettyPrint(), this.Expression.Evaluate(WindowsDebugger.CurrentProcess).InvokeToString()); + textVisualizerWindow.Mode = TextVisualizerMode.PlainText; textVisualizerWindow.ShowDialog(); } } diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/VisualizerDescriptors.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/VisualizerDescriptors.cs index dc1dc22bd3..c9e7387cc2 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/VisualizerDescriptors.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/VisualizerDescriptors.cs @@ -18,10 +18,11 @@ namespace Debugger.AddIn.Visualizers { static ReadOnlyCollection allDescriptors; - static IEnumerable createAllDescriptors() + static IEnumerable CreateAllDescriptors() { // these should be obtained from AddIn tree so that it is possible to write add-in for Debugger.AddIn with new visualizers yield return new TextVisualizerDescriptor(); + yield return new XmlVisualizerDescriptor(); yield return new ObjectGraphVisualizerDescriptor(); yield return new GridVisualizerDescriptor(); } @@ -29,7 +30,7 @@ namespace Debugger.AddIn.Visualizers public static ReadOnlyCollection GetAllDescriptors() { if (allDescriptors == null) { - allDescriptors = new List(createAllDescriptors()).AsReadOnly(); + allDescriptors = new List(CreateAllDescriptors()).AsReadOnly(); } return allDescriptors; } diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/XmlVisualizerCommand.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/XmlVisualizerCommand.cs new file mode 100644 index 0000000000..57664286db --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/Commands/XmlVisualizerCommand.cs @@ -0,0 +1,62 @@ +// +// +// +// +// $Revision$ +// +using Debugger.MetaData; +using System; +using System.Collections.Generic; +using System.Linq; +using Debugger.AddIn.TreeModel; +using Debugger.AddIn.Visualizers.TextVisualizer; +using ICSharpCode.NRefactory.Ast; +using ICSharpCode.SharpDevelop.Debugging; +using ICSharpCode.SharpDevelop.Services; + +namespace Debugger.AddIn.Visualizers +{ + public class XmlVisualizerDescriptor : IVisualizerDescriptor + { + public bool IsVisualizerAvailable(DebugType type) + { + return type.IsString; + } + + public IVisualizerCommand CreateVisualizerCommand(Expression expression) + { + return new XmlVisualizerCommand(expression); + } + } + + /// + /// Description of TextVisualizerCommand. + /// + public class XmlVisualizerCommand : ExpressionVisualizerCommand + { + public XmlVisualizerCommand(Expression expression) + :base(expression) + { + } + + public override bool CanExecute { + get { return true; } + } + + public override string ToString() + { + return "Xml visualizer"; + } + + public override void Execute() + { + if (this.Expression != null) + { + var textVisualizerWindow = new TextVisualizerWindow( + this.Expression.PrettyPrint(), this.Expression.Evaluate(WindowsDebugger.CurrentProcess).InvokeToString()); + textVisualizerWindow.Mode = TextVisualizerMode.Xml; + textVisualizerWindow.ShowDialog(); + } + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/TextVisualizer/TextVisualizerMode.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/TextVisualizer/TextVisualizerMode.cs new file mode 100644 index 0000000000..e8563bcc08 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/TextVisualizer/TextVisualizerMode.cs @@ -0,0 +1,15 @@ +// +// +// +// +// $Revision$ +// +using System.Collections.Generic; +using System.Linq; +using System; + +public enum TextVisualizerMode +{ + PlainText, + Xml +} \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/TextVisualizer/TextVisualizerWindow.xaml b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/TextVisualizer/TextVisualizerWindow.xaml index 758cf04bf1..997cdf322e 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/TextVisualizer/TextVisualizerWindow.xaml +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/TextVisualizer/TextVisualizerWindow.xaml @@ -1,6 +1,9 @@  - + ScrollViewer.VerticalScrollBarVisibility="Auto"> \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/TextVisualizer/TextVisualizerWindow.xaml.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/TextVisualizer/TextVisualizerWindow.xaml.cs index d61c469309..72f74f4bcd 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/TextVisualizer/TextVisualizerWindow.xaml.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/TextVisualizer/TextVisualizerWindow.xaml.cs @@ -4,9 +4,10 @@ // // $Revision$ // -using System.Linq; +using ICSharpCode.AvalonEdit.Highlighting; using System; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; @@ -25,6 +26,8 @@ namespace Debugger.AddIn.Visualizers.TextVisualizer public TextVisualizerWindow() { InitializeComponent(); + Mode = TextVisualizerMode.PlainText; + textEditor.IsReadOnly = true; } public TextVisualizerWindow(string title, string text) @@ -37,18 +40,35 @@ namespace Debugger.AddIn.Visualizers.TextVisualizer public string Text { - get { return this.txtText.Text; } - set { this.txtText.Text = value; } + get { return this.textEditor.Text; } + set { this.textEditor.Text = value; } + } + + private TextVisualizerMode mode; + public TextVisualizerMode Mode + { + get { return mode; } + set { + mode = value; + switch (mode) { + case TextVisualizerMode.PlainText: + textEditor.SyntaxHighlighting = null; + break; + case TextVisualizerMode.Xml: + textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(".xml"); + break; + } + } } void CheckBox_CheckedChanged(object sender, RoutedEventArgs e) { - txtText.TextWrapping = chbWrap.IsChecked.GetValueOrDefault(false) ? TextWrapping.Wrap : TextWrapping.NoWrap; + textEditor.WordWrap = chbWrap.IsChecked.GetValueOrDefault(false); } void BtnCopy_Click(object sender, RoutedEventArgs e) { - Clipboard.SetText(txtText.Text); + Clipboard.SetText(textEditor.Text); } void BtnClose_Click(object sender, RoutedEventArgs e)