Added reverse sorting for PlayMovie dialog for when clicking a column a second time.
This commit is contained in:
parent
115517c795
commit
d76fd77cfc
|
@ -20,6 +20,8 @@ namespace BizHawk.MultiClient
|
||||||
//AddMovieToList should check for duplicates and not add them
|
//AddMovieToList should check for duplicates and not add them
|
||||||
|
|
||||||
List<Movie> MovieList = new List<Movie>();
|
List<Movie> MovieList = new List<Movie>();
|
||||||
|
bool sortReverse;
|
||||||
|
string sortedCol;
|
||||||
|
|
||||||
public PlayMovie()
|
public PlayMovie()
|
||||||
{
|
{
|
||||||
|
@ -27,6 +29,8 @@ namespace BizHawk.MultiClient
|
||||||
MovieView.QueryItemText += new QueryItemTextHandler(MovieView_QueryItemText);
|
MovieView.QueryItemText += new QueryItemTextHandler(MovieView_QueryItemText);
|
||||||
MovieView.QueryItemBkColor += new QueryItemBkColorHandler(MovieView_QueryItemBkColor);
|
MovieView.QueryItemBkColor += new QueryItemBkColorHandler(MovieView_QueryItemBkColor);
|
||||||
MovieView.VirtualMode = true;
|
MovieView.VirtualMode = true;
|
||||||
|
sortReverse = false;
|
||||||
|
sortedCol = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovieView_QueryItemText(int index, int column, out string text)
|
void MovieView_QueryItemText(int index, int column, out string text)
|
||||||
|
@ -97,6 +101,8 @@ namespace BizHawk.MultiClient
|
||||||
UpdateList();
|
UpdateList();
|
||||||
MovieView.SelectedIndices.Clear();
|
MovieView.SelectedIndices.Clear();
|
||||||
MovieView.setSelection(MovieList.Count - 1);
|
MovieView.setSelection(MovieList.Count - 1);
|
||||||
|
sortReverse = false;
|
||||||
|
sortedCol = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,19 +200,25 @@ namespace BizHawk.MultiClient
|
||||||
private void OrderColumn(int columnToOrder)
|
private void OrderColumn(int columnToOrder)
|
||||||
{
|
{
|
||||||
string columnName = MovieView.Columns[columnToOrder].Text;
|
string columnName = MovieView.Columns[columnToOrder].Text;
|
||||||
|
if (sortedCol.CompareTo(columnName) != 0)
|
||||||
|
sortReverse = false;
|
||||||
InsertionSort(MovieList, columnName);
|
InsertionSort(MovieList, columnName);
|
||||||
|
sortedCol = columnName;
|
||||||
|
sortReverse = !(sortReverse);
|
||||||
MovieView.Refresh();
|
MovieView.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InsertionSort(List<Movie> smallList, string parameter)
|
private void InsertionSort(List<Movie> smallList, string parameter)
|
||||||
{
|
{
|
||||||
|
int sort = 1;
|
||||||
|
if (sortReverse)
|
||||||
|
sort = -1;
|
||||||
for (int i = 0; i < smallList.Count; i++)
|
for (int i = 0; i < smallList.Count; i++)
|
||||||
{
|
{
|
||||||
int smallest = i;
|
int smallest = i;
|
||||||
for (int k = i + 1; k < smallList.Count; k++)
|
for (int k = i + 1; k < smallList.Count; k++)
|
||||||
{
|
{
|
||||||
if (smallList[smallest].CompareTo(smallList[k], parameter) == 1)
|
if (smallList[smallest].CompareTo(smallList[k], parameter) == sort)
|
||||||
smallest = k;
|
smallest = k;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue