2015-08-02 19:27:02 -04: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;
|
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Debugger.Controls
|
|
|
|
|
{
|
|
|
|
|
public partial class ctrlBreakpoints : UserControl
|
|
|
|
|
{
|
2016-01-10 00:33:33 -05:00
|
|
|
|
public event EventHandler BreakpointNavigation;
|
2015-08-02 19:27:02 -04:00
|
|
|
|
|
|
|
|
|
public ctrlBreakpoints()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-01-10 00:33:33 -05:00
|
|
|
|
BreakpointManager.BreakpointsChanged += BreakpointManager_OnBreakpointChanged;
|
2015-08-02 19:27:02 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-10 00:33:33 -05:00
|
|
|
|
void BreakpointManager_OnBreakpointChanged(object sender, EventArgs e)
|
2015-08-02 19:27:02 -04:00
|
|
|
|
{
|
2016-01-10 00:33:33 -05:00
|
|
|
|
RefreshList();
|
2015-08-02 19:27:02 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-10 00:33:33 -05:00
|
|
|
|
protected override void OnLoad(EventArgs e)
|
2016-01-09 13:15:43 -05:00
|
|
|
|
{
|
2016-01-10 00:33:33 -05:00
|
|
|
|
base.OnLoad(e);
|
|
|
|
|
AdjustColumnWidth();
|
2016-01-09 13:15:43 -05:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-04 14:43:13 -04:00
|
|
|
|
public void RefreshList()
|
2015-08-02 19:27:02 -04:00
|
|
|
|
{
|
|
|
|
|
lstBreakpoints.ItemChecked -= new System.Windows.Forms.ItemCheckedEventHandler(lstBreakpoints_ItemChecked);
|
2016-11-14 22:33:59 -05:00
|
|
|
|
|
|
|
|
|
int topIndex = lstBreakpoints.TopItem != null ? lstBreakpoints.TopItem.Index : 0;
|
|
|
|
|
lstBreakpoints.BeginUpdate();
|
2015-08-02 19:27:02 -04:00
|
|
|
|
lstBreakpoints.Items.Clear();
|
2016-01-10 00:33:33 -05:00
|
|
|
|
foreach(Breakpoint breakpoint in BreakpointManager.Breakpoints) {
|
2015-08-02 19:27:02 -04:00
|
|
|
|
ListViewItem item = new ListViewItem();
|
|
|
|
|
item.Tag = breakpoint;
|
|
|
|
|
item.Checked = breakpoint.Enabled;
|
|
|
|
|
item.SubItems.Add(breakpoint.Type.ToString());
|
2016-12-04 12:21:20 -05:00
|
|
|
|
item.SubItems.Add(breakpoint.GetAddressString());
|
2016-01-09 13:15:43 -05:00
|
|
|
|
item.SubItems.Add(breakpoint.Condition);
|
2015-08-02 19:27:02 -04:00
|
|
|
|
lstBreakpoints.Items.Add(item);
|
|
|
|
|
}
|
2016-11-14 22:33:59 -05:00
|
|
|
|
lstBreakpoints.EndUpdate();
|
|
|
|
|
if(lstBreakpoints.Items.Count > 0) {
|
|
|
|
|
lstBreakpoints.TopItem = lstBreakpoints.Items[lstBreakpoints.Items.Count > topIndex ? topIndex : lstBreakpoints.Items.Count - 1];
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-02 19:27:02 -04:00
|
|
|
|
lstBreakpoints.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(lstBreakpoints_ItemChecked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lstBreakpoints_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(e.ColumnIndex == 2) {
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
}
|
|
|
|
|
AdjustColumnWidth();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lstBreakpoints_ColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
AdjustColumnWidth();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AdjustColumnWidth()
|
|
|
|
|
{
|
|
|
|
|
lstBreakpoints.ColumnWidthChanging -= lstBreakpoints_ColumnWidthChanging;
|
|
|
|
|
lstBreakpoints.ColumnWidthChanged -= lstBreakpoints_ColumnWidthChanged;
|
|
|
|
|
|
|
|
|
|
//Force watch values to take the full width of the list
|
2016-01-09 13:15:43 -05:00
|
|
|
|
int totalWidth = lstBreakpoints.Columns[0].Width + lstBreakpoints.Columns[1].Width + lstBreakpoints.Columns[2].Width + lstBreakpoints.Columns[3].Width;
|
2015-08-02 19:27:02 -04:00
|
|
|
|
colLastColumn.Width = lstBreakpoints.ClientSize.Width - totalWidth;
|
|
|
|
|
|
|
|
|
|
lstBreakpoints.ColumnWidthChanging += lstBreakpoints_ColumnWidthChanging;
|
|
|
|
|
lstBreakpoints.ColumnWidthChanged += lstBreakpoints_ColumnWidthChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lstBreakpoints_ItemChecked(object sender, ItemCheckedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(((Breakpoint)e.Item.Tag).Enabled != e.Item.Checked) {
|
|
|
|
|
((Breakpoint)e.Item.Tag).SetEnabled(e.Item.Checked);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lstBreakpoints_DoubleClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(lstBreakpoints.SelectedItems.Count > 0) {
|
2016-01-10 00:33:33 -05:00
|
|
|
|
BreakpointManager.EditBreakpoint(((Breakpoint)lstBreakpoints.SelectedItems[0].Tag));
|
2015-08-02 19:27:02 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuRemoveBreakpoint_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
foreach(ListViewItem item in lstBreakpoints.SelectedItems) {
|
2016-01-10 00:33:33 -05:00
|
|
|
|
BreakpointManager.RemoveBreakpoint((Breakpoint)item.Tag);
|
2015-08-02 19:27:02 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuAddBreakpoint_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Breakpoint breakpoint = new Breakpoint();
|
|
|
|
|
if(new frmBreakpoint(breakpoint).ShowDialog() == DialogResult.OK) {
|
2016-01-10 00:33:33 -05:00
|
|
|
|
BreakpointManager.AddBreakpoint(breakpoint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuGoToLocation_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(BreakpointNavigation != null) {
|
|
|
|
|
BreakpointNavigation(lstBreakpoints.SelectedItems[0].Tag, null);
|
2015-08-02 19:27:02 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void contextMenuBreakpoints_Opening(object sender, CancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
mnuRemoveBreakpoint.Enabled = (lstBreakpoints.SelectedItems.Count > 0);
|
2016-01-10 00:33:33 -05:00
|
|
|
|
mnuGoToLocation.Enabled = (lstBreakpoints.SelectedItems.Count == 1);
|
2015-08-02 19:27:02 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|