Skip to content

Commit

Permalink
Merge pull request #37 from burninrubber0/lang-finder
Browse files Browse the repository at this point in the history
Add "find next" to language editor
  • Loading branch information
burninrubber0 authored May 6, 2023
2 parents 7d7e286 + bab9544 commit e115f7c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 15 deletions.
40 changes: 26 additions & 14 deletions LangEditor/LangEdit.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 29 additions & 1 deletion LangEditor/LangEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public partial class LangEdit : Form, IEntryEditor

private bool _ignoreChanges;

private string searchVal;
private Dictionary<uint, string> dict;
private Language _lang;
public Language Lang
Expand Down Expand Up @@ -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]);
}

Expand Down Expand Up @@ -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)
{
Expand All @@ -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.");
Expand Down

0 comments on commit e115f7c

Please sign in to comment.