New Ram WAtch - implement column hide/show, and column positioning/width saving and loading

This commit is contained in:
adelikat 2013-09-08 15:47:41 +00:00
parent 0442eddf5a
commit 8d4a8bc869
3 changed files with 277 additions and 73 deletions

View File

@ -182,6 +182,7 @@ namespace BizHawk.MultiClient
public bool RamWatchShowPrevColumn = false;
public bool RamWatchShowDiffColumn = false;
public bool RamWatchShowDomainColumn = true;
public int RamWatchAddressWidth = -1;
public int RamWatchValueWidth = -1;
public int RamWatchPrevWidth = -1;
@ -189,6 +190,18 @@ namespace BizHawk.MultiClient
public int RamWatchDiffWidth = -1;
public int RamWatchNotesWidth = -1;
public int RamWatchDomainWidth = -1;
public Dictionary<string, int> RamWatchColumnWidths = new Dictionary<string, int>()
{
{ "AddressColumn", -1 },
{ "ValueColumn", -1 },
{ "PrevColumn", -1 },
{ "ChangesColumn", -1 },
{ "DiffColumn", -1 },
{ "DomainColumn", -1 },
{ "NotesColumn",-1 },
};
public int RamWatchAddressIndex = 0;
public int RamWatchValueIndex = 1;
public int RamWatchPrevIndex = 2;
@ -196,6 +209,7 @@ namespace BizHawk.MultiClient
public int RamWatchDiffIndex = 4;
public int RamWatchDomainIndex = 5;
public int RamWatchNotesIndex = 6;
public int RamWatchPrev_Type = 1;
// RamSearch Settings

View File

@ -89,13 +89,13 @@
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.WatchListView = new BizHawk.VirtualListView();
this.Address = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.Value = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.Prev = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.ChangeCounts = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.Diff = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.AddressColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.ValueColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.PrevColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.ChangesColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.DiffColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.DomainColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.Notes = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.NotesColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.toolStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
@ -555,36 +555,37 @@
this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.viewToolStripMenuItem.Text = "&View";
this.viewToolStripMenuItem.DropDownOpened += new System.EventHandler(this.viewToolStripMenuItem_DropDownOpened);
//
// showPreviousValueToolStripMenuItem
//
this.showPreviousValueToolStripMenuItem.Enabled = false;
this.showPreviousValueToolStripMenuItem.Name = "showPreviousValueToolStripMenuItem";
this.showPreviousValueToolStripMenuItem.Size = new System.Drawing.Size(156, 22);
this.showPreviousValueToolStripMenuItem.Text = "Previous Value";
this.showPreviousValueToolStripMenuItem.Click += new System.EventHandler(this.showPreviousValueToolStripMenuItem_Click);
//
// showChangeCountsToolStripMenuItem
//
this.showChangeCountsToolStripMenuItem.Checked = true;
this.showChangeCountsToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
this.showChangeCountsToolStripMenuItem.Enabled = false;
this.showChangeCountsToolStripMenuItem.Name = "showChangeCountsToolStripMenuItem";
this.showChangeCountsToolStripMenuItem.Size = new System.Drawing.Size(156, 22);
this.showChangeCountsToolStripMenuItem.Text = "Change Counts";
this.showChangeCountsToolStripMenuItem.Click += new System.EventHandler(this.showChangeCountsToolStripMenuItem_Click);
//
// diffToolStripMenuItem
//
this.diffToolStripMenuItem.Enabled = false;
this.diffToolStripMenuItem.Name = "diffToolStripMenuItem";
this.diffToolStripMenuItem.Size = new System.Drawing.Size(156, 22);
this.diffToolStripMenuItem.Text = "Difference";
this.diffToolStripMenuItem.Click += new System.EventHandler(this.diffToolStripMenuItem_Click);
//
// domainToolStripMenuItem
//
this.domainToolStripMenuItem.Enabled = false;
this.domainToolStripMenuItem.Name = "domainToolStripMenuItem";
this.domainToolStripMenuItem.Size = new System.Drawing.Size(156, 22);
this.domainToolStripMenuItem.Text = "Domain";
this.domainToolStripMenuItem.Click += new System.EventHandler(this.domainToolStripMenuItem_Click);
//
// optionsToolStripMenuItem
//
@ -655,13 +656,13 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.WatchListView.AutoArrange = false;
this.WatchListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.Address,
this.Value,
this.Prev,
this.ChangeCounts,
this.Diff,
this.AddressColumn,
this.ValueColumn,
this.PrevColumn,
this.ChangesColumn,
this.DiffColumn,
this.DomainColumn,
this.Notes});
this.NotesColumn});
this.WatchListView.FullRowSelect = true;
this.WatchListView.GridLines = true;
this.WatchListView.HideSelection = false;
@ -675,43 +676,50 @@
this.WatchListView.UseCompatibleStateImageBehavior = false;
this.WatchListView.View = System.Windows.Forms.View.Details;
//
// Address
// AddressColumn
//
this.Address.Text = "Address";
this.AddressColumn.Name = "AddressColumn";
this.AddressColumn.Text = "Address";
//
// Value
// ValueColumn
//
this.Value.Text = "Value";
this.Value.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.Value.Width = 59;
this.ValueColumn.Name = "ValueColumn";
this.ValueColumn.Text = "Value";
this.ValueColumn.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.ValueColumn.Width = 59;
//
// Prev
// PrevColumn
//
this.Prev.Text = "Prev";
this.Prev.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.Prev.Width = 0;
this.PrevColumn.Name = "PrevColumn";
this.PrevColumn.Text = "Prev";
this.PrevColumn.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.PrevColumn.Width = 59;
//
// ChangeCounts
// ChangesColumn
//
this.ChangeCounts.Text = "Changes";
this.ChangeCounts.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.ChangeCounts.Width = 54;
this.ChangesColumn.Name = "ChangesColumn";
this.ChangesColumn.Text = "Changes";
this.ChangesColumn.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.ChangesColumn.Width = 54;
//
// Diff
// DiffColumn
//
this.Diff.Text = "Diff";
this.Diff.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.Diff.Width = 59;
this.DiffColumn.Name = "DiffColumn";
this.DiffColumn.Text = "Diff";
this.DiffColumn.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.DiffColumn.Width = 59;
//
// DomainColumn
//
this.DomainColumn.Name = "DomainColumn";
this.DomainColumn.Text = "Domain";
this.DomainColumn.Width = 55;
//
// Notes
// NotesColumn
//
this.Notes.Text = "Notes";
this.Notes.Width = 128;
this.NotesColumn.Name = "NotesColumn";
this.NotesColumn.Text = "Notes";
this.NotesColumn.Width = 128;
//
// NewRamWatch
//
@ -740,13 +748,13 @@
#endregion
private VirtualListView WatchListView;
private System.Windows.Forms.ColumnHeader Address;
private System.Windows.Forms.ColumnHeader Value;
private System.Windows.Forms.ColumnHeader Prev;
private System.Windows.Forms.ColumnHeader ChangeCounts;
private System.Windows.Forms.ColumnHeader Diff;
private System.Windows.Forms.ColumnHeader AddressColumn;
private System.Windows.Forms.ColumnHeader ValueColumn;
private System.Windows.Forms.ColumnHeader PrevColumn;
private System.Windows.Forms.ColumnHeader ChangesColumn;
private System.Windows.Forms.ColumnHeader DiffColumn;
private System.Windows.Forms.ColumnHeader DomainColumn;
private System.Windows.Forms.ColumnHeader Notes;
private System.Windows.Forms.ColumnHeader NotesColumn;
private MenuStripEx menuStrip1;
private System.Windows.Forms.ToolStripMenuItem filesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem newListToolStripMenuItem;

View File

@ -12,6 +12,25 @@ namespace BizHawk.MultiClient
{
public partial class NewRamWatch : Form
{
private const string ADDRESS = "AddressColumn";
private const string VALUE = "ValueColumn";
private const string PREV = "PrevColumn";
private const string CHANGES = "ChangesColumn";
private const string DIFF = "DiffColumn";
private const string DOMAIN = "DomainColumn";
private const string NOTES = "NotesColumn";
private Dictionary<string, int> DefaultColumnWidths = new Dictionary<string, int>()
{
{ ADDRESS, 60 },
{ VALUE, 59 },
{ PREV, 59 },
{ CHANGES, 55 },
{ DIFF, 59 },
{ DOMAIN, 55 },
{ NOTES, 128 },
};
private int defaultWidth;
private int defaultHeight;
private WatchList Watches = new WatchList();
@ -105,13 +124,47 @@ namespace BizHawk.MultiClient
public void SaveConfigSettings()
{
Global.Config.RamWatchAddressWidth = WatchListView.Columns[Global.Config.RamWatchAddressIndex].Width;
Global.Config.RamWatchValueWidth = WatchListView.Columns[Global.Config.RamWatchValueIndex].Width;
Global.Config.RamWatchPrevWidth = WatchListView.Columns[Global.Config.RamWatchPrevIndex].Width;
Global.Config.RamWatchChangeWidth = WatchListView.Columns[Global.Config.RamWatchChangeIndex].Width;
Global.Config.RamWatchDiffWidth = WatchListView.Columns[Global.Config.RamWatchDiffIndex].Width;
Global.Config.RamWatchDomainWidth = WatchListView.Columns[Global.Config.RamWatchDomainIndex].Width;
Global.Config.RamWatchNotesWidth = WatchListView.Columns[Global.Config.RamWatchNotesIndex].Width;
if (WatchListView.Columns[ADDRESS] != null)
{
Global.Config.RamWatchAddressIndex = WatchListView.Columns[ADDRESS].DisplayIndex;
Global.Config.RamWatchColumnWidths[ADDRESS] = WatchListView.Columns[ADDRESS].Width;
}
if (WatchListView.Columns[VALUE] != null)
{
Global.Config.RamWatchValueIndex = WatchListView.Columns[VALUE].DisplayIndex;
Global.Config.RamWatchColumnWidths[VALUE] = WatchListView.Columns[VALUE].Width;
}
if (WatchListView.Columns[PREV] != null)
{
Global.Config.RamWatchPrevIndex = WatchListView.Columns[PREV].DisplayIndex;
Global.Config.RamWatchColumnWidths[PREV] = WatchListView.Columns[PREV].Width;
}
if (WatchListView.Columns[CHANGES] != null)
{
Global.Config.RamWatchChangeIndex = WatchListView.Columns[CHANGES].DisplayIndex;
Global.Config.RamWatchColumnWidths[CHANGES] = WatchListView.Columns[CHANGES].Width;
}
if (WatchListView.Columns[DIFF] != null)
{
Global.Config.RamWatchDiffIndex = WatchListView.Columns[DIFF].DisplayIndex;
Global.Config.RamWatchColumnWidths[DIFF] = WatchListView.Columns[DIFF].Width;
}
if (WatchListView.Columns[DOMAIN] != null)
{
Global.Config.RamWatchDomainIndex = WatchListView.Columns[DOMAIN].DisplayIndex;
Global.Config.RamWatchColumnWidths[DOMAIN] = WatchListView.Columns[DOMAIN].Width;
}
if (WatchListView.Columns[NOTES] != null)
{
Global.Config.RamWatchNotesIndex = WatchListView.Columns[NOTES].Index;
Global.Config.RamWatchColumnWidths[NOTES] = WatchListView.Columns[NOTES].Width;
}
Global.Config.RamWatchWndx = Location.X;
Global.Config.RamWatchWndy = Location.Y;
@ -126,6 +179,17 @@ namespace BizHawk.MultiClient
base.OnClosing(e);
}
private int GetColumnWidth(string columnName)
{
var width = Global.Config.RamWatchColumnWidths[columnName];
if (width == -1)
{
width = DefaultColumnWidths[columnName];
}
return width;
}
private void WatchListView_QueryItemBkColor(int index, int column, ref Color color)
{
if (index >= Watches.ItemCount)
@ -154,37 +218,38 @@ namespace BizHawk.MultiClient
{
return;
}
string columnName = WatchListView.Columns[column].Name;
switch (column)
switch (columnName)
{
case 0: // address
case ADDRESS:
text = Watches[index].AddressString;
break;
case 1: // value
case VALUE:
text = Watches[index].ValueString;
break;
case 2: // prev
case PREV:
if (Watches[index] is iWatchEntryDetails)
{
text = (Watches[index] as iWatchEntryDetails).PreviousStr;
}
break;
case 3: // changes
case CHANGES:
if (Watches[index] is iWatchEntryDetails)
{
text = (Watches[index] as iWatchEntryDetails).ChangeCount.ToString();
}
break;
case 4: // diff
case DIFF:
if (Watches[index] is iWatchEntryDetails)
{
text = (Watches[index] as iWatchEntryDetails).Diff;
}
break;
case 5: // domain
case DOMAIN:
text = Watches[index].Domain.Name;
break;
case 6: // notes
case NOTES:
if (Watches[index] is iWatchEntryDetails)
{
text = (Watches[index] as iWatchEntryDetails).Notes;
@ -488,10 +553,68 @@ namespace BizHawk.MultiClient
}
}
#region Winform Events
private void NewRamWatch_Load(object sender, EventArgs e)
private void AddRemoveColumn(string columnName, bool enabled)
{
if (enabled)
{
if (WatchListView.Columns[columnName] == null)
{
ColumnHeader column = new ColumnHeader()
{
Name = columnName,
Text = columnName.Replace("Column", ""),
Width = GetColumnWidth(columnName),
};
WatchListView.Columns.Add(column); //TODO: insert in right place
}
}
else
{
WatchListView.Columns.RemoveByKey(columnName);
}
DisplayWatches();
}
private void ColumnPositionSet() //TODO: fix indexing, thrown off by columns not existing
{
List<ColumnHeader> columnHeaders = new List<ColumnHeader>();
foreach(ColumnHeader column in WatchListView.Columns)
{
columnHeaders.Add(column);
}
WatchListView.Columns.Clear();
List<KeyValuePair<int, string>> columnSettings = new List<KeyValuePair<int, string>>
{
new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, ADDRESS),
new KeyValuePair<int, string>(Global.Config.RamWatchValueIndex, VALUE),
new KeyValuePair<int, string>(Global.Config.RamWatchPrevIndex, PREV),
new KeyValuePair<int, string>(Global.Config.RamWatchChangeIndex, CHANGES),
new KeyValuePair<int, string>(Global.Config.RamWatchDiffIndex, DIFF),
new KeyValuePair<int, string>(Global.Config.RamWatchDomainIndex, DOMAIN),
new KeyValuePair<int, string>(Global.Config.RamWatchNotesIndex, NOTES)
};
columnSettings = columnSettings.OrderBy(s => s.Key).ToList();
foreach (KeyValuePair<int, string> t in columnSettings)
{
foreach (ColumnHeader t1 in columnHeaders)
{
if (t.Value == t1.Name)
{
WatchListView.Columns.Add(t1);
}
}
}
}
private void LoadConfigSettings()
{
//Size and Positioning
defaultWidth = Size.Width; //Save these first so that the user can restore to its original size
defaultHeight = Size.Height;
@ -504,6 +627,24 @@ namespace BizHawk.MultiClient
{
Size = new Size(Global.Config.RamWatchWidth, Global.Config.RamWatchHeight);
}
//Columns
ColumnPositionSet();
AddRemoveColumn(CHANGES, Global.Config.RamWatchShowChangeColumn);
AddRemoveColumn(DIFF, Global.Config.RamWatchShowDiffColumn);
AddRemoveColumn(DOMAIN, Global.Config.RamWatchShowDomainColumn);
AddRemoveColumn(PREV, Global.Config.RamWatchShowPrevColumn);
WatchListView.Columns[ADDRESS].Width = GetColumnWidth(ADDRESS);
WatchListView.Columns[VALUE].Width = GetColumnWidth(VALUE);
WatchListView.Columns[NOTES].Width = GetColumnWidth(NOTES);
}
#region Winform Events
private void NewRamWatch_Load(object sender, EventArgs e)
{
LoadConfigSettings();
}
/*************File***********************/
@ -677,6 +818,39 @@ namespace BizHawk.MultiClient
SelectAll();
}
/*************View***********************/
private void viewToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
showPreviousValueToolStripMenuItem.Checked = Global.Config.RamWatchShowPrevColumn;
showChangeCountsToolStripMenuItem.Checked = Global.Config.RamWatchShowChangeColumn;
diffToolStripMenuItem.Checked = Global.Config.RamWatchShowDiffColumn;
domainToolStripMenuItem.Checked = Global.Config.RamWatchShowDomainColumn;
}
private void showPreviousValueToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchShowPrevColumn ^= true;
AddRemoveColumn(PREV, Global.Config.RamWatchShowPrevColumn);
}
private void showChangeCountsToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchShowChangeColumn ^= true;
AddRemoveColumn(CHANGES, Global.Config.RamWatchShowChangeColumn);
}
private void diffToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchShowDiffColumn ^= true;
AddRemoveColumn(DIFF, Global.Config.RamWatchShowDiffColumn);
}
private void domainToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.RamWatchShowDomainColumn ^= true;
AddRemoveColumn(DOMAIN, Global.Config.RamWatchShowDomainColumn);
}
/*************Options***********************/
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
@ -712,21 +886,29 @@ namespace BizHawk.MultiClient
Global.Config.RamWatchPrevIndex = 2;
Global.Config.RamWatchChangeIndex = 3;
Global.Config.RamWatchDiffIndex = 4;
Global.Config.RamWatchNotesIndex = 5;
Global.Config.RamWatchDomainIndex = 5;
Global.Config.RamWatchNotesIndex = 6;
ColumnPositionSet();
showPreviousValueToolStripMenuItem.Checked = false;
Global.Config.RamWatchShowPrevColumn = false;
showChangeCountsToolStripMenuItem.Checked = true;
Global.Config.RamWatchShowChangeColumn = true;
Global.Config.RamWatchShowDiffColumn = false;
Global.Config.RamWatchShowDomainColumn = true;
WatchListView.Columns[0].Width = 60;
WatchListView.Columns[1].Width = 59;
WatchListView.Columns[2].Width = 0;
WatchListView.Columns[3].Width = 55;
WatchListView.Columns[4].Width = 0;
WatchListView.Columns[5].Width = 55;
WatchListView.Columns[6].Width = 128;
Global.Config.RamWatchShowPrevColumn = false;
Global.Config.RamWatchShowDiffColumn = false;
AddRemoveColumn(CHANGES, Global.Config.RamWatchShowChangeColumn);
AddRemoveColumn(DOMAIN, Global.Config.RamWatchShowDomainColumn);
AddRemoveColumn(PREV, Global.Config.RamWatchShowPrevColumn);
AddRemoveColumn(DIFF, Global.Config.RamWatchShowDiffColumn);
WatchListView.Columns[ADDRESS].Width = DefaultColumnWidths[ADDRESS];
WatchListView.Columns[VALUE].Width = DefaultColumnWidths[VALUE];
//WatchListView.Columns[PREV].Width = DefaultColumnWidths[PREV];
WatchListView.Columns[CHANGES].Width = DefaultColumnWidths[CHANGES];
//WatchListView.Columns[DIFF].Width = DefaultColumnWidths[DIFF];
WatchListView.Columns[DOMAIN].Width = DefaultColumnWidths[DOMAIN];
WatchListView.Columns[NOTES].Width = DefaultColumnWidths[NOTES];
Global.Config.DisplayRamWatch = false;
Global.Config.RamWatchSaveWindowPosition = true;
}