From d61ef575187340e1dc752354a121b1f3db2c240c Mon Sep 17 00:00:00 2001 From: ArtUrlWWW Date: Sun, 25 Jun 2017 13:47:59 +0300 Subject: [PATCH 1/2] V. 10.1 - Reworked context menu - more usable for editing cells in Editor. --- Source/AboutEditorForm.resx | 2 +- Source/Editor.Designer.cs | 34 +++++++----- Source/Editor.cs | 53 +++++++++++-------- Source/Editor.resx | 86 +++++++++++++++++-------------- Source/Properties/AssemblyInfo.cs | 4 +- 5 files changed, 101 insertions(+), 78 deletions(-) diff --git a/Source/AboutEditorForm.resx b/Source/AboutEditorForm.resx index 0f3fa57..247ee6c 100644 --- a/Source/AboutEditorForm.resx +++ b/Source/AboutEditorForm.resx @@ -136,7 +136,7 @@ 1 - Version 10.0 by ArtUrlWWW + Version 10.1 by ArtUrlWWW MiddleCenter diff --git a/Source/Editor.Designer.cs b/Source/Editor.Designer.cs index 3969450..4ca2dbb 100644 --- a/Source/Editor.Designer.cs +++ b/Source/Editor.Designer.cs @@ -30,7 +30,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Editor)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -42,7 +42,6 @@ private void InitializeComponent() this.label2 = new System.Windows.Forms.Label(); this.Paste_ALL_copied_values = new System.Windows.Forms.Button(); this.Show_copied_values = new System.Windows.Forms.Button(); - this.label3 = new System.Windows.Forms.Label(); this.Copy_Values_By_IDs = new System.Windows.Forms.Button(); this.Copy_selected_rows = new System.Windows.Forms.Button(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); @@ -50,6 +49,8 @@ private void InitializeComponent() this.copyThisRowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); + this.copySelectedRowsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.label3 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -66,8 +67,8 @@ private void InitializeComponent() this.Column2, this.Column3}); this.dataGridView1.Name = "dataGridView1"; - dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick); this.dataGridView1.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView1_CellMouseClick); this.dataGridView1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.dataGridView1_MouseClick); @@ -139,12 +140,6 @@ private void InitializeComponent() this.Show_copied_values.UseVisualStyleBackColor = true; this.Show_copied_values.Click += new System.EventHandler(this.Show_copied_values_Click); // - // label3 - // - resources.ApplyResources(this.label3, "label3"); - this.label3.Name = "label3"; - this.label3.Click += new System.EventHandler(this.label3_Click); - // // Copy_Values_By_IDs // resources.ApplyResources(this.Copy_Values_By_IDs, "Copy_Values_By_IDs"); @@ -163,7 +158,8 @@ private void InitializeComponent() // this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.deleteThisElementToolStripMenuItem, - this.copyThisRowToolStripMenuItem}); + this.copyThisRowToolStripMenuItem, + this.copySelectedRowsToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; resources.ApplyResources(this.contextMenuStrip1, "contextMenuStrip1"); // @@ -189,15 +185,26 @@ private void InitializeComponent() resources.ApplyResources(this.label5, "label5"); this.label5.Name = "label5"; // + // copySelectedRowsToolStripMenuItem + // + this.copySelectedRowsToolStripMenuItem.Name = "copySelectedRowsToolStripMenuItem"; + resources.ApplyResources(this.copySelectedRowsToolStripMenuItem, "copySelectedRowsToolStripMenuItem"); + this.copySelectedRowsToolStripMenuItem.Click += new System.EventHandler(this.copySelectedRowsToolStripMenuItem_Click); + // + // label3 + // + resources.ApplyResources(this.label3, "label3"); + this.label3.Name = "label3"; + // // Editor // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.Controls.Add(this.label3); this.Controls.Add(this.label5); this.Controls.Add(this.label4); this.Controls.Add(this.Copy_selected_rows); this.Controls.Add(this.Copy_Values_By_IDs); - this.Controls.Add(this.label3); this.Controls.Add(this.Show_copied_values); this.Controls.Add(this.Paste_ALL_copied_values); this.Controls.Add(this.label2); @@ -228,7 +235,6 @@ private void InitializeComponent() private System.Windows.Forms.Label label2; private System.Windows.Forms.Button Paste_ALL_copied_values; private System.Windows.Forms.Button Show_copied_values; - private System.Windows.Forms.Label label3; private System.Windows.Forms.Button Copy_Values_By_IDs; private System.Windows.Forms.Button Copy_selected_rows; private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; @@ -236,5 +242,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem copyThisRowToolStripMenuItem; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; + private System.Windows.Forms.ToolStripMenuItem copySelectedRowsToolStripMenuItem; + private System.Windows.Forms.Label label3; } } \ No newline at end of file diff --git a/Source/Editor.cs b/Source/Editor.cs index 2cf749c..0ea0750 100644 --- a/Source/Editor.cs +++ b/Source/Editor.cs @@ -199,27 +199,27 @@ private void Show_copied_values_Click(object sender, EventArgs e) private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { - if (dataGridView1.SelectedRows.Count > 0) - { - if (e.Button == MouseButtons.Left) - { - //if (addstr != null) - //{ - // addstr.setFldsValues(MainUI.strHolders[listView1.SelectedIndices[0]]); - //} - } - else - { - CopySelectedRows(); - } - } + //if (dataGridView1.SelectedRows.Count > 0) + //{ + // if (e.Button == MouseButtons.Left) + // { + // //if (addstr != null) + // //{ + // // addstr.setFldsValues(MainUI.strHolders[listView1.SelectedIndices[0]]); + // //} + // } + // else + // { + // CopySelectedRows(); + // } + //} } - private void label3_Click(object sender, EventArgs e) - { - HowToCopyMultipleRows a = new HowToCopyMultipleRows(); - a.ShowDialog(); - } + //private void label3_Click(object sender, EventArgs e) + //{ + // HowToCopyMultipleRows a = new HowToCopyMultipleRows(); + // a.ShowDialog(); + //} private void Copy_Values_By_IDs_Click(object sender, EventArgs e) { @@ -300,7 +300,7 @@ private static DialogResult ShowInputDialog(ref string input) private void Copy_selected_rows_Click(object sender, EventArgs e) { - CopySelectedRows(); + //CopySelectedRows(); } private void CopySelectedRows() @@ -337,8 +337,12 @@ private void deleteThisElementToolStripMenuItem_Click(object sender, EventArgs e private void dataGridView1_MouseClick(object sender, MouseEventArgs e) { - contextMenuStrip1.Tag = dataGridView1.CurrentCell; - contextMenuStrip1.Show(dataGridView1, e.Location); + if (e.Button == MouseButtons.Right) + { + dataGridView1.CurrentCell.OwningRow.Selected = true; + contextMenuStrip1.Tag = dataGridView1.CurrentCell; + contextMenuStrip1.Show(dataGridView1, e.Location); + } } @@ -369,5 +373,10 @@ protected override bool ProcessDialogKey(Keys keyData) } return base.ProcessDialogKey(keyData); } + + private void copySelectedRowsToolStripMenuItem_Click(object sender, EventArgs e) + { + CopySelectedRows(); + } } } diff --git a/Source/Editor.resx b/Source/Editor.resx index 753cfc9..6f1c27e 100644 --- a/Source/Editor.resx +++ b/Source/Editor.resx @@ -286,7 +286,7 @@ NoControl - 681, 572 + 668, 595 341, 19 @@ -360,39 +360,6 @@ 6 - - Bottom, Right - - - True - - - NoControl - - - 473, 591 - - - 549, 19 - - - 7 - - - You can copy cells by selecting multiple rows and clicking Right Click. Click HERE for help. - - - label3 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 5 - 566, 492 @@ -415,7 +382,7 @@ $this - 4 + 5 390, 492 @@ -439,13 +406,13 @@ $this - 3 + 4 17, 17 - 176, 48 + 177, 70 contextMenuStrip1 @@ -454,13 +421,13 @@ System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 175, 22 + 176, 22 Delete this element - 175, 22 + 176, 22 Copy this row @@ -490,7 +457,7 @@ $this - 1 + 3 True @@ -520,6 +487,39 @@ $this + 2 + + + 176, 22 + + + Copy selected rows + + + True + + + 668, 572 + + + 328, 19 + + + 12 + + + Right click on some cell to show menu copy options. + + + label3 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 @@ -4022,6 +4022,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + copySelectedRowsToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + Editor diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index e9dbc03..3e06ee8 100644 --- a/Source/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("10.0.0.0")] -[assembly: AssemblyFileVersion("10.0.0.0")] +[assembly: AssemblyVersion("10.1.0.0")] +[assembly: AssemblyFileVersion("10.1.0.0")] From 6dbf1729347d3c5cdbdeef183ddd49abd35c0235 Mon Sep 17 00:00:00 2001 From: ArtUrlWWW Date: Sun, 25 Jun 2017 15:12:29 +0300 Subject: [PATCH 2/2] 10.2 - Improved Mass Insert - now it will not create duplicates with same IDs, but will update str values of the existing strings. --- Source/AboutEditorForm.resx | 2 +- Source/AddString.cs | 2 +- Source/Editor.cs | 10 ++++---- Source/MainUI.cs | 39 ++++++++++++++++++++++--------- Source/Properties/AssemblyInfo.cs | 4 ++-- Source/StringPicker.cs | 10 ++++---- 6 files changed, 42 insertions(+), 25 deletions(-) diff --git a/Source/AboutEditorForm.resx b/Source/AboutEditorForm.resx index 247ee6c..89477ba 100644 --- a/Source/AboutEditorForm.resx +++ b/Source/AboutEditorForm.resx @@ -136,7 +136,7 @@ 1 - Version 10.1 by ArtUrlWWW + Version 10.2 by ArtUrlWWW MiddleCenter diff --git a/Source/AddString.cs b/Source/AddString.cs index 23e384d..6ebfaf3 100644 --- a/Source/AddString.cs +++ b/Source/AddString.cs @@ -139,7 +139,7 @@ private void copyStrFldsValues_Click(object sender, EventArgs e) sh.textIDFld = textIDFld.Text; sh.displayTextFld = displayTextFld.Text; - MainUI.strHolders.Add(sh); + MainUI.copiedValuesStrHolders.Add(sh); } private void pasteStrFldsValues_Click(object sender, EventArgs e) diff --git a/Source/Editor.cs b/Source/Editor.cs index 0ea0750..fb3c26c 100644 --- a/Source/Editor.cs +++ b/Source/Editor.cs @@ -167,15 +167,15 @@ private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventA sh.textIDFld = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); sh.displayTextFld = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); - MainUI.strHolders.Add(sh); + MainUI.copiedValuesStrHolders.Add(sh); } } private void Paste_ALL_copied_values_Click(object sender, EventArgs e) { - for (int x = 0; x < MainUI.strHolders.Count; x++) + for (int x = 0; x < MainUI.copiedValuesStrHolders.Count; x++) { - StringHolder sh = MainUI.strHolders[x]; + StringHolder sh = MainUI.copiedValuesStrHolders[x]; DataTable dt = (DataTable)dataGridView1.DataSource; DataRow dr; @@ -311,7 +311,7 @@ private void CopySelectedRows() sh.textIDFld = dataGridView1.SelectedRows[x].Cells[0].Value.ToString(); sh.displayTextFld = dataGridView1.SelectedRows[x].Cells[1].Value.ToString(); - MainUI.strHolders.Add(sh); + MainUI.copiedValuesStrHolders.Add(sh); } MessageBox.Show(dataGridView1.SelectedRows.Count + " rows copied!"); @@ -354,7 +354,7 @@ private void copyThisRowToolStripMenuItem_Click(object sender, EventArgs e) sh.textIDFld = row.Cells[0].Value.ToString(); sh.displayTextFld = row.Cells[1].Value.ToString(); - MainUI.strHolders.Add(sh); + MainUI.copiedValuesStrHolders.Add(sh); } diff --git a/Source/MainUI.cs b/Source/MainUI.cs index c9f3d14..c624305 100644 --- a/Source/MainUI.cs +++ b/Source/MainUI.cs @@ -21,7 +21,7 @@ public partial class MainUI : Form private DataGridViewSettings settings0 = new DataGridViewSettings(); private DataGridViewSettings settings1 = new DataGridViewSettings(); - public static List strHolders = new List(); + public static List copiedValuesStrHolders = new List(); public MainUI() { @@ -375,6 +375,8 @@ private void closeAndSavePackage(bool save = true) SaveSTBLFile(true); } + fileNameLbl.Text = ""; + LanguageLbl.Text = ""; dataGridView1.DataSource = null; dataGridView1.Columns.Add("Column1", ""); @@ -421,7 +423,7 @@ private void showLangCodesToolStripMenuItem_Click(object sender, EventArgs e) private void multyInsertIntoFilesToolStripMenuItem_Click(object sender, EventArgs e) { - if (MainUI.strHolders.Count > 0) + if (MainUI.copiedValuesStrHolders.Count > 0) { isTextChanged = false; @@ -462,17 +464,31 @@ private void multyInsertIntoFilesToolStripMenuItem_Click(object sender, EventArg isTextChanged = true; - for (int x = 0; x < MainUI.strHolders.Count; x++) + for (int x = 0; x < MainUI.copiedValuesStrHolders.Count; x++) { - StringHolder sh = MainUI.strHolders[x]; + StringHolder copiedStrElement = MainUI.copiedValuesStrHolders[x]; DataTable dt = (DataTable)dataGridView1.DataSource; - DataRow dr; - dr = dt.NewRow(); - dr[0] = sh.textIDFld; - dr[1] = sh.displayTextFld; - dt.Rows.Add(dr); - dataGridView1.Rows[dataGridView1.Rows.Count - 1].HeaderCell.Value = (dataGridView1.Rows.Count).ToString(); + + var drArr = (from rowEl in dt.AsEnumerable() + where rowEl.Field(0) == copiedStrElement.textIDFld + select rowEl); + + if (drArr.Count() == 0) + { + DataRow dr = dt.NewRow(); + dr[0] = copiedStrElement.textIDFld; + dr[1] = copiedStrElement.displayTextFld; + dt.Rows.Add(dr); + dataGridView1.Rows[dataGridView1.Rows.Count - 1].HeaderCell.Value = (dataGridView1.Rows.Count).ToString(); + + } + else + { + DataRow dr = drArr.First(); + dr[1] = copiedStrElement.displayTextFld; + } + } @@ -484,7 +500,8 @@ private void multyInsertIntoFilesToolStripMenuItem_Click(object sender, EventArg isTextChanged = false; } - } else + } + else { MessageBox.Show("You have not copied any string. \r\nCopy strings and use this option for mass insert of copied strings into STBL files!"); } diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index 3e06ee8..8cece65 100644 --- a/Source/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("10.1.0.0")] -[assembly: AssemblyFileVersion("10.1.0.0")] +[assembly: AssemblyVersion("10.2.0.0")] +[assembly: AssemblyFileVersion("10.2.0.0")] diff --git a/Source/StringPicker.cs b/Source/StringPicker.cs index e630a50..4ac82dc 100644 --- a/Source/StringPicker.cs +++ b/Source/StringPicker.cs @@ -29,9 +29,9 @@ private void reloadListView() { listView1.Items.Clear(); listView1.View = View.List; - for (int x = 0; x < MainUI.strHolders.Count; x++) + for (int x = 0; x < MainUI.copiedValuesStrHolders.Count; x++) { - StringHolder sh = MainUI.strHolders[x]; + StringHolder sh = MainUI.copiedValuesStrHolders[x]; listView1.Items.Add(sh.textIDFld + " - " + sh.displayTextFld); } @@ -45,12 +45,12 @@ private void listView1_MouseClick(object sender, MouseEventArgs e) { if (addstr != null) { - addstr.setFldsValues(MainUI.strHolders[listView1.SelectedIndices[0]]); + addstr.setFldsValues(MainUI.copiedValuesStrHolders[listView1.SelectedIndices[0]]); } } else { - MainUI.strHolders.RemoveAt(listView1.SelectedIndices[0]); + MainUI.copiedValuesStrHolders.RemoveAt(listView1.SelectedIndices[0]); reloadListView(); } } @@ -60,7 +60,7 @@ private void listView1_MouseDoubleClick(object sender, MouseEventArgs e) { if (addstr != null) { - addstr.setFldsValues(MainUI.strHolders[listView1.SelectedIndices[0]]); + addstr.setFldsValues(MainUI.copiedValuesStrHolders[listView1.SelectedIndices[0]]); } this.Close();