New Ram Watch - column ordering
This commit is contained in:
parent
85b25ec371
commit
450fc79086
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
|
@ -12,14 +13,14 @@ 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";
|
||||
|
||||
public const string ADDRESS = "AddressColumn";
|
||||
public const string VALUE = "ValueColumn";
|
||||
public const string PREV = "PrevColumn";
|
||||
public const string CHANGES = "ChangesColumn";
|
||||
public const string DIFF = "DiffColumn";
|
||||
public const string DOMAIN = "DomainColumn";
|
||||
public const string NOTES = "NotesColumn";
|
||||
|
||||
private Dictionary<string, int> DefaultColumnWidths = new Dictionary<string, int>()
|
||||
{
|
||||
{ ADDRESS, 60 },
|
||||
|
@ -35,8 +36,8 @@ namespace BizHawk.MultiClient
|
|||
private int defaultHeight;
|
||||
private WatchList Watches = new WatchList();
|
||||
private string systemID = "NULL";
|
||||
private string sortedCol = "";
|
||||
private bool sortReverse = false;
|
||||
private string _sortedColumn = "";
|
||||
private bool _sortReverse = false;
|
||||
|
||||
public NewRamWatch()
|
||||
{
|
||||
|
@ -45,8 +46,8 @@ namespace BizHawk.MultiClient
|
|||
WatchListView.QueryItemBkColor += WatchListView_QueryItemBkColor;
|
||||
WatchListView.VirtualMode = true;
|
||||
Closing += (o, e) => SaveConfigSettings();
|
||||
sortedCol = "";
|
||||
sortReverse = false;
|
||||
_sortedColumn = "";
|
||||
_sortReverse = false;
|
||||
}
|
||||
|
||||
public void UpdateValues()
|
||||
|
@ -292,8 +293,8 @@ namespace BizHawk.MultiClient
|
|||
DisplayWatches();
|
||||
UpdateWatchCount();
|
||||
MessageLabel.Text = "";
|
||||
sortReverse = false;
|
||||
sortedCol = "";
|
||||
_sortReverse = false;
|
||||
_sortedColumn = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,21 +427,18 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void InsertSeparator()
|
||||
{
|
||||
Changes();
|
||||
|
||||
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
|
||||
var indexes = WatchListView.SelectedIndices;
|
||||
if (indexes.Count > 0)
|
||||
{
|
||||
if (indexes[0] > 0)
|
||||
{
|
||||
Watches.Insert(indexes[0], SeparatorWatch.Instance);
|
||||
}
|
||||
Watches.Insert(indexes[0], SeparatorWatch.Instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
Watches.Add(SeparatorWatch.Instance);
|
||||
}
|
||||
DisplayWatches();
|
||||
Changes();
|
||||
UpdateWatchCount();
|
||||
}
|
||||
|
||||
private Point GetPromptPoint()
|
||||
|
@ -725,9 +723,19 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
private void OrderColumn(int columnToOrder)
|
||||
private void OrderColumn(int index)
|
||||
{
|
||||
//TODO
|
||||
var column = WatchListView.Columns[index];
|
||||
if (column.Name != _sortedColumn)
|
||||
{
|
||||
_sortReverse = false;
|
||||
}
|
||||
|
||||
Watches.OrderWatches(column.Name, _sortReverse);
|
||||
|
||||
_sortedColumn = column.Name;
|
||||
_sortReverse ^= true;
|
||||
WatchListView.Refresh();
|
||||
}
|
||||
|
||||
#region Winform Events
|
||||
|
|
|
@ -683,7 +683,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public class WatchList : IEnumerable
|
||||
public class WatchList : IEnumerable<Watch>
|
||||
{
|
||||
private string _currentFilename = "";
|
||||
|
||||
|
@ -737,6 +737,159 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
public void OrderWatches(string column, bool reverse)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case NewRamWatch.ADDRESS:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderByDescending(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Domain.Name)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ThenBy(x => x.BigEndian)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Domain.Name)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ThenBy(x => x.BigEndian)
|
||||
.ToList();
|
||||
}
|
||||
break;
|
||||
case NewRamWatch.VALUE:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderByDescending(x => x.Value ?? 0)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ThenBy(x => x.BigEndian)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderBy(x => x.Value ?? 0)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ThenBy(x => x.BigEndian)
|
||||
.ToList();
|
||||
}
|
||||
break;
|
||||
case NewRamWatch.PREV: //Note: these only work if all entries are detailed objects!
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderByDescending(x => (x as IWatchDetails).PreviousStr)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderBy(x => (x as IWatchDetails).PreviousStr)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
}
|
||||
break;
|
||||
case NewRamWatch.DIFF:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderByDescending(x => (x as IWatchDetails).Diff)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderBy(x => (x as IWatchDetails).Diff)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
}
|
||||
break;
|
||||
case NewRamWatch.CHANGES:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderByDescending(x => (x as IWatchDetails).ChangeCount)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderBy(x => (x as IWatchDetails).ChangeCount)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
}
|
||||
break;
|
||||
case NewRamWatch.DOMAIN:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderByDescending(x => x.Domain)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ThenBy(x => x.BigEndian)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderBy(x => x.Domain)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ThenBy(x => x.BigEndian)
|
||||
.ToList();
|
||||
}
|
||||
break;
|
||||
case NewRamWatch.NOTES:
|
||||
if (reverse)
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderByDescending(x => (x as IWatchDetails).Notes)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_watchList = _watchList
|
||||
.OrderBy(x => (x as IWatchDetails).Notes)
|
||||
.ThenBy(x => x.Address ?? 0)
|
||||
.ThenBy(x => x.Size)
|
||||
.ThenBy(x => x.Type)
|
||||
.ToList();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public string AddressFormatStr
|
||||
{
|
||||
get
|
||||
|
|
Loading…
Reference in New Issue