Lua Function List dialog - add a filter box

This commit is contained in:
adelikat 2014-05-24 13:19:24 +00:00
parent 80707ebc53
commit 8dc56b312e
2 changed files with 114 additions and 25 deletions

View File

@ -31,7 +31,9 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LuaFunctionsForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LuaFunctionsForm));
this.OK = new System.Windows.Forms.Button(); this.OK = new System.Windows.Forms.Button();
this.directoryEntry1 = new System.DirectoryServices.DirectoryEntry(); this.directoryEntry1 = new System.DirectoryServices.DirectoryEntry();
this.FunctionView = new System.Windows.Forms.ListView(); this.FilterBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.FunctionView = new BizHawk.Client.EmuHawk.VirtualListView();
this.LibraryReturn = ((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.LibraryHead = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.LibraryName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.LibraryName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
@ -45,16 +47,36 @@
this.OK.Location = new System.Drawing.Point(647, 309); this.OK.Location = new System.Drawing.Point(647, 309);
this.OK.Name = "OK"; this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23); this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 0; this.OK.TabIndex = 10;
this.OK.Text = "&Ok"; this.OK.Text = "&Ok";
this.OK.UseVisualStyleBackColor = true; this.OK.UseVisualStyleBackColor = true;
this.OK.Click += new System.EventHandler(this.Ok_Click); this.OK.Click += new System.EventHandler(this.Ok_Click);
// //
// FilterBox
//
this.FilterBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.FilterBox.Location = new System.Drawing.Point(12, 311);
this.FilterBox.Name = "FilterBox";
this.FilterBox.Size = new System.Drawing.Size(159, 20);
this.FilterBox.TabIndex = 1;
this.FilterBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.FilterBox_KeyUp);
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(173, 314);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(29, 13);
this.label1.TabIndex = 3;
this.label1.Text = "Filter";
//
// FunctionView // FunctionView
// //
this.FunctionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.FunctionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.FunctionView.BlazingFast = false;
this.FunctionView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.FunctionView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.LibraryReturn, this.LibraryReturn,
this.LibraryHead, this.LibraryHead,
@ -63,12 +85,16 @@
this.LibraryDescription}); this.LibraryDescription});
this.FunctionView.FullRowSelect = true; this.FunctionView.FullRowSelect = true;
this.FunctionView.GridLines = true; this.FunctionView.GridLines = true;
this.FunctionView.ItemCount = 0;
this.FunctionView.Location = new System.Drawing.Point(12, 12); this.FunctionView.Location = new System.Drawing.Point(12, 12);
this.FunctionView.Name = "FunctionView"; this.FunctionView.Name = "FunctionView";
this.FunctionView.SelectAllInProgress = false;
this.FunctionView.selectedItem = -1;
this.FunctionView.Size = new System.Drawing.Size(710, 291); this.FunctionView.Size = new System.Drawing.Size(710, 291);
this.FunctionView.TabIndex = 1; this.FunctionView.TabIndex = 1;
this.FunctionView.UseCompatibleStateImageBehavior = false; this.FunctionView.UseCompatibleStateImageBehavior = false;
this.FunctionView.View = System.Windows.Forms.View.Details; this.FunctionView.View = System.Windows.Forms.View.Details;
this.FunctionView.VirtualMode = true;
this.FunctionView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.FunctionView_ColumnClick); this.FunctionView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.FunctionView_ColumnClick);
this.FunctionView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FunctionView_KeyDown); this.FunctionView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FunctionView_KeyDown);
// //
@ -103,6 +129,8 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(730, 340); this.ClientSize = new System.Drawing.Size(730, 340);
this.Controls.Add(this.label1);
this.Controls.Add(this.FilterBox);
this.Controls.Add(this.FunctionView); this.Controls.Add(this.FunctionView);
this.Controls.Add(this.OK); this.Controls.Add(this.OK);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@ -112,6 +140,7 @@
this.Text = "Lua Functions"; this.Text = "Lua Functions";
this.Load += new System.EventHandler(this.LuaFunctionList_Load); this.Load += new System.EventHandler(this.LuaFunctionList_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
@ -119,11 +148,13 @@
private System.Windows.Forms.Button OK; private System.Windows.Forms.Button OK;
private System.DirectoryServices.DirectoryEntry directoryEntry1; private System.DirectoryServices.DirectoryEntry directoryEntry1;
private System.Windows.Forms.ListView FunctionView; private VirtualListView FunctionView;
private System.Windows.Forms.ColumnHeader LibraryHead; private System.Windows.Forms.ColumnHeader LibraryHead;
private System.Windows.Forms.ColumnHeader LibraryReturn; private System.Windows.Forms.ColumnHeader LibraryReturn;
private System.Windows.Forms.ColumnHeader LibraryName; private System.Windows.Forms.ColumnHeader LibraryName;
private System.Windows.Forms.ColumnHeader LibraryParameters; private System.Windows.Forms.ColumnHeader LibraryParameters;
private System.Windows.Forms.ColumnHeader LibraryDescription; private System.Windows.Forms.ColumnHeader LibraryDescription;
private System.Windows.Forms.TextBox FilterBox;
private System.Windows.Forms.Label label1;
} }
} }

View File

@ -1,38 +1,86 @@
using System; using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class LuaFunctionsForm : Form public partial class LuaFunctionsForm : Form
{ {
private readonly Sorting _columnSort = new Sorting(); private readonly Sorting _columnSort = new Sorting();
private List<LuaDocumentation.LibraryFunction> FunctionList = new List<LuaDocumentation.LibraryFunction>();
private List<LuaDocumentation.LibraryFunction> FilteredList
{
get
{
if (!string.IsNullOrWhiteSpace(FilterBox.Text))
{
return FunctionList
.Where(f => (f.Library + "." + f.Name).Contains(FilterBox.Text))
.ToList();
}
return FunctionList;
}
}
public LuaFunctionsForm() public LuaFunctionsForm()
{ {
InitializeComponent(); InitializeComponent();
FunctionView.QueryItemText += FunctionView_QueryItemText;
FunctionView.QueryItemBkColor += FunctionView_QueryItemBkColor;
} }
private void LuaFunctionList_Load(object sender, EventArgs e) private void LuaFunctionList_Load(object sender, EventArgs e)
{ {
PopulateListView(); FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList.ToList();
UpdateList();
FilterBox.Focus();
} }
private void PopulateListView() private void FunctionView_QueryItemBkColor(int index, int column, ref Color color)
{ {
FunctionView.Items.Clear();
foreach (var libraryFunction in GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList) }
private void FunctionView_QueryItemText(int index, int column, out string text)
{
text = string.Empty;
try
{ {
var item = new ListViewItem { Text = libraryFunction.ReturnType }; switch (column)
item.SubItems.Add(libraryFunction.Library + "."); {
item.SubItems.Add(libraryFunction.Name); case 0:
item.SubItems.Add(libraryFunction.ParameterList); text = FilteredList[index].ReturnType;
item.SubItems.Add(libraryFunction.Description); break;
FunctionView.Items.Add(item); case 1:
text = FilteredList[index].Library;
break;
case 2:
text = FilteredList[index].Name;
break;
case 3:
text = FilteredList[index].ParameterList;
break;
case 4:
text = FilteredList[index].Description;
break;
}
}
catch(Exception ex)
{
} }
} }
private void OrderColumn(int column) private void OrderColumn(int column)
{ {
_columnSort.Column = column; _columnSort.Column = column;
@ -41,19 +89,19 @@ namespace BizHawk.Client.EmuHawk
switch (column) switch (column)
{ {
case 0: // Return case 0: // Return
GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList.OrderByDescending(x => x.ReturnType).ToList(); FunctionList = FunctionList.OrderByDescending(x => x.ReturnType).ToList();
break; break;
case 1: // Library case 1: // Library
GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList.OrderByDescending(x => x.Library).ToList(); FunctionList = FunctionList.OrderByDescending(x => x.Library).ToList();
break; break;
case 2: // Name case 2: // Name
GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList.OrderByDescending(x => x.Name).ToList(); FunctionList = FunctionList.OrderByDescending(x => x.Name).ToList();
break; break;
case 3: // Parameters case 3: // Parameters
GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList.OrderByDescending(x => x.ParameterList).ToList(); FunctionList = FunctionList.OrderByDescending(x => x.ParameterList).ToList();
break; break;
case 4: // Description case 4: // Description
GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList.OrderByDescending(x => x.Description).ToList(); FunctionList = FunctionList.OrderByDescending(x => x.Description).ToList();
break; break;
} }
} }
@ -62,24 +110,24 @@ namespace BizHawk.Client.EmuHawk
switch (column) switch (column)
{ {
case 0: // Return case 0: // Return
GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList.OrderBy(x => x.ReturnType).ToList(); FunctionList = FunctionList.OrderBy(x => x.ReturnType).ToList();
break; break;
case 1: // Library case 1: // Library
GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList.OrderBy(x => x.Library).ToList(); FunctionList = FunctionList.OrderBy(x => x.Library).ToList();
break; break;
case 2: // Name case 2: // Name
GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList.OrderBy(x => x.Name).ToList(); FunctionList = FunctionList.OrderBy(x => x.Name).ToList();
break; break;
case 3: // Parameters case 3: // Parameters
GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList.OrderBy(x => x.ParameterList).ToList(); FunctionList = FunctionList.OrderBy(x => x.ParameterList).ToList();
break; break;
case 4: // Description case 4: // Description
GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList.OrderBy(x => x.Description).ToList(); FunctionList = FunctionList.OrderBy(x => x.Description).ToList();
break; break;
} }
} }
PopulateListView(); UpdateList();
} }
private void Ok_Click(object sender, EventArgs e) private void Ok_Click(object sender, EventArgs e)
@ -144,5 +192,15 @@ namespace BizHawk.Client.EmuHawk
} }
} }
} }
private void UpdateList()
{
FunctionView.ItemCount = FilteredList.Count;
}
private void FilterBox_KeyUp(object sender, KeyEventArgs e)
{
UpdateList();
}
} }
} }