New Ram Search - implement column ordering and other listview events (copy, double click to add to ram watch, select all, etc)
This commit is contained in:
parent
0deb8761bd
commit
cc358ec9ea
|
@ -201,8 +201,12 @@
|
|||
this.WatchListView.UseCompatibleStateImageBehavior = false;
|
||||
this.WatchListView.View = System.Windows.Forms.View.Details;
|
||||
this.WatchListView.VirtualMode = true;
|
||||
this.WatchListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.WatchListView_ColumnClick);
|
||||
this.WatchListView.ColumnReordered += new System.Windows.Forms.ColumnReorderedEventHandler(this.WatchListView_ColumnReordered);
|
||||
this.WatchListView.SelectedIndexChanged += new System.EventHandler(this.WatchListView_SelectedIndexChanged);
|
||||
this.WatchListView.Enter += new System.EventHandler(this.WatchListView_Enter);
|
||||
this.WatchListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.WatchListView_KeyDown);
|
||||
this.WatchListView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.WatchListView_MouseDoubleClick);
|
||||
//
|
||||
// AddressColumn
|
||||
//
|
||||
|
|
|
@ -571,6 +571,25 @@ namespace BizHawk.MultiClient
|
|||
RedoToolBarItem.Enabled = Searches.CanRedo;
|
||||
}
|
||||
|
||||
private string GetColumnValue(string name, int index)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
default:
|
||||
return String.Empty;
|
||||
case ADDRESS:
|
||||
return Searches[index].AddressString;
|
||||
case VALUE:
|
||||
return Searches[index].ValueString;
|
||||
case PREV:
|
||||
return Searches[index].PreviousStr;
|
||||
case CHANGES:
|
||||
return (Searches[index] as IWatchDetails).ChangeCount.ToString();
|
||||
case DIFF:
|
||||
return (Searches[index] as IWatchDetails).Diff;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Winform Events
|
||||
|
@ -1180,6 +1199,34 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
RemoveAddresses();
|
||||
}
|
||||
else if (e.KeyCode == Keys.A && e.Control && !e.Alt && !e.Shift) //Select All
|
||||
{
|
||||
for (int x = 0; x < Searches.Count; x++)
|
||||
{
|
||||
WatchListView.SelectItem(x, true);
|
||||
}
|
||||
}
|
||||
else if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift) //Copy
|
||||
{
|
||||
if (SelectedIndices.Count > 0)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (int index in SelectedIndices)
|
||||
{
|
||||
foreach (ColumnHeader column in WatchListView.Columns)
|
||||
{
|
||||
sb.Append(GetColumnValue(column.Name, index)).Append('\t');
|
||||
}
|
||||
sb.Remove(sb.Length - 1, 1);
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
Clipboard.SetDataObject(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WatchListView_SelectedIndexChanged(object sender, EventArgs e)
|
||||
|
@ -1191,10 +1238,45 @@ namespace BizHawk.MultiClient
|
|||
SelectedIndices.Any();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private void WatchListView_ColumnReordered(object sender, ColumnReorderedEventArgs e)
|
||||
{
|
||||
Global.Config.RamSearchColumnIndexes[ADDRESS] = WatchListView.Columns[ADDRESS].DisplayIndex;
|
||||
Global.Config.RamSearchColumnIndexes[VALUE] = WatchListView.Columns[VALUE].DisplayIndex;
|
||||
Global.Config.RamSearchColumnIndexes[PREV] = WatchListView.Columns[ADDRESS].DisplayIndex;
|
||||
Global.Config.RamSearchColumnIndexes[CHANGES] = WatchListView.Columns[CHANGES].DisplayIndex;
|
||||
Global.Config.RamSearchColumnIndexes[DIFF] = WatchListView.Columns[DIFF].DisplayIndex;
|
||||
}
|
||||
|
||||
private void WatchListView_Enter(object sender, EventArgs e)
|
||||
{
|
||||
WatchListView.Refresh();
|
||||
}
|
||||
|
||||
private void WatchListView_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||
{
|
||||
var column = WatchListView.Columns[e.Column];
|
||||
if (column.Name != _sortedColumn)
|
||||
{
|
||||
_sortReverse = false;
|
||||
}
|
||||
|
||||
Searches.Sort(column.Name, _sortReverse);
|
||||
|
||||
_sortedColumn = column.Name;
|
||||
_sortReverse ^= true;
|
||||
WatchListView.Refresh();
|
||||
}
|
||||
|
||||
private void WatchListView_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (SelectedIndices.Count > 0)
|
||||
{
|
||||
AddToRamWatch();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -302,6 +302,72 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public void Sort(string column, bool reverse)
|
||||
{
|
||||
switch(column)
|
||||
{
|
||||
case NewRamSearch.ADDRESS:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList.OrderByDescending(x => x.Address).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList.OrderBy(x => x.Address).ToList();
|
||||
}
|
||||
break;
|
||||
case NewRamSearch.VALUE:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList.OrderByDescending(x => GetValue(x.Address)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList.OrderBy(x => GetValue(x.Address)).ToList();
|
||||
}
|
||||
break;
|
||||
case NewRamSearch.PREV:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList.OrderByDescending(x => x.Previous).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList.OrderBy(x => x.Previous).ToList();
|
||||
}
|
||||
break;
|
||||
case NewRamSearch.CHANGES:
|
||||
if (_settings.Mode == Settings.SearchMode.Detailed)
|
||||
{
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.Cast<IMiniWatchDetails>()
|
||||
.OrderByDescending(x => x.ChangeCount)
|
||||
.Cast<IMiniWatch>().ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.Cast<IMiniWatchDetails>()
|
||||
.OrderBy(x => x.ChangeCount)
|
||||
.Cast<IMiniWatch>().ToList();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NewRamSearch.DIFF:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList.OrderByDescending(x => (GetValue(x.Address) - x.Previous)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList.OrderBy(x => (GetValue(x.Address) - x.Previous)).ToList();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Undo API
|
||||
|
|
Loading…
Reference in New Issue