Fix UI issues

This commit is contained in:
2023-10-18 22:49:45 +08:00
parent 101e3c5ffc
commit f5780a4366
6 changed files with 62 additions and 63 deletions

View File

@ -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;
}
}

View File

@ -119,13 +119,12 @@ namespace GrasscutterTools.Forms
private void GenLines()
{
List<ListViewItem> items = new List<ListViewItem>(data.TextMap.Count);
var items = new List<ListViewItem>(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)
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,
Id = data.ManualTextMap.TryGetValue(kv.Key, out string id) ? id : "",
Text = kv.Value
})
).ToList();
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();
}

View File

@ -315,15 +315,6 @@
<data name="ColumnHash.Width" type="System.Int32, mscorlib">
<value>80</value>
</data>
<metadata name="ColumnID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="ColumnID.HeaderText" xml:space="preserve">
<value>ID</value>
</data>
<data name="ColumnID.Width" type="System.Int32, mscorlib">
<value>240</value>
</data>
<metadata name="ColumnText.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -333,6 +324,15 @@
<data name="ColumnText.Width" type="System.Int32, mscorlib">
<value>250</value>
</data>
<metadata name="ColumnID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="ColumnID.HeaderText" xml:space="preserve">
<value>ID</value>
</data>
<data name="ColumnID.Width" type="System.Int32, mscorlib">
<value>240</value>
</data>
<data name="DGVTextMap.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 70</value>
</data>
@ -420,18 +420,18 @@
<data name="&gt;&gt;ColumnHash.Type" xml:space="preserve">
<value>System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;ColumnID.Name" xml:space="preserve">
<value>ColumnID</value>
</data>
<data name="&gt;&gt;ColumnID.Type" xml:space="preserve">
<value>System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;ColumnText.Name" xml:space="preserve">
<value>ColumnText</value>
</data>
<data name="&gt;&gt;ColumnText.Type" xml:space="preserve">
<value>System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;ColumnID.Name" xml:space="preserve">
<value>ColumnID</value>
</data>
<data name="&gt;&gt;ColumnID.Type" xml:space="preserve">
<value>System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>FormTextMapBrowser</value>
</data>

View File

@ -274,7 +274,7 @@
<value>2</value>
</data>
<data name="TxtHotKey.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left, Right</value>
<value>Bottom, Right</value>
</data>
<data name="TxtHotKey.Location" type="System.Drawing.Point, System.Drawing">
<value>262, 210</value>
@ -301,7 +301,7 @@
<value>4</value>
</data>
<data name="LblHotKeyLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left, Right</value>
<value>Bottom, Right</value>
</data>
<data name="LblHotKeyLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>

View File

@ -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;
}
/// <summary>

View File

@ -181,6 +181,7 @@ namespace GrasscutterTools.Pages
FormMain.Instance.ResetPageTabOrders();
FormMain.Instance.UpdatePagesNav();
InitPageList();
isChanged = true;
}
}
}