New Cheat List - column ordering

This commit is contained in:
adelikat 2013-10-05 21:37:01 +00:00
parent 6bbed2116f
commit b59ac97d5f
3 changed files with 187 additions and 4 deletions

View File

@ -262,6 +262,171 @@ namespace BizHawk.MultiClient
get { return _currentFileName; }
}
public void Sort(string column, bool reverse)
{
switch (column)
{
case NewCheatForm.NAME:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Name)
.ThenBy(x => x.Address ?? 0)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Name)
.ThenBy(x => x.Address ?? 0)
.ToList();
}
break;
case NewCheatForm.ADDRESS:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Address ?? 0)
.ThenBy(x => x.Name)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Address ?? 0)
.ThenBy(x => x.Name)
.ToList();
}
break;
case NewCheatForm.VALUE:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Value ?? 0)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Value ?? 0)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
case NewCheatForm.COMPARE:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Compare ?? 0)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Compare ?? 0)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
case NewCheatForm.ON:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Enabled)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Enabled)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
case NewCheatForm.DOMAIN:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Domain)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Domain)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
case NewCheatForm.SIZE:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => ((int)x.Size))
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => ((int)x.Size))
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
case NewCheatForm.ENDIAN:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.BigEndian)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.BigEndian)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
case NewCheatForm.TYPE:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Type)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Type)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
}
}
#region privates
private string GenerateDefaultFilename()

View File

@ -110,8 +110,9 @@
// CheatListView
//
this.CheatListView.AllowColumnReorder = true;
this.CheatListView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.CheatListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.CheatListView.AutoArrange = false;
this.CheatListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.CheatName,
@ -133,6 +134,7 @@
this.CheatListView.TabIndex = 1;
this.CheatListView.UseCompatibleStateImageBehavior = false;
this.CheatListView.View = System.Windows.Forms.View.Details;
this.CheatListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.CheatListView_ColumnClick);
this.CheatListView.ColumnReordered += new System.Windows.Forms.ColumnReorderedEventHandler(this.CheatListView_ColumnReordered);
this.CheatListView.SelectedIndexChanged += new System.EventHandler(this.CheatListView_SelectedIndexChanged);
this.CheatListView.Click += new System.EventHandler(this.CheatListView_Click);
@ -715,7 +717,8 @@
//
// CheatGroupBox
//
this.CheatGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.CheatGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.CheatGroupBox.Controls.Add(this.CheatEditor);
this.CheatGroupBox.Location = new System.Drawing.Point(432, 66);
this.CheatGroupBox.Name = "CheatGroupBox";

View File

@ -801,7 +801,7 @@ namespace BizHawk.MultiClient
#endregion
#region ListView Events
#region ListView and Dialog Events
private void CheatListView_Click(object sender, EventArgs e)
{
@ -844,6 +844,21 @@ namespace BizHawk.MultiClient
DoSelectedIndexChange();
}
private void CheatListView_ColumnClick(object sender, ColumnClickEventArgs e)
{
var column = CheatListView.Columns[e.Column];
if (column.Name != _sortedColumn)
{
_sortReverse = false;
}
Global.CheatList2.Sort(column.Name, _sortReverse);
_sortedColumn = column.Name;
_sortReverse ^= true;
UpdateListView();
}
private void NewCheatForm_DragDrop(object sender, DragEventArgs e)
{
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);