From 5aae3feeb5547cf06018ac09207b72bda45a839a Mon Sep 17 00:00:00 2001 From: null_ptr Date: Mon, 13 Jan 2014 15:59:54 +0000 Subject: [PATCH] Filter focused at startup of ArchiveChooser Filter TextBox above search TextBox Files now sorted by plain filename --- .../ArchiveChooser.Designer.cs | 32 +++++----- BizHawk.Client.EmuHawk/ArchiveChooser.cs | 59 +++---------------- 2 files changed, 23 insertions(+), 68 deletions(-) diff --git a/BizHawk.Client.EmuHawk/ArchiveChooser.Designer.cs b/BizHawk.Client.EmuHawk/ArchiveChooser.Designer.cs index b6e9a894dd..d892b7dd4f 100644 --- a/BizHawk.Client.EmuHawk/ArchiveChooser.Designer.cs +++ b/BizHawk.Client.EmuHawk/ArchiveChooser.Designer.cs @@ -58,7 +58,7 @@ this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 276); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; this.flowLayoutPanel1.Size = new System.Drawing.Size(472, 29); - this.flowLayoutPanel1.TabIndex = 0; + this.flowLayoutPanel1.TabIndex = 1; // // btnCancel // @@ -66,7 +66,7 @@ this.btnCancel.Location = new System.Drawing.Point(394, 3); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(75, 23); - this.btnCancel.TabIndex = 1; + this.btnCancel.TabIndex = 8; this.btnCancel.Text = "Cancel"; this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); @@ -76,7 +76,7 @@ this.btnOK.Location = new System.Drawing.Point(313, 3); this.btnOK.Name = "btnOK"; this.btnOK.Size = new System.Drawing.Size(75, 23); - this.btnOK.TabIndex = 0; + this.btnOK.TabIndex = 7; this.btnOK.Text = "OK"; this.btnOK.UseVisualStyleBackColor = true; this.btnOK.Click += new System.EventHandler(this.btnOK_Click); @@ -94,7 +94,7 @@ 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.Size = new System.Drawing.Size(472, 276); - this.tableLayoutPanel1.TabIndex = 1; + this.tableLayoutPanel1.TabIndex = 0; // // lvMembers // @@ -108,7 +108,7 @@ this.lvMembers.MultiSelect = false; this.lvMembers.Name = "lvMembers"; this.lvMembers.Size = new System.Drawing.Size(466, 164); - this.lvMembers.TabIndex = 3; + this.lvMembers.TabIndex = 0; this.lvMembers.UseCompatibleStateImageBehavior = false; this.lvMembers.View = System.Windows.Forms.View.Details; // @@ -143,10 +143,10 @@ this.cbInstantFilter.AutoSize = true; this.cbInstantFilter.Checked = true; this.cbInstantFilter.CheckState = System.Windows.Forms.CheckState.Checked; - this.cbInstantFilter.Location = new System.Drawing.Point(258, 33); + this.cbInstantFilter.Location = new System.Drawing.Point(263, 5); this.cbInstantFilter.Name = "cbInstantFilter"; this.cbInstantFilter.Size = new System.Drawing.Size(106, 17); - this.cbInstantFilter.TabIndex = 6; + this.cbInstantFilter.TabIndex = 3; this.cbInstantFilter.Text = "Filter while typing"; this.cbInstantFilter.UseVisualStyleBackColor = true; this.cbInstantFilter.CheckedChanged += new System.EventHandler(this.cbInstantFilter_CheckedChanged); @@ -157,7 +157,7 @@ this.radRegEx.Location = new System.Drawing.Point(71, 58); this.radRegEx.Name = "radRegEx"; this.radRegEx.Size = new System.Drawing.Size(116, 17); - this.radRegEx.TabIndex = 5; + this.radRegEx.TabIndex = 6; this.radRegEx.Text = "Regular Expression"; this.radRegEx.UseVisualStyleBackColor = true; this.radRegEx.CheckedChanged += new System.EventHandler(this.radRegEx_CheckedChanged); @@ -169,34 +169,34 @@ this.radSimple.Location = new System.Drawing.Point(9, 57); this.radSimple.Name = "radSimple"; this.radSimple.Size = new System.Drawing.Size(56, 17); - this.radSimple.TabIndex = 4; + this.radSimple.TabIndex = 6; this.radSimple.TabStop = true; this.radSimple.Text = "Simple"; this.radSimple.UseVisualStyleBackColor = true; // // btnFilter // - this.btnFilter.Location = new System.Drawing.Point(177, 29); + this.btnFilter.Location = new System.Drawing.Point(182, 1); this.btnFilter.Name = "btnFilter"; this.btnFilter.Size = new System.Drawing.Size(75, 23); - this.btnFilter.TabIndex = 3; + this.btnFilter.TabIndex = 2; this.btnFilter.Text = "Filter"; this.btnFilter.UseVisualStyleBackColor = true; this.btnFilter.Click += new System.EventHandler(this.btnFilter_Click); // // btnSearch // - this.btnSearch.Location = new System.Drawing.Point(177, 3); + this.btnSearch.Location = new System.Drawing.Point(182, 27); this.btnSearch.Name = "btnSearch"; this.btnSearch.Size = new System.Drawing.Size(75, 23); - this.btnSearch.TabIndex = 2; + this.btnSearch.TabIndex = 5; this.btnSearch.Text = "Find"; this.btnSearch.UseVisualStyleBackColor = true; this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click); // // tbFilter // - this.tbFilter.Location = new System.Drawing.Point(4, 31); + this.tbFilter.Location = new System.Drawing.Point(9, 3); this.tbFilter.Name = "tbFilter"; this.tbFilter.Size = new System.Drawing.Size(167, 20); this.tbFilter.TabIndex = 1; @@ -204,10 +204,10 @@ // // tbSearch // - this.tbSearch.Location = new System.Drawing.Point(4, 4); + this.tbSearch.Location = new System.Drawing.Point(9, 29); this.tbSearch.Name = "tbSearch"; this.tbSearch.Size = new System.Drawing.Size(167, 20); - this.tbSearch.TabIndex = 0; + this.tbSearch.TabIndex = 4; // // ArchiveChooser // diff --git a/BizHawk.Client.EmuHawk/ArchiveChooser.cs b/BizHawk.Client.EmuHawk/ArchiveChooser.cs index 5db5bfd63f..65d157e176 100644 --- a/BizHawk.Client.EmuHawk/ArchiveChooser.cs +++ b/BizHawk.Client.EmuHawk/ArchiveChooser.cs @@ -43,63 +43,17 @@ namespace BizHawk.Client.EmuHawk size -= 16; lvi.SubItems[1].Text = Util.FormatFileSize(size); archiveItems.Add(lvi); - lvMembers.Items.Add(lvi); - } + } - SortItems(); + InitializeFileView(); } - private bool IsVerifiedRegion(string name, string region) + private void InitializeFileView() { - if (name.Contains(region) && name.Contains("[!]")) - return true; - else - return false; - } - - private bool IsUnverifiedRegion(string name, string region) - { - if (name.Contains(region) && !(name.Contains("[!]"))) - return true; - else - return false; - } - - private bool IsNotRegion(string name) - { - if (name.Contains("(W)")) return false; - if (name.Contains("(JU)")) return false; - if (name.Contains("(U)")) return false; - if (name.Contains("(J)")) return false; - if (name.Contains("(E)")) return false; - return true; - } - - private void SortItems() - { - List lvitems = lvMembers.Items.Cast().ToList(); - - List sorteditems = new List(); - - sorteditems.AddRange(lvitems.Where(x => IsVerifiedRegion(x.SubItems[1].Text, "(W)")).OrderBy(x => x.Name).ToList()); - sorteditems.AddRange(lvitems.Where(x => IsUnverifiedRegion(x.SubItems[1].Text, "(W)")).OrderBy(x => x.Name).ToList()); - - sorteditems.AddRange(lvitems.Where(x => IsVerifiedRegion(x.SubItems[1].Text, "(JU)")).OrderBy(x => x.Name).ToList()); - sorteditems.AddRange(lvitems.Where(x => IsUnverifiedRegion(x.SubItems[1].Text, "(JU)")).OrderBy(x => x.Name).ToList()); - - sorteditems.AddRange(lvitems.Where(x => IsVerifiedRegion(x.SubItems[1].Text, "(U)")).OrderBy(x => x.Name).ToList()); - sorteditems.AddRange(lvitems.Where(x => IsUnverifiedRegion(x.SubItems[1].Text, "(U)")).OrderBy(x => x.Name).ToList()); - - sorteditems.AddRange(lvitems.Where(x => IsVerifiedRegion(x.SubItems[1].Text, "(J)")).OrderBy(x => x.Name).ToList()); - sorteditems.AddRange(lvitems.Where(x => IsUnverifiedRegion(x.SubItems[1].Text, "(J)")).OrderBy(x => x.Name).ToList()); - - sorteditems.AddRange(lvitems.Where(x => IsVerifiedRegion(x.SubItems[1].Text, "(E)")).OrderBy(x => x.Name).ToList()); - sorteditems.AddRange(lvitems.Where(x => IsUnverifiedRegion(x.SubItems[1].Text, "(E)")).OrderBy(x => x.Name).ToList()); - - sorteditems.AddRange(lvitems.Where(x => IsNotRegion(x.SubItems[1].Text)).ToList()); + archiveItems.OrderBy(x => x.Name); lvMembers.Items.Clear(); - foreach (ListViewItem i in sorteditems) + foreach (ListViewItem i in archiveItems) { lvMembers.Items.Add(i); } @@ -135,6 +89,7 @@ namespace BizHawk.Client.EmuHawk private void ArchiveChooser_Load(object sender, EventArgs e) { lvMembers.Items[0].Selected = true; + tbFilter.Select(); } private void btnSearch_Click(object sender, EventArgs e) @@ -207,7 +162,7 @@ namespace BizHawk.Client.EmuHawk } if (searchResultIdx != null) { - lvMembers.Focus(); + lvMembers.Select(); lvMembers.Items[searchResultIdx.Value].Selected = true; } else