Lua - Lua Function List - column sorting (including descending)
This commit is contained in:
parent
4aaeabb568
commit
45227b1b11
|
@ -32,8 +32,8 @@
|
|||
this.OK = new System.Windows.Forms.Button();
|
||||
this.directoryEntry1 = new System.DirectoryServices.DirectoryEntry();
|
||||
this.FunctionView = new System.Windows.Forms.ListView();
|
||||
this.LibraryHead = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.LibraryReturn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.LibraryHead = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.LibraryName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.LibraryParameters = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.SuspendLayout();
|
||||
|
@ -41,7 +41,7 @@
|
|||
// OK
|
||||
//
|
||||
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.OK.Location = new System.Drawing.Point(423, 287);
|
||||
this.OK.Location = new System.Drawing.Point(423, 284);
|
||||
this.OK.Name = "OK";
|
||||
this.OK.Size = new System.Drawing.Size(75, 23);
|
||||
this.OK.TabIndex = 0;
|
||||
|
@ -62,10 +62,15 @@
|
|||
this.FunctionView.GridLines = true;
|
||||
this.FunctionView.Location = new System.Drawing.Point(12, 12);
|
||||
this.FunctionView.Name = "FunctionView";
|
||||
this.FunctionView.Size = new System.Drawing.Size(486, 253);
|
||||
this.FunctionView.Size = new System.Drawing.Size(486, 266);
|
||||
this.FunctionView.TabIndex = 1;
|
||||
this.FunctionView.UseCompatibleStateImageBehavior = false;
|
||||
this.FunctionView.View = System.Windows.Forms.View.Details;
|
||||
this.FunctionView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.FunctionView_ColumnClick);
|
||||
//
|
||||
// LibraryReturn
|
||||
//
|
||||
this.LibraryReturn.Text = "Return";
|
||||
//
|
||||
// LibraryHead
|
||||
//
|
||||
|
@ -73,10 +78,6 @@
|
|||
this.LibraryHead.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
this.LibraryHead.Width = 75;
|
||||
//
|
||||
// LibraryReturn
|
||||
//
|
||||
this.LibraryReturn.Text = "Return";
|
||||
//
|
||||
// LibraryName
|
||||
//
|
||||
this.LibraryName.Text = "Name";
|
||||
|
@ -92,7 +93,7 @@
|
|||
this.AcceptButton = this.OK;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(510, 322);
|
||||
this.ClientSize = new System.Drawing.Size(510, 319);
|
||||
this.Controls.Add(this.FunctionView);
|
||||
this.Controls.Add(this.OK);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
|
|
|
@ -12,12 +12,18 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
public partial class LuaFunctionList : Form
|
||||
{
|
||||
Sorting ColumnSort = new Sorting();
|
||||
public LuaFunctionList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void LuaFunctionList_Load(object sender, EventArgs e)
|
||||
{
|
||||
PopulateListView();
|
||||
}
|
||||
|
||||
private void PopulateListView()
|
||||
{
|
||||
FunctionView.Items.Clear();
|
||||
foreach (LuaDocumentation.LibraryFunction l in Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList)
|
||||
|
@ -31,9 +37,86 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
private void OrderColumn(int column)
|
||||
{
|
||||
ColumnSort.Column = column;
|
||||
if (ColumnSort.Descending)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case 0: //Return
|
||||
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderByDescending(x => x.ReturnType).ToList();
|
||||
break;
|
||||
case 1: //Library
|
||||
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderByDescending(x => x.library).ToList();
|
||||
break;
|
||||
case 2: //Name
|
||||
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderByDescending(x => x.name).ToList();
|
||||
break;
|
||||
case 3: //Parameters
|
||||
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderByDescending(x => x.ParameterList).ToList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case 0: //Return
|
||||
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderBy(x => x.ReturnType).ToList();
|
||||
break;
|
||||
case 1: //Library
|
||||
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderBy(x => x.library).ToList();
|
||||
break;
|
||||
case 2: //Name
|
||||
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderBy(x => x.name).ToList();
|
||||
break;
|
||||
case 3: //Parameters
|
||||
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderBy(x => x.ParameterList).ToList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
PopulateListView();
|
||||
}
|
||||
|
||||
private void OK_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void FunctionView_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||
{
|
||||
OrderColumn(e.Column);
|
||||
}
|
||||
|
||||
public class Sorting
|
||||
{
|
||||
private bool desc = false;
|
||||
private int column = 1;
|
||||
|
||||
public int Column
|
||||
{
|
||||
get
|
||||
{
|
||||
return column;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (column == value)
|
||||
{
|
||||
desc ^= true;
|
||||
}
|
||||
column = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Descending
|
||||
{
|
||||
get
|
||||
{
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue