diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.Designer.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.Designer.cs index 4463162796..76e927b7c2 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.Designer.cs @@ -31,7 +31,9 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LuaFunctionsForm)); this.OK = new System.Windows.Forms.Button(); 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.LibraryHead = ((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.Name = "OK"; this.OK.Size = new System.Drawing.Size(75, 23); - this.OK.TabIndex = 0; + this.OK.TabIndex = 10; this.OK.Text = "&Ok"; this.OK.UseVisualStyleBackColor = true; 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 // 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.Right))); + this.FunctionView.BlazingFast = false; this.FunctionView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.LibraryReturn, this.LibraryHead, @@ -63,12 +85,16 @@ this.LibraryDescription}); this.FunctionView.FullRowSelect = true; this.FunctionView.GridLines = true; + this.FunctionView.ItemCount = 0; this.FunctionView.Location = new System.Drawing.Point(12, 12); this.FunctionView.Name = "FunctionView"; + this.FunctionView.SelectAllInProgress = false; + this.FunctionView.selectedItem = -1; this.FunctionView.Size = new System.Drawing.Size(710, 291); this.FunctionView.TabIndex = 1; this.FunctionView.UseCompatibleStateImageBehavior = false; 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.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FunctionView_KeyDown); // @@ -103,6 +129,8 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 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.OK); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); @@ -112,6 +140,7 @@ this.Text = "Lua Functions"; this.Load += new System.EventHandler(this.LuaFunctionList_Load); this.ResumeLayout(false); + this.PerformLayout(); } @@ -119,11 +148,13 @@ private System.Windows.Forms.Button OK; 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 LibraryReturn; private System.Windows.Forms.ColumnHeader LibraryName; private System.Windows.Forms.ColumnHeader LibraryParameters; private System.Windows.Forms.ColumnHeader LibraryDescription; + private System.Windows.Forms.TextBox FilterBox; + private System.Windows.Forms.Label label1; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs index f81f2e4305..2a2f2924d6 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs @@ -1,38 +1,86 @@ using System; +using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.Client.EmuHawk { public partial class LuaFunctionsForm : Form { private readonly Sorting _columnSort = new Sorting(); - + + private List FunctionList = new List(); + + private List FilteredList + { + get + { + if (!string.IsNullOrWhiteSpace(FilterBox.Text)) + { + return FunctionList + .Where(f => (f.Library + "." + f.Name).Contains(FilterBox.Text)) + .ToList(); + } + + return FunctionList; + } + } + public LuaFunctionsForm() { InitializeComponent(); + FunctionView.QueryItemText += FunctionView_QueryItemText; + FunctionView.QueryItemBkColor += FunctionView_QueryItemBkColor; } 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 }; - item.SubItems.Add(libraryFunction.Library + "."); - item.SubItems.Add(libraryFunction.Name); - item.SubItems.Add(libraryFunction.ParameterList); - item.SubItems.Add(libraryFunction.Description); - FunctionView.Items.Add(item); + switch (column) + { + case 0: + text = FilteredList[index].ReturnType; + break; + 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) { _columnSort.Column = column; @@ -41,19 +89,19 @@ namespace BizHawk.Client.EmuHawk switch (column) { 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; 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; 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; 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; 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; } } @@ -62,24 +110,24 @@ namespace BizHawk.Client.EmuHawk switch (column) { 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; 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; 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; 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; 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; } } - PopulateListView(); + UpdateList(); } 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(); + } } }