Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2270 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
10 changed files with 514 additions and 237 deletions
@ -0,0 +1,124 @@
@@ -0,0 +1,124 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
using ICSharpCode.Core; |
||||
|
||||
namespace Debugger |
||||
{ |
||||
public class BaseTypeItem: ListItem |
||||
{ |
||||
NamedValue val; |
||||
DebugType type; |
||||
|
||||
public NamedValue Value { |
||||
get { |
||||
return val; |
||||
} |
||||
} |
||||
|
||||
public DebugType DebugType { |
||||
get { |
||||
return type; |
||||
} |
||||
} |
||||
|
||||
public override int ImageIndex { |
||||
get { |
||||
return -1; |
||||
} |
||||
} |
||||
|
||||
public override string Name { |
||||
get { |
||||
return StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.BaseClass}"); |
||||
} |
||||
} |
||||
|
||||
public override string Text { |
||||
get { |
||||
return String.Empty; |
||||
} |
||||
} |
||||
|
||||
public override bool CanEditText { |
||||
get { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public override string Type { |
||||
get { |
||||
return type.FullName; |
||||
} |
||||
} |
||||
|
||||
public override bool HasSubItems { |
||||
get { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public override IList<ListItem> SubItems { |
||||
get { |
||||
return GetSubItems(); |
||||
} |
||||
} |
||||
|
||||
public BaseTypeItem(NamedValue val, DebugType type) |
||||
{ |
||||
this.val = val; |
||||
this.type = type; |
||||
} |
||||
|
||||
List<ListItem> GetMembers(BindingFlags flags) |
||||
{ |
||||
List<ListItem> list = new List<ListItem>(); |
||||
foreach(NamedValue v in val.GetMembers(type, flags)) { |
||||
list.Add(new ValueItem(v)); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
IList<ListItem> GetSubItems() |
||||
{ |
||||
List<ListItem> list = new List<ListItem>(); |
||||
|
||||
string privateRes = StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.PrivateMembers}"); |
||||
string staticRes = StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.StaticMembers}"); |
||||
string privateStaticRes = StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.PrivateStaticMembers}"); |
||||
|
||||
List<ListItem> publicInstance = GetMembers(BindingFlags.Public | BindingFlags.Instance); |
||||
List<ListItem> publicStatic = GetMembers(BindingFlags.Public | BindingFlags.Static); |
||||
List<ListItem> privateInstance = GetMembers(BindingFlags.NonPublic | BindingFlags.Instance); |
||||
List<ListItem> privateStatic = GetMembers(BindingFlags.NonPublic | BindingFlags.Static); |
||||
|
||||
if (type.BaseType != null) { |
||||
list.Add(new BaseTypeItem(val, type.BaseType)); |
||||
} |
||||
|
||||
if (publicStatic.Count > 0) { |
||||
list.Add(new FixedItem(-1, staticRes, String.Empty, String.Empty, true, publicStatic)); |
||||
} |
||||
|
||||
if (privateInstance.Count > 0 || privateStatic.Count > 0) { |
||||
List<ListItem> nonPublicItems = new List<ListItem>(); |
||||
if (privateStatic.Count > 0) { |
||||
nonPublicItems.Add(new FixedItem(-1, privateStaticRes, String.Empty, String.Empty, true, privateStatic)); |
||||
} |
||||
nonPublicItems.AddRange(privateInstance); |
||||
list.Add(new FixedItem(-1, privateRes, String.Empty, String.Empty, true, nonPublicItems)); |
||||
} |
||||
|
||||
list.AddRange(publicInstance); |
||||
|
||||
return list; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace Debugger |
||||
{ |
||||
public class FixedItem: ListItem |
||||
{ |
||||
int imageIndex; |
||||
string name; |
||||
string text; |
||||
string type; |
||||
bool hasSubItems; |
||||
IList<ListItem> subItems; |
||||
|
||||
public override int ImageIndex { |
||||
get { |
||||
return imageIndex; |
||||
} |
||||
} |
||||
|
||||
public override string Name { |
||||
get { |
||||
return name; |
||||
} |
||||
} |
||||
|
||||
public override string Text { |
||||
get { |
||||
return text; |
||||
} |
||||
} |
||||
|
||||
public override bool CanEditText { |
||||
get { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public override string Type { |
||||
get { |
||||
return type; |
||||
} |
||||
} |
||||
|
||||
public override bool HasSubItems { |
||||
get { |
||||
return hasSubItems; |
||||
} |
||||
} |
||||
|
||||
public override IList<ListItem> SubItems { |
||||
get { |
||||
return subItems; |
||||
} |
||||
} |
||||
|
||||
public FixedItem(int imageIndex, string name, string text, string type, bool hasSubItems, IList<ListItem> subItems) |
||||
{ |
||||
this.imageIndex = imageIndex; |
||||
this.name = name; |
||||
this.text = text; |
||||
this.type = type; |
||||
this.hasSubItems = hasSubItems; |
||||
this.subItems = subItems; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace Debugger |
||||
{ |
||||
public abstract class ListItem |
||||
{ |
||||
public event EventHandler<ListItemEventArgs> Changed; |
||||
|
||||
public abstract int ImageIndex { get; } |
||||
public abstract string Name { get; } |
||||
public abstract string Text { get; } |
||||
public abstract bool CanEditText { get; } |
||||
public abstract string Type { get; } |
||||
public abstract bool HasSubItems { get; } |
||||
public abstract IList<ListItem> SubItems { get; } |
||||
|
||||
public System.Drawing.Image Image { |
||||
get { |
||||
if (ImageIndex == -1) { |
||||
return null; |
||||
} else { |
||||
return DebuggerIcons.ImageList.Images[ImageIndex]; |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnChanged(ListItemEventArgs e) |
||||
{ |
||||
if (Changed != null) { |
||||
Changed(this, e); |
||||
} |
||||
} |
||||
|
||||
public virtual bool SetText(string newValue) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public virtual ContextMenuStrip GetContextMenu() |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace Debugger |
||||
{ |
||||
public class ListItemEventArgs: EventArgs |
||||
{ |
||||
ListItem listItem; |
||||
|
||||
public ListItem ListItem { |
||||
get { |
||||
return listItem; |
||||
} |
||||
} |
||||
|
||||
public ListItemEventArgs(ListItem listItem) |
||||
{ |
||||
this.listItem = listItem; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,154 @@
@@ -0,0 +1,154 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Runtime.InteropServices; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Services; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
|
||||
namespace Debugger |
||||
{ |
||||
class ValueItem: ListItem |
||||
{ |
||||
NamedValue val; |
||||
|
||||
public NamedValue Value { |
||||
get { |
||||
return val; |
||||
} |
||||
} |
||||
|
||||
public static bool ShowValuesInHexadecimal { |
||||
get { |
||||
return ((WindowsDebugger)DebuggerService.CurrentDebugger).Properties.Get("ShowValuesInHexadecimal", false); |
||||
} |
||||
set { |
||||
((WindowsDebugger)DebuggerService.CurrentDebugger).Properties.Set("ShowValuesInHexadecimal", value); |
||||
} |
||||
} |
||||
|
||||
public override int ImageIndex { |
||||
get { |
||||
if (val.IsObject) { |
||||
return 0; // Class
|
||||
} else { |
||||
return 1; // Field
|
||||
} |
||||
} |
||||
} |
||||
|
||||
public override string Name { |
||||
get { |
||||
return val.Name; |
||||
} |
||||
} |
||||
|
||||
public override string Text { |
||||
get { |
||||
if (ShowValuesInHexadecimal && val.IsInteger) { |
||||
return String.Format("0x{0:X}", val.PrimitiveValue); |
||||
} else { |
||||
return val.AsString; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override bool CanEditText { |
||||
get { |
||||
return val.IsInteger && !ShowValuesInHexadecimal; |
||||
} |
||||
} |
||||
|
||||
public override string Type { |
||||
get { |
||||
if (val.Type != null) { |
||||
return val.Type.FullName; |
||||
} else { |
||||
return String.Empty; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public override bool HasSubItems { |
||||
get { |
||||
return val.IsObject || val.IsArray; |
||||
} |
||||
} |
||||
|
||||
public override IList<ListItem> SubItems { |
||||
get { |
||||
List<ListItem> list = new List<ListItem>(); |
||||
if (val.IsArray) { |
||||
foreach(NamedValue element in val.GetArrayElements()) { |
||||
list.Add(new ValueItem(element)); |
||||
} |
||||
} |
||||
if (val.IsObject) { |
||||
return new BaseTypeItem(val, val.Type).SubItems; |
||||
} |
||||
return list; |
||||
} |
||||
} |
||||
|
||||
public ValueItem(NamedValue val) |
||||
{ |
||||
this.val = val; |
||||
|
||||
val.Changed += delegate { OnChanged(new ListItemEventArgs(this)); }; |
||||
} |
||||
|
||||
public override bool SetText(string newValue) |
||||
{ |
||||
try { |
||||
val.PrimitiveValue = newValue; |
||||
return true; |
||||
} catch (NotSupportedException) { |
||||
string format = ResourceService.GetString("MainWindow.Windows.Debug.LocalVariables.CannotSetValue.BadFormat"); |
||||
string msg = String.Format(format, newValue, val.Type.ManagedType.ToString()); |
||||
MessageService.ShowMessage(msg ,"${res:MainWindow.Windows.Debug.LocalVariables.CannotSetValue.Title}"); |
||||
} catch (COMException) { |
||||
// COMException (0x80131330): Cannot perfrom SetValue on non-leaf frames.
|
||||
// Happens if trying to set value after exception is breaked
|
||||
MessageService.ShowMessage("${res:MainWindow.Windows.Debug.LocalVariables.CannotSetValue.UnknownError}", |
||||
"${res:MainWindow.Windows.Debug.LocalVariables.CannotSetValue.Title}"); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public override ContextMenuStrip GetContextMenu() |
||||
{ |
||||
ContextMenuStrip menu = new ContextMenuStrip(); |
||||
|
||||
ToolStripMenuItem copyItem; |
||||
copyItem = new ToolStripMenuItem(); |
||||
copyItem.Text = ResourceService.GetString("MainWindow.Windows.Debug.LocalVariables.CopyToClipboard"); |
||||
copyItem.Checked = false; |
||||
copyItem.Click += delegate { |
||||
ClipboardWrapper.SetText(this.Text); |
||||
}; |
||||
|
||||
ToolStripMenuItem hewView; |
||||
hewView = new ToolStripMenuItem(); |
||||
hewView.Text = ResourceService.GetString("MainWindow.Windows.Debug.LocalVariables.ShowInHexadecimal"); |
||||
hewView.Checked = ShowValuesInHexadecimal; |
||||
hewView.Click += delegate { |
||||
ShowValuesInHexadecimal = !ShowValuesInHexadecimal; |
||||
}; |
||||
|
||||
menu.Items.AddRange(new ToolStripItem[] { |
||||
copyItem, |
||||
hewView |
||||
}); |
||||
|
||||
return menu; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue