Archive Chooser - restore double-click selection (weird that I had to do it this way), and resize some things

This commit is contained in:
adelikat 2014-01-16 02:38:27 +00:00
parent f669279cae
commit dcde99d1e1
2 changed files with 253 additions and 248 deletions

View File

@ -28,210 +28,211 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.btnCancel = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button(); this.btnOK = new System.Windows.Forms.Button();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.lvMembers = new System.Windows.Forms.ListView(); this.lvMembers = new System.Windows.Forms.ListView();
this.colName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.colName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.colSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.cbInstantFilter = new System.Windows.Forms.CheckBox(); this.cbInstantFilter = new System.Windows.Forms.CheckBox();
this.radRegEx = new System.Windows.Forms.RadioButton(); this.radRegEx = new System.Windows.Forms.RadioButton();
this.radSimple = new System.Windows.Forms.RadioButton(); this.radSimple = new System.Windows.Forms.RadioButton();
this.btnFilter = new System.Windows.Forms.Button(); this.btnFilter = new System.Windows.Forms.Button();
this.btnSearch = new System.Windows.Forms.Button(); this.btnSearch = new System.Windows.Forms.Button();
this.tbFilter = new System.Windows.Forms.TextBox(); this.tbFilter = new System.Windows.Forms.TextBox();
this.tbSearch = new System.Windows.Forms.TextBox(); this.tbSearch = new System.Windows.Forms.TextBox();
this.flowLayoutPanel1.SuspendLayout(); this.flowLayoutPanel1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// flowLayoutPanel1 // flowLayoutPanel1
// //
this.flowLayoutPanel1.AutoSize = true; this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.Controls.Add(this.btnCancel); this.flowLayoutPanel1.Controls.Add(this.btnCancel);
this.flowLayoutPanel1.Controls.Add(this.btnOK); this.flowLayoutPanel1.Controls.Add(this.btnOK);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 276); this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 317);
this.flowLayoutPanel1.Name = "flowLayoutPanel1"; this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(472, 29); this.flowLayoutPanel1.Size = new System.Drawing.Size(472, 29);
this.flowLayoutPanel1.TabIndex = 1; this.flowLayoutPanel1.TabIndex = 1;
// //
// btnCancel // btnCancel
// //
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(394, 3); this.btnCancel.Location = new System.Drawing.Point(394, 3);
this.btnCancel.Name = "btnCancel"; this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 8; this.btnCancel.TabIndex = 8;
this.btnCancel.Text = "Cancel"; this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
// //
// btnOK // btnOK
// //
this.btnOK.Location = new System.Drawing.Point(313, 3); this.btnOK.Location = new System.Drawing.Point(313, 3);
this.btnOK.Name = "btnOK"; this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23); this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 7; this.btnOK.TabIndex = 7;
this.btnOK.Text = "OK"; this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true; this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click); this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
// //
// tableLayoutPanel1 // tableLayoutPanel1
// //
this.tableLayoutPanel1.ColumnCount = 1; this.tableLayoutPanel1.ColumnCount = 1;
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.lvMembers, 0, 0); this.tableLayoutPanel1.Controls.Add(this.lvMembers, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 1); this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 1);
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 = 2;
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.Size = new System.Drawing.Size(472, 276); this.tableLayoutPanel1.Size = new System.Drawing.Size(472, 317);
this.tableLayoutPanel1.TabIndex = 0; this.tableLayoutPanel1.TabIndex = 0;
// //
// lvMembers // lvMembers
// //
this.lvMembers.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.lvMembers.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.colName, this.colName,
this.colSize}); this.colSize});
this.lvMembers.Dock = System.Windows.Forms.DockStyle.Fill; this.lvMembers.Dock = System.Windows.Forms.DockStyle.Fill;
this.lvMembers.FullRowSelect = true; this.lvMembers.FullRowSelect = true;
this.lvMembers.GridLines = true; this.lvMembers.GridLines = true;
this.lvMembers.Location = new System.Drawing.Point(3, 3); this.lvMembers.Location = new System.Drawing.Point(3, 3);
this.lvMembers.MultiSelect = false; this.lvMembers.MultiSelect = false;
this.lvMembers.Name = "lvMembers"; this.lvMembers.Name = "lvMembers";
this.lvMembers.Size = new System.Drawing.Size(466, 164); this.lvMembers.Size = new System.Drawing.Size(466, 229);
this.lvMembers.TabIndex = 0; this.lvMembers.TabIndex = 0;
this.lvMembers.UseCompatibleStateImageBehavior = false; this.lvMembers.UseCompatibleStateImageBehavior = false;
this.lvMembers.View = System.Windows.Forms.View.Details; this.lvMembers.View = System.Windows.Forms.View.Details;
// this.lvMembers.DoubleClick += new System.EventHandler(this.lvMembers_ItemActivate);
// colName //
// // colName
this.colName.DisplayIndex = 1; //
this.colName.Text = "Name"; this.colName.DisplayIndex = 1;
this.colName.Width = 409; this.colName.Text = "Name";
// this.colName.Width = 409;
// colSize //
// // colSize
this.colSize.DisplayIndex = 0; //
this.colSize.Text = "Size"; this.colSize.DisplayIndex = 0;
// this.colSize.Text = "Size";
// panel1 //
// // panel1
this.panel1.Controls.Add(this.cbInstantFilter); //
this.panel1.Controls.Add(this.radRegEx); this.panel1.Controls.Add(this.cbInstantFilter);
this.panel1.Controls.Add(this.radSimple); this.panel1.Controls.Add(this.radRegEx);
this.panel1.Controls.Add(this.btnFilter); this.panel1.Controls.Add(this.radSimple);
this.panel1.Controls.Add(this.btnSearch); this.panel1.Controls.Add(this.btnFilter);
this.panel1.Controls.Add(this.tbFilter); this.panel1.Controls.Add(this.btnSearch);
this.panel1.Controls.Add(this.tbSearch); this.panel1.Controls.Add(this.tbFilter);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Controls.Add(this.tbSearch);
this.panel1.Location = new System.Drawing.Point(3, 173); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Name = "panel1"; this.panel1.Location = new System.Drawing.Point(3, 238);
this.panel1.Size = new System.Drawing.Size(466, 100); this.panel1.Name = "panel1";
this.panel1.TabIndex = 4; this.panel1.Size = new System.Drawing.Size(466, 76);
// this.panel1.TabIndex = 4;
// cbInstantFilter //
// // cbInstantFilter
this.cbInstantFilter.AutoSize = true; //
this.cbInstantFilter.Checked = true; this.cbInstantFilter.AutoSize = true;
this.cbInstantFilter.CheckState = System.Windows.Forms.CheckState.Checked; this.cbInstantFilter.Checked = true;
this.cbInstantFilter.Location = new System.Drawing.Point(263, 5); this.cbInstantFilter.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbInstantFilter.Name = "cbInstantFilter"; this.cbInstantFilter.Location = new System.Drawing.Point(263, 5);
this.cbInstantFilter.Size = new System.Drawing.Size(106, 17); this.cbInstantFilter.Name = "cbInstantFilter";
this.cbInstantFilter.TabIndex = 3; this.cbInstantFilter.Size = new System.Drawing.Size(106, 17);
this.cbInstantFilter.Text = "Filter while typing"; this.cbInstantFilter.TabIndex = 3;
this.cbInstantFilter.UseVisualStyleBackColor = true; this.cbInstantFilter.Text = "Filter while typing";
this.cbInstantFilter.CheckedChanged += new System.EventHandler(this.cbInstantFilter_CheckedChanged); this.cbInstantFilter.UseVisualStyleBackColor = true;
// this.cbInstantFilter.CheckedChanged += new System.EventHandler(this.cbInstantFilter_CheckedChanged);
// radRegEx //
// // radRegEx
this.radRegEx.AutoSize = true; //
this.radRegEx.Location = new System.Drawing.Point(71, 58); this.radRegEx.AutoSize = true;
this.radRegEx.Name = "radRegEx"; this.radRegEx.Location = new System.Drawing.Point(71, 58);
this.radRegEx.Size = new System.Drawing.Size(116, 17); this.radRegEx.Name = "radRegEx";
this.radRegEx.TabIndex = 6; this.radRegEx.Size = new System.Drawing.Size(116, 17);
this.radRegEx.Text = "Regular Expression"; this.radRegEx.TabIndex = 6;
this.radRegEx.UseVisualStyleBackColor = true; this.radRegEx.Text = "Regular Expression";
this.radRegEx.CheckedChanged += new System.EventHandler(this.radRegEx_CheckedChanged); this.radRegEx.UseVisualStyleBackColor = true;
// this.radRegEx.CheckedChanged += new System.EventHandler(this.radRegEx_CheckedChanged);
// radSimple //
// // radSimple
this.radSimple.AutoSize = true; //
this.radSimple.Checked = true; this.radSimple.AutoSize = true;
this.radSimple.Location = new System.Drawing.Point(9, 57); this.radSimple.Checked = true;
this.radSimple.Name = "radSimple"; this.radSimple.Location = new System.Drawing.Point(9, 57);
this.radSimple.Size = new System.Drawing.Size(56, 17); this.radSimple.Name = "radSimple";
this.radSimple.TabIndex = 6; this.radSimple.Size = new System.Drawing.Size(56, 17);
this.radSimple.TabStop = true; this.radSimple.TabIndex = 6;
this.radSimple.Text = "Simple"; this.radSimple.TabStop = true;
this.radSimple.UseVisualStyleBackColor = true; this.radSimple.Text = "Simple";
// this.radSimple.UseVisualStyleBackColor = true;
// btnFilter //
// // btnFilter
this.btnFilter.Location = new System.Drawing.Point(182, 1); //
this.btnFilter.Name = "btnFilter"; this.btnFilter.Location = new System.Drawing.Point(182, 1);
this.btnFilter.Size = new System.Drawing.Size(75, 23); this.btnFilter.Name = "btnFilter";
this.btnFilter.TabIndex = 2; this.btnFilter.Size = new System.Drawing.Size(75, 23);
this.btnFilter.Text = "Filter"; this.btnFilter.TabIndex = 2;
this.btnFilter.UseVisualStyleBackColor = true; this.btnFilter.Text = "Filter";
this.btnFilter.Click += new System.EventHandler(this.btnFilter_Click); this.btnFilter.UseVisualStyleBackColor = true;
// this.btnFilter.Click += new System.EventHandler(this.btnFilter_Click);
// btnSearch //
// // btnSearch
this.btnSearch.Location = new System.Drawing.Point(182, 27); //
this.btnSearch.Name = "btnSearch"; this.btnSearch.Location = new System.Drawing.Point(182, 27);
this.btnSearch.Size = new System.Drawing.Size(75, 23); this.btnSearch.Name = "btnSearch";
this.btnSearch.TabIndex = 5; this.btnSearch.Size = new System.Drawing.Size(75, 23);
this.btnSearch.Text = "Find"; this.btnSearch.TabIndex = 5;
this.btnSearch.UseVisualStyleBackColor = true; this.btnSearch.Text = "Find";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click); this.btnSearch.UseVisualStyleBackColor = true;
// this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
// tbFilter //
// // tbFilter
this.tbFilter.Location = new System.Drawing.Point(9, 3); //
this.tbFilter.Name = "tbFilter"; this.tbFilter.Location = new System.Drawing.Point(9, 3);
this.tbFilter.Size = new System.Drawing.Size(167, 20); this.tbFilter.Name = "tbFilter";
this.tbFilter.TabIndex = 1; this.tbFilter.Size = new System.Drawing.Size(167, 20);
this.tbFilter.TextChanged += new System.EventHandler(this.tbFilter_TextChanged); this.tbFilter.TabIndex = 1;
// this.tbFilter.TextChanged += new System.EventHandler(this.tbFilter_TextChanged);
// tbSearch //
// // tbSearch
this.tbSearch.Location = new System.Drawing.Point(9, 29); //
this.tbSearch.Name = "tbSearch"; this.tbSearch.Location = new System.Drawing.Point(9, 29);
this.tbSearch.Size = new System.Drawing.Size(167, 20); this.tbSearch.Name = "tbSearch";
this.tbSearch.TabIndex = 4; this.tbSearch.Size = new System.Drawing.Size(167, 20);
// this.tbSearch.TabIndex = 4;
// ArchiveChooser //
// // ArchiveChooser
this.AcceptButton = this.btnOK; //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AcceptButton = this.btnOK;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.CancelButton = this.btnCancel; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(472, 305); this.CancelButton = this.btnCancel;
this.Controls.Add(this.tableLayoutPanel1); this.ClientSize = new System.Drawing.Size(472, 346);
this.Controls.Add(this.flowLayoutPanel1); this.Controls.Add(this.tableLayoutPanel1);
this.MaximizeBox = false; this.Controls.Add(this.flowLayoutPanel1);
this.MinimizeBox = false; this.MaximizeBox = false;
this.MinimumSize = new System.Drawing.Size(112, 138); this.MinimizeBox = false;
this.Name = "ArchiveChooser"; this.MinimumSize = new System.Drawing.Size(112, 138);
this.ShowIcon = false; this.Name = "ArchiveChooser";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.ShowIcon = false;
this.Text = "Choose File From Archive"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Load += new System.EventHandler(this.ArchiveChooser_Load); this.Text = "Choose File From Archive";
this.flowLayoutPanel1.ResumeLayout(false); this.Load += new System.EventHandler(this.ArchiveChooser_Load);
this.tableLayoutPanel1.ResumeLayout(false); this.flowLayoutPanel1.ResumeLayout(false);
this.panel1.ResumeLayout(false); this.tableLayoutPanel1.ResumeLayout(false);
this.panel1.PerformLayout(); this.panel1.ResumeLayout(false);
this.ResumeLayout(false); this.panel1.PerformLayout();
this.PerformLayout(); this.ResumeLayout(false);
this.PerformLayout();
} }

View File

@ -15,8 +15,8 @@ namespace BizHawk.Client.EmuHawk
IList<ListViewItem> archiveItems = new List<ListViewItem>(); IList<ListViewItem> archiveItems = new List<ListViewItem>();
ToolTip errorBalloon = new ToolTip(); ToolTip errorBalloon = new ToolTip();
static bool useRegEx = false; static bool useRegEx = false;
static bool matchWhileTyping = true; static bool matchWhileTyping = true;
public ArchiveChooser(HawkFile hawkfile) public ArchiveChooser(HawkFile hawkfile)
{ {
@ -24,17 +24,17 @@ namespace BizHawk.Client.EmuHawk
errorBalloon.IsBalloon = true; errorBalloon.IsBalloon = true;
errorBalloon.InitialDelay = 0; errorBalloon.InitialDelay = 0;
if (useRegEx) if (useRegEx)
radRegEx.Checked = true; radRegEx.Checked = true;
else else
radSimple.Checked = true; radSimple.Checked = true;
cbInstantFilter.Checked = matchWhileTyping; cbInstantFilter.Checked = matchWhileTyping;
var items = hawkfile.ArchiveItems; var items = hawkfile.ArchiveItems;
for (int i=0;i<items.Count;i++) for (int i = 0; i < items.Count; i++)
{ {
var item = items[i]; var item = items[i];
var lvi = new ListViewItem {Tag = i}; var lvi = new ListViewItem { Tag = i };
lvi.SubItems.Add(new ListViewItem.ListViewSubItem()); lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
lvi.Text = item.name; lvi.Text = item.name;
long size = item.size; long size = item.size;
@ -43,14 +43,14 @@ namespace BizHawk.Client.EmuHawk
size -= 16; size -= 16;
lvi.SubItems[1].Text = Util.FormatFileSize(size); lvi.SubItems[1].Text = Util.FormatFileSize(size);
archiveItems.Add(lvi); archiveItems.Add(lvi);
} }
InitializeFileView(); InitializeFileView();
} }
private void InitializeFileView() private void InitializeFileView()
{ {
archiveItems.OrderBy(x => x.Name); archiveItems.OrderBy(x => x.Name);
lvMembers.BeginUpdate(); lvMembers.BeginUpdate();
try try
@ -97,23 +97,23 @@ namespace BizHawk.Client.EmuHawk
private void ArchiveChooser_Load(object sender, EventArgs e) private void ArchiveChooser_Load(object sender, EventArgs e)
{ {
lvMembers.Items[0].Selected = true; lvMembers.Items[0].Selected = true;
tbFilter.Select(); tbFilter.Select();
} }
private void btnSearch_Click(object sender, EventArgs e) private void btnSearch_Click(object sender, EventArgs e)
{ {
StartMatching(tbSearch, DoSearch); StartMatching(tbSearch, DoSearch);
} }
private void cbInstantFilter_CheckedChanged(object sender, EventArgs e) private void cbInstantFilter_CheckedChanged(object sender, EventArgs e)
{ {
matchWhileTyping = cbInstantFilter.Checked; matchWhileTyping = cbInstantFilter.Checked;
} }
private void radRegEx_CheckedChanged(object sender, EventArgs e) private void radRegEx_CheckedChanged(object sender, EventArgs e)
{ {
useRegEx = radRegEx.Checked; useRegEx = radRegEx.Checked;
} }
private void tbFilter_TextChanged(object sender, EventArgs e) private void tbFilter_TextChanged(object sender, EventArgs e)
{ {
@ -129,20 +129,21 @@ namespace BizHawk.Client.EmuHawk
} }
private void StartMatching(TextBox tb, Action<IMatcher> func) private void StartMatching(TextBox tb, Action<IMatcher> func)
{ {
try try
{ {
errorBalloon.Hide(tb); errorBalloon.Hide(tb);
var searchMatcher = CreateMatcher(tb.Text); var searchMatcher = CreateMatcher(tb.Text);
if (searchMatcher != null) if (searchMatcher != null)
{ {
func(searchMatcher); func(searchMatcher);
} }
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
string errMsg = ex.Message; string errMsg = ex.Message;
errMsg = errMsg.Substring(errMsg.IndexOf('-') + 2); errMsg = errMsg.Substring(errMsg.IndexOf('-') + 2);
// Balloon is bugged on first invocation // Balloon is bugged on first invocation
errorBalloon.Show("Error parsing RegEx: " + errMsg, tb); errorBalloon.Show("Error parsing RegEx: " + errMsg, tb);
errorBalloon.Show("Error parsing RegEx: " + errMsg, tb); errorBalloon.Show("Error parsing RegEx: " + errMsg, tb);
@ -151,21 +152,21 @@ namespace BizHawk.Client.EmuHawk
private void DoSearch(IMatcher searchMatcher) private void DoSearch(IMatcher searchMatcher)
{ {
int count = lvMembers.Items.Count; int count = lvMembers.Items.Count;
int searchStartIdx = 0; int searchStartIdx = 0;
if (lvMembers.SelectedItems.Count > 0) if (lvMembers.SelectedItems.Count > 0)
{ {
searchStartIdx = (lvMembers.SelectedIndices[0] + 1) % count; searchStartIdx = (lvMembers.SelectedIndices[0] + 1) % count;
} }
int? searchResultIdx = null; int? searchResultIdx = null;
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
{ {
int curIdx = (searchStartIdx + i) % count; int curIdx = (searchStartIdx + i) % count;
if (searchMatcher.Matches(lvMembers.Items[curIdx])) if (searchMatcher.Matches(lvMembers.Items[curIdx]))
{ {
searchResultIdx = curIdx; searchResultIdx = curIdx;
break; break;
} }
} }
if (searchResultIdx != null) if (searchResultIdx != null)
@ -175,9 +176,9 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
// Balloon is bugged on first invocation // Balloon is bugged on first invocation
errorBalloon.Show("Could not find search text", tbSearch); errorBalloon.Show("Could not find search text", tbSearch);
errorBalloon.Show("Could not find search text", tbSearch); errorBalloon.Show("Could not find search text", tbSearch);
} }
} }
@ -209,17 +210,18 @@ namespace BizHawk.Client.EmuHawk
private class SimpleMatcher : IMatcher private class SimpleMatcher : IMatcher
{ {
public string[] Keys { get; set; } public string[] Keys { get; set; }
public bool Matches(ListViewItem value) public bool Matches(ListViewItem value)
{ {
string searchedStr = value.Text.ToLower(); string searchedStr = value.Text.ToLower();
foreach (string key in Keys) foreach (string key in Keys)
{ {
if (!searchedStr.Contains(key)) if (!searchedStr.Contains(key))
{ {
return false; return false;
} }
} }
return true;
return true;
} }
}; };
@ -236,9 +238,11 @@ namespace BizHawk.Client.EmuHawk
{ {
if (radSimple.Checked) if (radSimple.Checked)
{ {
return new SimpleMatcher { return new SimpleMatcher
Keys = searchKey.ToLower().Split(new char[0], {
StringSplitOptions.RemoveEmptyEntries)}; Keys = searchKey.ToLower().Split(new char[0],
StringSplitOptions.RemoveEmptyEntries)
};
} }
else else
{ {