Browse Source

Numbers can be set using debugger tooltip

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@768 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
dee7a7ede4
  1. 27
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs
  2. 57
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs
  3. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs
  4. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs

27
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs

@ -7,7 +7,9 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms;
using Debugger; using Debugger;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Gui.TreeGrid; using ICSharpCode.SharpDevelop.Gui.TreeGrid;
namespace ICSharpCode.SharpDevelop.Services namespace ICSharpCode.SharpDevelop.Services
@ -41,16 +43,33 @@ namespace ICSharpCode.SharpDevelop.Services
this.variable = variable; this.variable = variable;
this[1].Paint += OnIconPaint;
this[2].Text = variable.Name; this[2].Text = variable.Name;
this[3].Text = variable.Value.AsString; this[3].Text = variable.Value.AsString;
this[3].FinishLabelEdit += OnLabelEdited;
this[1].Paint += delegate(object sender, ItemPaintEventArgs e) { if (variable.Value is PrimitiveValue && variable.Value.ManagedType != typeof(string)) {
e.Graphics.DrawImageUnscaled(DebuggerIcons.GetImage(variable), e.ClipRectangle); this[3].AllowLabelEdit = true;
}; }
if (!variable.Value.MayHaveSubVariables) if (!variable.Value.MayHaveSubVariables)
this.ShowPlus = false; this.ShowPlus = false;
this.ShowMinusWhileExpanded = true; this.ShowMinusWhileExpanded = true;
} }
void OnIconPaint(object sender, ItemPaintEventArgs e)
{
e.Graphics.DrawImage(DebuggerIcons.GetImage(variable), e.ClipRectangle);
}
void OnLabelEdited(object sender, DynamicListEventArgs e)
{
PrimitiveValue val = (PrimitiveValue)variable.Value;
string newValue = ((DynamicListItem)sender).Text;
try {
val.Primitive = newValue;
} catch (NotSupportedException) {
MessageBox.Show(WorkbenchSingleton.MainForm, "Can not covert " + newValue + " to " + val.ManagedType.ToString(), "Can not set value");
}
}
} }
} }

57
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PrimitiveValue.cs

@ -6,6 +6,7 @@
// </file> // </file>
using System; using System;
using System.ComponentModel;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Debugger.Interop.CorDebug; using Debugger.Interop.CorDebug;
@ -14,6 +15,14 @@ namespace Debugger
{ {
public class PrimitiveValue: Value public class PrimitiveValue: Value
{ {
public event EventHandler<ValueEventArgs> ValueChanged;
protected virtual void OnValueChanged() {
if (ValueChanged != null) {
ValueChanged(this, new ValueEventArgs(this));
}
}
public override string AsString { public override string AsString {
get { get {
if (Primitive != null) { if (Primitive != null) {
@ -24,12 +33,9 @@ namespace Debugger
} }
} }
public unsafe object Primitive public unsafe object Primitive {
{ get {
get if (CorType == CorElementType.STRING) {
{
if (CorType == CorElementType.STRING)
{
uint pStringLenght = 1; // Terminating character NOT included in pStringLenght uint pStringLenght = 1; // Terminating character NOT included in pStringLenght
IntPtr pString = Marshal.AllocHGlobal(2); IntPtr pString = Marshal.AllocHGlobal(2);
@ -51,7 +57,7 @@ namespace Debugger
Marshal.FreeHGlobal(pString); Marshal.FreeHGlobal(pString);
return text; return text;
} } else {
object retValue; object retValue;
IntPtr pValue = Marshal.AllocHGlobal(8); IntPtr pValue = Marshal.AllocHGlobal(8);
@ -78,6 +84,43 @@ namespace Debugger
return retValue; return retValue;
} }
} }
set {
object newValue;
TypeConverter converter = TypeDescriptor.GetConverter(ManagedType);
try {
newValue = converter.ConvertFrom(value);
} catch {
throw new NotSupportedException("Can not convert " + value.GetType().ToString() + " to " + ManagedType.ToString());
}
if (CorType == CorElementType.STRING) {
throw new NotSupportedException();
} else {
IntPtr pValue = Marshal.AllocHGlobal(8);
switch(CorType)
{
case CorElementType.BOOLEAN: *((System.Boolean*)pValue) = (System.Boolean)newValue; break;
case CorElementType.CHAR: *((System.Char*)pValue) = (System.Char)newValue; break;
case CorElementType.I1: *((System.SByte*)pValue) = (System.SByte)newValue; break;
case CorElementType.U1: *((System.Byte*)pValue) = (System.Byte)newValue; break;
case CorElementType.I2: *((System.Int16*)pValue) = (System.Int16)newValue; break;
case CorElementType.U2: *((System.UInt16*)pValue) = (System.UInt16)newValue; break;
case CorElementType.I4: *((System.Int32*)pValue) = (System.Int32)newValue; break;
case CorElementType.U4: *((System.UInt32*)pValue) = (System.UInt32)newValue; break;
case CorElementType.I8: *((System.Int64*)pValue) = (System.Int64)newValue; break;
case CorElementType.U8: *((System.UInt64*)pValue) = (System.UInt64)newValue; break;
case CorElementType.R4: *((System.Single*)pValue) = (System.Single)newValue; break;
case CorElementType.R8: *((System.Double*)pValue) = (System.Double)newValue; break;
case CorElementType.I: *((int*)pValue) = (int)newValue; break;
case CorElementType.U: *((uint*)pValue) = (uint)newValue; break;
default: throw new NotSupportedException();
}
((ICorDebugGenericValue)corValue).SetValue(pValue);
Marshal.FreeHGlobal(pValue);
}
OnValueChanged();
}
}
internal PrimitiveValue(NDebugger debugger, ICorDebugValue corValue):base(debugger, corValue) internal PrimitiveValue(NDebugger debugger, ICorDebugValue corValue):base(debugger, corValue)
{ {

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Value.cs

@ -47,6 +47,12 @@ namespace Debugger
} }
} }
public virtual Type ManagedType {
get {
return CorTypeToManagedType(CorType);
}
}
public abstract bool MayHaveSubVariables { public abstract bool MayHaveSubVariables {
get; get;
} }

5
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs

@ -38,6 +38,9 @@ namespace Debugger
} }
internal set { internal set {
val = value; val = value;
if (val is PrimitiveValue) {
((PrimitiveValue)val).ValueChanged += delegate { OnValueChanged(); };
}
OnValueChanged(); OnValueChanged();
} }
} }
@ -84,7 +87,7 @@ namespace Debugger
public Variable(NDebugger debugger, Value val, string name) public Variable(NDebugger debugger, Value val, string name)
{ {
this.debugger = debugger; this.debugger = debugger;
this.val = val; this.Value = val;
this.name = name; this.name = name;
this.subVariables = new VariableCollection(debugger); this.subVariables = new VariableCollection(debugger);
this.subVariables.Updating += OnSubVariablesUpdating; this.subVariables.Updating += OnSubVariablesUpdating;

Loading…
Cancel
Save