Debugger: Fixed issues with watch list and the "add to watch" shortcut

This commit is contained in:
Souryo 2016-02-13 23:13:44 -05:00
parent 51cad0e870
commit 700a71446b
3 changed files with 27 additions and 3 deletions

View File

@ -13,7 +13,7 @@ namespace Mesen.GUI.Controls
{
private bool _preventCheck = false;
private int _editItemIndex = -1;
private string _originalText;
private string _originalText = null;
public bool IsEditing
{
@ -41,6 +41,9 @@ namespace Mesen.GUI.Controls
protected override void OnBeforeLabelEdit(LabelEditEventArgs e)
{
if(_originalText == null) {
_originalText = this.Items[e.Item].Text;
}
_editItemIndex = e.Item;
base.OnBeforeLabelEdit(e);
}
@ -48,6 +51,7 @@ namespace Mesen.GUI.Controls
protected override void OnAfterLabelEdit(LabelEditEventArgs e)
{
base.OnAfterLabelEdit(e);
_originalText = null;
_editItemIndex = -1;
}

View File

@ -59,6 +59,7 @@
this.lstWatch.TabIndex = 6;
this.lstWatch.UseCompatibleStateImageBehavior = false;
this.lstWatch.View = System.Windows.Forms.View.Details;
this.lstWatch.BeforeLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.lstWatch_BeforeLabelEdit);
this.lstWatch.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.lstWatch_AfterLabelEdit);
this.lstWatch.SelectedIndexChanged += new System.EventHandler(this.lstWatch_SelectedIndexChanged);
this.lstWatch.Click += new System.EventHandler(this.lstWatch_Click);
@ -89,9 +90,10 @@
// mnuRemoveWatch
//
this.mnuRemoveWatch.Name = "mnuRemoveWatch";
this.mnuRemoveWatch.ShortcutKeys = System.Windows.Forms.Keys.Delete;
this.mnuRemoveWatch.ShortcutKeyDisplayString = "Del";
this.mnuRemoveWatch.Size = new System.Drawing.Size(183, 22);
this.mnuRemoveWatch.Text = "Remove";
this.mnuRemoveWatch.Click += new System.EventHandler(this.mnuRemoveWatch_Click);
//
// mnuHexDisplay
//

View File

@ -106,11 +106,15 @@ namespace Mesen.GUI.Debugger
public void AddWatch(UInt32 address)
{
ListViewItem item = lstWatch.Items.Insert(lstWatch.Items.Count - 1, "$" + address.ToString("x"));
ListViewItem item = lstWatch.Items.Insert(lstWatch.Items.Count - 1, "[$" + address.ToString("X") + "]");
item.Tag = address;
UpdateWatch();
}
private void lstWatch_BeforeLabelEdit(object sender, LabelEditEventArgs e)
{
}
private void lstWatch_AfterLabelEdit(object sender, LabelEditEventArgs e)
{
this.BeginInvoke((MethodInvoker)(() => { this.UpdateWatch(e.Item); }));
@ -139,5 +143,19 @@ namespace Mesen.GUI.Debugger
lstWatch.SelectedItems[0].BeginEdit();
}
}
private void mnuRemoveWatch_Click(object sender, EventArgs e)
{
if(lstWatch.SelectedItems.Count >= 1) {
var itemsToRemove = new List<ListViewItem>();
foreach(ListViewItem item in lstWatch.SelectedItems) {
itemsToRemove.Add(item);
}
foreach(ListViewItem item in itemsToRemove) {
lstWatch.Items.Remove(item);
}
UpdateWatch();
}
}
}
}