From f5780a436605d8753eb82a2a8763fba477452d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AD=B1=E5=82=91?= Date: Wed, 18 Oct 2023 22:49:45 +0800 Subject: [PATCH] Fix UI issues --- .../Forms/FormTextMapBrowser.Designer.cs | 52 +++++++++---------- .../Forms/FormTextMapBrowser.cs | 36 ++++++------- .../Forms/FormTextMapBrowser.resx | 30 +++++------ Source/GrasscutterTools/Pages/PageHotKey.resx | 4 +- Source/GrasscutterTools/Pages/PageScene.cs | 2 +- Source/GrasscutterTools/Pages/PageSettings.cs | 1 + 6 files changed, 62 insertions(+), 63 deletions(-) diff --git a/Source/GrasscutterTools/Forms/FormTextMapBrowser.Designer.cs b/Source/GrasscutterTools/Forms/FormTextMapBrowser.Designer.cs index ef8832a..3107041 100644 --- a/Source/GrasscutterTools/Forms/FormTextMapBrowser.Designer.cs +++ b/Source/GrasscutterTools/Forms/FormTextMapBrowser.Designer.cs @@ -37,10 +37,10 @@ this.LblResourcesPath = new System.Windows.Forms.Label(); this.BtnSearch = new System.Windows.Forms.Button(); this.DGVTextMap = new System.Windows.Forms.DataGridView(); - this.ColumnHash = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnID = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ColumnText = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.LblClearFilter = new System.Windows.Forms.Label(); + this.ColumnHash = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnText = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnID = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.DGVTextMap)).BeginInit(); this.SuspendLayout(); // @@ -100,30 +100,12 @@ this.DGVTextMap.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.DGVTextMap.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.ColumnHash, - this.ColumnID, - this.ColumnText}); + this.ColumnText, + this.ColumnID}); this.DGVTextMap.Name = "DGVTextMap"; this.DGVTextMap.ReadOnly = true; this.DGVTextMap.RowTemplate.Height = 23; // - // ColumnHash - // - resources.ApplyResources(this.ColumnHash, "ColumnHash"); - this.ColumnHash.Name = "ColumnHash"; - this.ColumnHash.ReadOnly = true; - // - // ColumnID - // - resources.ApplyResources(this.ColumnID, "ColumnID"); - this.ColumnID.Name = "ColumnID"; - this.ColumnID.ReadOnly = true; - // - // ColumnText - // - resources.ApplyResources(this.ColumnText, "ColumnText"); - this.ColumnText.Name = "ColumnText"; - this.ColumnText.ReadOnly = true; - // // LblClearFilter // resources.ApplyResources(this.LblClearFilter, "LblClearFilter"); @@ -132,6 +114,24 @@ this.LblClearFilter.Name = "LblClearFilter"; this.LblClearFilter.Click += new System.EventHandler(this.LblClearFilter_Click); // + // ColumnHash + // + resources.ApplyResources(this.ColumnHash, "ColumnHash"); + this.ColumnHash.Name = "ColumnHash"; + this.ColumnHash.ReadOnly = true; + // + // ColumnText + // + resources.ApplyResources(this.ColumnText, "ColumnText"); + this.ColumnText.Name = "ColumnText"; + this.ColumnText.ReadOnly = true; + // + // ColumnID + // + resources.ApplyResources(this.ColumnID, "ColumnID"); + this.ColumnID.Name = "ColumnID"; + this.ColumnID.ReadOnly = true; + // // FormTextMapBrowser // resources.ApplyResources(this, "$this"); @@ -162,9 +162,9 @@ private System.Windows.Forms.Label LblResourcesPath; private System.Windows.Forms.Button BtnSearch; private System.Windows.Forms.DataGridView DGVTextMap; - private System.Windows.Forms.DataGridViewTextBoxColumn ColumnHash; - private System.Windows.Forms.DataGridViewTextBoxColumn ColumnID; - private System.Windows.Forms.DataGridViewTextBoxColumn ColumnText; private System.Windows.Forms.Label LblClearFilter; + private System.Windows.Forms.DataGridViewTextBoxColumn ColumnHash; + private System.Windows.Forms.DataGridViewTextBoxColumn ColumnText; + private System.Windows.Forms.DataGridViewTextBoxColumn ColumnID; } } \ No newline at end of file diff --git a/Source/GrasscutterTools/Forms/FormTextMapBrowser.cs b/Source/GrasscutterTools/Forms/FormTextMapBrowser.cs index 1a2060a..540df2d 100644 --- a/Source/GrasscutterTools/Forms/FormTextMapBrowser.cs +++ b/Source/GrasscutterTools/Forms/FormTextMapBrowser.cs @@ -119,13 +119,12 @@ namespace GrasscutterTools.Forms private void GenLines() { - List items = new List(data.TextMap.Count); + var items = new List(data.TextMap.Count); foreach (var kv in data.TextMap) { - if (data.ManualTextMap.TryGetValue(kv.Key, out string id)) - items.Add(new ListViewItem(new string[] { kv.Key, id, kv.Value })); - else - items.Add(new ListViewItem(new string[] { kv.Key, "", kv.Value })); + items.Add(data.ManualTextMap?.TryGetValue(kv.Key, out var id) == true + ? new ListViewItem(new[] { kv.Key, id, kv.Value }) + : new ListViewItem(new[] { kv.Key, "", kv.Value })); } Items = items; } @@ -161,26 +160,25 @@ namespace GrasscutterTools.Forms Cursor = Cursors.WaitCursor; Application.DoEvents(); - var result = data.ManualTextMap.Where(kv => r.Match(kv.Value).Success) - .Select(kv => new { Hash = kv.Key, Id = kv.Value, Text = data.TextMap[kv.Key] }) - .Concat( - data.TextMap.Where(kv => r.Match(kv.Key).Success || r.Match(kv.Value).Success) - .Select(kv => new - { - Hash = kv.Key, - Id = data.ManualTextMap.TryGetValue(kv.Key, out string id) ? id : "", - Text = kv.Value - }) - ).ToList(); + var manualResult = data.ManualTextMap?.Where(kv => r.Match(kv.Value).Success) + .Select(kv => new { Hash = kv.Key, Text = data.TextMap[kv.Key], Id = kv.Value, }); + var textMapResult = data.TextMap.Where(kv => r.Match(kv.Key).Success || r.Match(kv.Value).Success) + .Select(kv => new + { + Hash = kv.Key, + Text = kv.Value, + Id = data.ManualTextMap?.TryGetValue(kv.Key, out var id) == true ? id : "", + }); + var result = manualResult == null ? textMapResult.ToList() : textMapResult.Concat(manualResult).ToList(); DGVTextMap.SuspendLayout(); DGVTextMap.Rows.Clear(); - for (int i = 0; i < result.Count; i++) + for (var i = 0; i < result.Count; i++) { DGVTextMap.Rows.Add(); DGVTextMap.Rows[i].Cells[0].Value = result[i].Hash; - DGVTextMap.Rows[i].Cells[1].Value = result[i].Id; - DGVTextMap.Rows[i].Cells[2].Value = result[i].Text; + DGVTextMap.Rows[i].Cells[1].Value = result[i].Text; + DGVTextMap.Rows[i].Cells[2].Value = result[i].Id; } DGVTextMap.ResumeLayout(); } diff --git a/Source/GrasscutterTools/Forms/FormTextMapBrowser.resx b/Source/GrasscutterTools/Forms/FormTextMapBrowser.resx index 74d941e..121eb3b 100644 --- a/Source/GrasscutterTools/Forms/FormTextMapBrowser.resx +++ b/Source/GrasscutterTools/Forms/FormTextMapBrowser.resx @@ -315,15 +315,6 @@ 80 - - True - - - ID - - - 240 - True @@ -333,6 +324,15 @@ 250 + + True + + + ID + + + 240 + 12, 70 @@ -420,18 +420,18 @@ System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ColumnID - - - System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ColumnText System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ColumnID + + + System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + FormTextMapBrowser diff --git a/Source/GrasscutterTools/Pages/PageHotKey.resx b/Source/GrasscutterTools/Pages/PageHotKey.resx index b920e45..018b62e 100644 --- a/Source/GrasscutterTools/Pages/PageHotKey.resx +++ b/Source/GrasscutterTools/Pages/PageHotKey.resx @@ -274,7 +274,7 @@ 2 - Bottom, Left, Right + Bottom, Right 262, 210 @@ -301,7 +301,7 @@ 4 - Bottom, Left, Right + Bottom, Right True diff --git a/Source/GrasscutterTools/Pages/PageScene.cs b/Source/GrasscutterTools/Pages/PageScene.cs index 113b68f..ba97d2b 100644 --- a/Source/GrasscutterTools/Pages/PageScene.cs +++ b/Source/GrasscutterTools/Pages/PageScene.cs @@ -90,7 +90,7 @@ namespace GrasscutterTools.Pages private void TxtSceneFilter_TextChanged(object sender, EventArgs e) { UIUtil.ListBoxFilter(ListScenes, Scenes, TxtSceneFilter.Text); - TxtSceneFilter.Visible = TxtSceneFilter.Text.Length > 0; + LblClearFilter.Visible = TxtSceneFilter.Text.Length > 0; } /// diff --git a/Source/GrasscutterTools/Pages/PageSettings.cs b/Source/GrasscutterTools/Pages/PageSettings.cs index 3ff5778..7d5caaa 100644 --- a/Source/GrasscutterTools/Pages/PageSettings.cs +++ b/Source/GrasscutterTools/Pages/PageSettings.cs @@ -181,6 +181,7 @@ namespace GrasscutterTools.Pages FormMain.Instance.ResetPageTabOrders(); FormMain.Instance.UpdatePagesNav(); InitPageList(); + isChanged = true; } } } \ No newline at end of file