diff --git a/LangEditor/LangEdit.Designer.cs b/LangEditor/LangEdit.Designer.cs index 5db5f66..d87be21 100644 --- a/LangEditor/LangEdit.Designer.cs +++ b/LangEditor/LangEdit.Designer.cs @@ -29,6 +29,8 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { dgvMain = new System.Windows.Forms.DataGridView(); + colID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + colString = new System.Windows.Forms.DataGridViewTextBoxColumn(); statusStrip1 = new System.Windows.Forms.StatusStrip(); menuStrip1 = new System.Windows.Forms.MenuStrip(); fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -38,10 +40,9 @@ private void InitializeComponent() applyChangesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); findToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + findNextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); hashToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - colID = new System.Windows.Forms.DataGridViewTextBoxColumn(); - colString = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)dgvMain).BeginInit(); menuStrip1.SuspendLayout(); SuspendLayout(); @@ -54,11 +55,22 @@ private void InitializeComponent() dgvMain.Dock = System.Windows.Forms.DockStyle.Fill; dgvMain.Location = new System.Drawing.Point(0, 24); dgvMain.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + dgvMain.MultiSelect = false; dgvMain.Name = "dgvMain"; dgvMain.Size = new System.Drawing.Size(484, 382); dgvMain.TabIndex = 0; dgvMain.RowsAdded += dgvMain_RowsAdded; // + // colID + // + colID.HeaderText = "ID"; + colID.Name = "colID"; + // + // colString + // + colString.HeaderText = "String"; + colString.Name = "colString"; + // // statusStrip1 // statusStrip1.Location = new System.Drawing.Point(0, 406); @@ -113,7 +125,7 @@ private void InitializeComponent() // // editToolStripMenuItem // - editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { findToolStripMenuItem }); + editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { findToolStripMenuItem, findNextToolStripMenuItem }); editToolStripMenuItem.Name = "editToolStripMenuItem"; editToolStripMenuItem.Size = new System.Drawing.Size(39, 20); editToolStripMenuItem.Text = "Edit"; @@ -122,10 +134,19 @@ private void InitializeComponent() // findToolStripMenuItem.Name = "findToolStripMenuItem"; findToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F; - findToolStripMenuItem.Size = new System.Drawing.Size(137, 22); + findToolStripMenuItem.Size = new System.Drawing.Size(195, 22); findToolStripMenuItem.Text = "Find"; findToolStripMenuItem.Click += findToolStripMenuItem_Click; // + // findNextToolStripMenuItem + // + findNextToolStripMenuItem.Enabled = false; + findNextToolStripMenuItem.Name = "findNextToolStripMenuItem"; + findNextToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift | System.Windows.Forms.Keys.F; + findNextToolStripMenuItem.Size = new System.Drawing.Size(195, 22); + findNextToolStripMenuItem.Text = "Find next"; + findNextToolStripMenuItem.Click += findNextToolStripMenuItem_Click; + // // toolsToolStripMenuItem // toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { hashToolStripMenuItem }); @@ -140,16 +161,6 @@ private void InitializeComponent() hashToolStripMenuItem.Text = "Hash"; hashToolStripMenuItem.Click += hashToolStripMenuItem_Click; // - // colID - // - colID.HeaderText = "ID"; - colID.Name = "colID"; - // - // colString - // - colString.HeaderText = "String"; - colString.Name = "colString"; - // // LangEdit // AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -185,5 +196,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem applyChangesToolStripMenuItem; private System.Windows.Forms.DataGridViewTextBoxColumn colID; private System.Windows.Forms.DataGridViewTextBoxColumn colString; + private System.Windows.Forms.ToolStripMenuItem findNextToolStripMenuItem; } } diff --git a/LangEditor/LangEdit.cs b/LangEditor/LangEdit.cs index 43d893d..f228fab 100644 --- a/LangEditor/LangEdit.cs +++ b/LangEditor/LangEdit.cs @@ -15,6 +15,7 @@ public partial class LangEdit : Form, IEntryEditor private bool _ignoreChanges; + private string searchVal; private Dictionary dict; private Language _lang; public Language Lang @@ -185,7 +186,7 @@ private void importToolStripMenuItem_Click(object sender, EventArgs e) pair[1] = pair[1].Replace("\"\"", "\""); // Convert double quotes pair[1] = pair[1].Replace("\\r", "\xD").Replace("\\n", "\xA"); // Convert newlines } - + data.Add(key, pair[1]); } @@ -241,6 +242,8 @@ private void findToolStripMenuItem_Click(object sender, EventArgs e) string value = InputDialog.ShowInput(this, "Please enter the value to search for."); if (value == null) return; + searchVal = value; + findNextToolStripMenuItem.Enabled = true; foreach (DataGridViewRow row in dgvMain.Rows) { @@ -257,6 +260,31 @@ private void findToolStripMenuItem_Click(object sender, EventArgs e) MessageBox.Show(this, "Hash not found!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } + private void findNextToolStripMenuItem_Click(object sender, EventArgs e) + { + if (searchVal == null) + return; + int start = dgvMain.SelectedCells[0].RowIndex + 1; + if (start > dgvMain.Rows.Count - 1) + { + MessageBox.Show(this, "Hash not found!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + for (int i = start; i < dgvMain.Rows.Count - 1; ++i) + { + if (((string)dgvMain.Rows[i].Cells[0].Value).Contains(searchVal, StringComparison.CurrentCultureIgnoreCase) + || ((string)dgvMain.Rows[i].Cells[1].Value).Contains(searchVal, StringComparison.CurrentCultureIgnoreCase)) + { + dgvMain.ClearSelection(); + dgvMain.CurrentCell = dgvMain.Rows[i].Cells[0]; + dgvMain.Rows[i].Selected = true; + return; + } + } + + MessageBox.Show(this, "Hash not found!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + private void hashToolStripMenuItem_Click(object sender, EventArgs e) { string value = InputDialog.ShowInput(this, "Please enter the value to hash.");