LuaFunctions dialog - use listview in virtualmode instead of virtuallistview

This commit is contained in:
adelikat 2019-10-19 14:26:45 -05:00
parent 2a6225940b
commit b84413b947
2 changed files with 18 additions and 47 deletions

View File

@ -34,7 +34,7 @@
this.FilterBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.ToWikiMarkupButton = new System.Windows.Forms.Button();
this.FunctionView = new BizHawk.Client.EmuHawk.VirtualListView();
this.FunctionView = new System.Windows.Forms.ListView();
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()));
@ -96,7 +96,6 @@
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,
@ -105,11 +104,9 @@
this.LibraryDescription});
this.FunctionView.FullRowSelect = true;
this.FunctionView.GridLines = true;
this.FunctionView.ItemCount = 0;
this.FunctionView.VirtualListSize = 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;
@ -170,7 +167,7 @@
private System.Windows.Forms.Button OK;
private System.DirectoryServices.DirectoryEntry directoryEntry1;
private VirtualListView FunctionView;
private System.Windows.Forms.ListView FunctionView;
private System.Windows.Forms.ColumnHeader LibraryHead;
private System.Windows.Forms.ColumnHeader LibraryReturn;
private System.Windows.Forms.ColumnHeader LibraryName;

View File

@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Common;
namespace BizHawk.Client.EmuHawk
{
@ -35,8 +33,7 @@ namespace BizHawk.Client.EmuHawk
public LuaFunctionsForm()
{
InitializeComponent();
FunctionView.QueryItemText += FunctionView_QueryItemText;
FunctionView.QueryItemBkColor += FunctionView_QueryItemBkColor;
FunctionView.RetrieveVirtualItem += FunctionView_QueryItemText;
}
private void LuaFunctionList_Load(object sender, EventArgs e)
@ -51,42 +48,14 @@ namespace BizHawk.Client.EmuHawk
ToWikiMarkupButton.Visible = VersionInfo.DeveloperBuild;
}
private void FunctionView_QueryItemBkColor(int index, int column, ref Color color)
private void FunctionView_QueryItemText(object sender, RetrieveVirtualItemEventArgs e)
{
}
private void FunctionView_QueryItemText(int index, int column, out string text)
{
text = "";
try
{
if (_filteredList.Any() && index < _filteredList.Count)
{
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
{
/* Eat it*/
}
var entry = _filteredList[e.ItemIndex];
e.Item = new ListViewItem(entry.ReturnType);
e.Item.SubItems.Add(entry.Library);
e.Item.SubItems.Add(entry.Name);
e.Item.SubItems.Add(entry.ParameterList);
e.Item.SubItems.Add(entry.Description);
}
private void OrderColumn(int column)
@ -206,7 +175,12 @@ namespace BizHawk.Client.EmuHawk
//FREVBHFYL?
private void FunctionView_Copy(object sender, EventArgs e)
{
var itm = _filteredList[FunctionView.selectedItem];
if (FunctionView.SelectedIndices.Count == 0)
{
return;
}
var itm = _filteredList[FunctionView.SelectedIndices[0]];
var sb = new StringBuilder($"//{itm.Library}.{itm.Name}{itm.ParameterList}"); //comment style not an accident: the 'declaration' is not legal lua, so use of -- to comment it shouldn't suggest it. right?
if (itm.Example != null)
{
@ -221,7 +195,7 @@ namespace BizHawk.Client.EmuHawk
private void UpdateList()
{
GenerateFilteredList();
FunctionView.ItemCount = _filteredList.Count;
FunctionView.VirtualListSize = _filteredList.Count;
}
private void FilterBox_KeyUp(object sender, KeyEventArgs e)