Archives: Added search box to select rom dialog
This commit is contained in:
parent
b852edfec8
commit
9fc9c8bc60
3 changed files with 117 additions and 7 deletions
66
GUI.NET/Forms/frmSelectRom.Designer.cs
generated
66
GUI.NET/Forms/frmSelectRom.Designer.cs
generated
|
@ -27,14 +27,20 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
this.lstRoms = new System.Windows.Forms.ListBox();
|
this.lstRoms = new System.Windows.Forms.ListBox();
|
||||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
this.btnOK = new System.Windows.Forms.Button();
|
this.btnOK = new System.Windows.Forms.Button();
|
||||||
this.btnCancel = new System.Windows.Forms.Button();
|
this.btnCancel = new System.Windows.Forms.Button();
|
||||||
this.lblRomCount = new System.Windows.Forms.Label();
|
this.lblRomCount = new System.Windows.Forms.Label();
|
||||||
|
this.lblSearch = new System.Windows.Forms.Label();
|
||||||
|
this.txtSearch = new System.Windows.Forms.TextBox();
|
||||||
|
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.tmrSearch = new System.Windows.Forms.Timer(this.components);
|
||||||
this.tableLayoutPanel1.SuspendLayout();
|
this.tableLayoutPanel1.SuspendLayout();
|
||||||
this.flowLayoutPanel1.SuspendLayout();
|
this.flowLayoutPanel1.SuspendLayout();
|
||||||
|
this.tableLayoutPanel2.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// tableLayoutPanel1
|
// tableLayoutPanel1
|
||||||
|
@ -42,13 +48,15 @@
|
||||||
this.tableLayoutPanel1.ColumnCount = 2;
|
this.tableLayoutPanel1.ColumnCount = 2;
|
||||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
this.tableLayoutPanel1.Controls.Add(this.lstRoms, 0, 0);
|
this.tableLayoutPanel1.Controls.Add(this.lstRoms, 0, 1);
|
||||||
this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 1, 1);
|
this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 1, 2);
|
||||||
this.tableLayoutPanel1.Controls.Add(this.lblRomCount, 0, 1);
|
this.tableLayoutPanel1.Controls.Add(this.lblRomCount, 0, 2);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 0);
|
||||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||||
this.tableLayoutPanel1.RowCount = 2;
|
this.tableLayoutPanel1.RowCount = 3;
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||||
|
@ -62,9 +70,9 @@
|
||||||
this.lstRoms.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.lstRoms.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.lstRoms.FormattingEnabled = true;
|
this.lstRoms.FormattingEnabled = true;
|
||||||
this.lstRoms.ItemHeight = 18;
|
this.lstRoms.ItemHeight = 18;
|
||||||
this.lstRoms.Location = new System.Drawing.Point(3, 3);
|
this.lstRoms.Location = new System.Drawing.Point(3, 28);
|
||||||
this.lstRoms.Name = "lstRoms";
|
this.lstRoms.Name = "lstRoms";
|
||||||
this.lstRoms.Size = new System.Drawing.Size(457, 207);
|
this.lstRoms.Size = new System.Drawing.Size(457, 182);
|
||||||
this.lstRoms.TabIndex = 1;
|
this.lstRoms.TabIndex = 1;
|
||||||
this.lstRoms.SelectedIndexChanged += new System.EventHandler(this.lstRoms_SelectedIndexChanged);
|
this.lstRoms.SelectedIndexChanged += new System.EventHandler(this.lstRoms_SelectedIndexChanged);
|
||||||
this.lstRoms.DoubleClick += new System.EventHandler(this.lstRoms_DoubleClick);
|
this.lstRoms.DoubleClick += new System.EventHandler(this.lstRoms_DoubleClick);
|
||||||
|
@ -113,6 +121,46 @@
|
||||||
this.lblRomCount.TabIndex = 2;
|
this.lblRomCount.TabIndex = 2;
|
||||||
this.lblRomCount.Text = "### roms found";
|
this.lblRomCount.Text = "### roms found";
|
||||||
//
|
//
|
||||||
|
// lblSearch
|
||||||
|
//
|
||||||
|
this.lblSearch.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||||
|
this.lblSearch.AutoSize = true;
|
||||||
|
this.lblSearch.Location = new System.Drawing.Point(3, 6);
|
||||||
|
this.lblSearch.Name = "lblSearch";
|
||||||
|
this.lblSearch.Size = new System.Drawing.Size(44, 13);
|
||||||
|
this.lblSearch.TabIndex = 3;
|
||||||
|
this.lblSearch.Text = "Search:";
|
||||||
|
//
|
||||||
|
// txtSearch
|
||||||
|
//
|
||||||
|
this.txtSearch.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.txtSearch.Location = new System.Drawing.Point(53, 3);
|
||||||
|
this.txtSearch.Name = "txtSearch";
|
||||||
|
this.txtSearch.Size = new System.Drawing.Size(407, 20);
|
||||||
|
this.txtSearch.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// tableLayoutPanel2
|
||||||
|
//
|
||||||
|
this.tableLayoutPanel2.ColumnCount = 2;
|
||||||
|
this.tableLayoutPanel1.SetColumnSpan(this.tableLayoutPanel2, 2);
|
||||||
|
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||||
|
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel2.Controls.Add(this.txtSearch, 1, 0);
|
||||||
|
this.tableLayoutPanel2.Controls.Add(this.lblSearch, 0, 0);
|
||||||
|
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
|
||||||
|
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||||
|
this.tableLayoutPanel2.RowCount = 1;
|
||||||
|
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel2.Size = new System.Drawing.Size(463, 25);
|
||||||
|
this.tableLayoutPanel2.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// tmrSearch
|
||||||
|
//
|
||||||
|
this.tmrSearch.Enabled = true;
|
||||||
|
this.tmrSearch.Tick += new System.EventHandler(this.tmrSearch_Tick);
|
||||||
|
//
|
||||||
// frmSelectRom
|
// frmSelectRom
|
||||||
//
|
//
|
||||||
this.AcceptButton = this.btnOK;
|
this.AcceptButton = this.btnOK;
|
||||||
|
@ -127,6 +175,8 @@
|
||||||
this.tableLayoutPanel1.ResumeLayout(false);
|
this.tableLayoutPanel1.ResumeLayout(false);
|
||||||
this.tableLayoutPanel1.PerformLayout();
|
this.tableLayoutPanel1.PerformLayout();
|
||||||
this.flowLayoutPanel1.ResumeLayout(false);
|
this.flowLayoutPanel1.ResumeLayout(false);
|
||||||
|
this.tableLayoutPanel2.ResumeLayout(false);
|
||||||
|
this.tableLayoutPanel2.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -139,5 +189,9 @@
|
||||||
private System.Windows.Forms.Button btnOK;
|
private System.Windows.Forms.Button btnOK;
|
||||||
private System.Windows.Forms.Button btnCancel;
|
private System.Windows.Forms.Button btnCancel;
|
||||||
private System.Windows.Forms.Label lblRomCount;
|
private System.Windows.Forms.Label lblRomCount;
|
||||||
|
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
|
||||||
|
private System.Windows.Forms.TextBox txtSearch;
|
||||||
|
private System.Windows.Forms.Label lblSearch;
|
||||||
|
private System.Windows.Forms.Timer tmrSearch;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,6 +14,7 @@ namespace Mesen.GUI.Forms
|
||||||
{
|
{
|
||||||
private List<string> _romFiles;
|
private List<string> _romFiles;
|
||||||
private int SelectedIndex { get; set; }
|
private int SelectedIndex { get; set; }
|
||||||
|
private string _previousSearch = "";
|
||||||
|
|
||||||
public frmSelectRom(List<string> romFiles)
|
public frmSelectRom(List<string> romFiles)
|
||||||
{
|
{
|
||||||
|
@ -22,9 +23,53 @@ namespace Mesen.GUI.Forms
|
||||||
_romFiles = romFiles;
|
_romFiles = romFiles;
|
||||||
lblRomCount.Text = ResourceHelper.GetMessage("RomsFound", _romFiles.Count.ToString());
|
lblRomCount.Text = ResourceHelper.GetMessage("RomsFound", _romFiles.Count.ToString());
|
||||||
|
|
||||||
lstRoms.Items.AddRange(romFiles.ToArray());
|
|
||||||
lstRoms.Sorted = true;
|
lstRoms.Sorted = true;
|
||||||
this.DialogResult = DialogResult.Cancel;
|
this.DialogResult = DialogResult.Cancel;
|
||||||
|
|
||||||
|
UpdateList();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||||
|
{
|
||||||
|
if(txtSearch.Focused) {
|
||||||
|
if(keyData == Keys.Down || keyData == Keys.PageDown || keyData == Keys.Up || keyData == Keys.PageUp) {
|
||||||
|
lstRoms.Focus();
|
||||||
|
if(lstRoms.Items.Count > 0) {
|
||||||
|
lstRoms.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if(lstRoms.Focused && lstRoms.SelectedIndex <= 0) {
|
||||||
|
if(keyData == Keys.Up || keyData == Keys.PageUp) {
|
||||||
|
txtSearch.Focus();
|
||||||
|
txtSearch.SelectAll();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return base.ProcessCmdKey(ref msg, keyData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateList()
|
||||||
|
{
|
||||||
|
lstRoms.Items.Clear();
|
||||||
|
if(string.IsNullOrWhiteSpace(_previousSearch)) {
|
||||||
|
lstRoms.Items.AddRange(_romFiles.ToArray());
|
||||||
|
} else {
|
||||||
|
List<string> romsToAdd = new List<string>();
|
||||||
|
foreach(string rom in _romFiles) {
|
||||||
|
if(rom.IndexOf(_previousSearch, StringComparison.InvariantCultureIgnoreCase) >= 0) {
|
||||||
|
romsToAdd.Add(rom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lstRoms.Items.AddRange(romsToAdd.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnLoad(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnLoad(e);
|
||||||
|
|
||||||
|
txtSearch.Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool SelectRom(string filename, out int archiveFileIndex)
|
public static bool SelectRom(string filename, out int archiveFileIndex)
|
||||||
|
@ -64,5 +109,13 @@ namespace Mesen.GUI.Forms
|
||||||
{
|
{
|
||||||
SetSelectedIndex();
|
SetSelectedIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tmrSearch_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(txtSearch.Text.Trim() != _previousSearch) {
|
||||||
|
_previousSearch = txtSearch.Text.Trim();
|
||||||
|
UpdateList();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,4 +120,7 @@
|
||||||
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="tmrSearch.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>107, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
Loading…
Add table
Reference in a new issue