2016-11-21 22:34:47 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Debugger.Controls
|
|
|
|
|
{
|
|
|
|
|
public partial class ctrlLabelList : UserControl
|
|
|
|
|
{
|
|
|
|
|
public event EventHandler OnLabelSelected;
|
|
|
|
|
public ctrlLabelList()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateLabelList()
|
|
|
|
|
{
|
|
|
|
|
Int32[] entryPoints = InteropEmu.DebugGetFunctionEntryPoints();
|
|
|
|
|
|
|
|
|
|
lstLabels.BeginUpdate();
|
|
|
|
|
lstLabels.Items.Clear();
|
2016-11-22 22:38:14 -05:00
|
|
|
|
foreach(KeyValuePair<string, CodeLabel> kvp in LabelManager.GetLabels()) {
|
2016-11-21 22:34:47 -05:00
|
|
|
|
if(kvp.Value.Label.Length > 0) {
|
|
|
|
|
ListViewItem item = lstLabels.Items.Add(kvp.Value.Label);
|
|
|
|
|
|
2016-11-22 22:38:14 -05:00
|
|
|
|
Int32 relativeAddress = InteropEmu.DebugGetRelativeAddress(kvp.Value.Address, kvp.Value.AddressType);
|
2016-11-21 22:34:47 -05:00
|
|
|
|
if(relativeAddress >= 0) {
|
|
|
|
|
item.SubItems.Add("$" + relativeAddress.ToString("X4"));
|
|
|
|
|
} else {
|
|
|
|
|
item.SubItems.Add("[n/a]");
|
|
|
|
|
item.ForeColor = Color.Gray;
|
|
|
|
|
item.Font = new Font(item.Font, FontStyle.Italic);
|
|
|
|
|
}
|
|
|
|
|
item.SubItems.Add("$" + kvp.Value.Address.ToString("X4"));
|
2016-11-22 22:38:14 -05:00
|
|
|
|
item.SubItems[1].Tag = kvp.Value;
|
2016-11-21 22:34:47 -05:00
|
|
|
|
|
|
|
|
|
item.Tag = relativeAddress;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
lstLabels.Sort();
|
|
|
|
|
lstLabels.EndUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lstLabels_DoubleClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(lstLabels.SelectedItems.Count > 0) {
|
|
|
|
|
Int32 relativeAddress = (Int32)lstLabels.SelectedItems[0].Tag;
|
|
|
|
|
|
|
|
|
|
if(relativeAddress >= 0) {
|
|
|
|
|
OnLabelSelected?.Invoke(relativeAddress, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuActions_Opening(object sender, CancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
mnuDelete.Enabled = lstLabels.SelectedItems.Count > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuDelete_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
foreach(ListViewItem item in lstLabels.SelectedItems) {
|
2016-11-22 22:38:14 -05:00
|
|
|
|
LabelManager.DeleteLabel(((CodeLabel)item.SubItems[1].Tag).Address, ((CodeLabel)item.SubItems[1].Tag).AddressType);
|
2016-11-21 22:34:47 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|