private void Replace_Button_Click(object sender, EventArgs e) { if (Find_TB.Text.Length <= 0) { MessageBox.Show("You didn't enter anything to search for. Please Try Again"); } if (Replace_TB.Text.Length <= 0) { MessageBox.Show("You didn't enter anything to replace with. Please Try Again"); } if (Option1_CB.Checked) { Editor_TextBox.Text = Editor_TextBox.Text.Replace(Find_TB.Text, Replace_TB.Text); } else { if (!searchPhrase_selected) { MessageBox.Show("You need to find something before you can try replacing it..."); } else { Editor_TextBox.Focus(); ReplaceText(); } } }
private void LintPanel_MouseClick(object sender, MouseEventArgs e) { if (jsonError) { try { string error = JSON_Reader.GetJSON_Error(Editor_TextBox.Text); ConsoleHandler.force_append_Notice(error); //Line number string[] split = error.Split(','); string[] line = split[split.Length - 2].Split(' '); int lineNumber = Int32.Parse(line[line.Length - 1].Replace(".", "").Replace(",", "")); //Position in line string[] pos = split[split.Length - 1].Split(' '); int linePos = Int32.Parse(pos[pos.Length - 1].Replace(".", "").Replace(",", "")); //Scroll to the line above error int index = Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 3) + linePos; Editor_TextBox.Select(index, 1); Editor_TextBox.ScrollToCaret(); int numChars = (Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 1)) - (Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 2)); //highlight line with error index = Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 2) + linePos; Editor_TextBox.Focus(); Editor_TextBox.Select(index, numChars - 2); } catch { ConsoleHandler.append_CanRepeat("Something went wrong... Unable to find the bad json"); } } }
private void Find_Button_Click(object sender, EventArgs e) { if (Find_TB.Text.Length > 0) { Editor_TextBox.Focus(); if (Option1_CB.Checked) { SearchForSubtask(); } else { FindText(); } } else { ConsoleHandler.append("You didn't enter anything to search"); } }
// //Find and replace stuff // #region Find and Replace stuff private void ShowSearchMenu(string op) { Editor_TextBox.Size = new Size(Editor_TextBox.Size.Width, Editor_TextBox.Size.Height - 40); tB_line.Size = new Size(tB_line.Size.Width, tB_line.Size.Height - 40); if (op == "find") { Find_TB.Location = new Point(Editor_TextBox.Width - 241, 5); Find_Button.Location = new Point(Editor_TextBox.Width - 321, 4); SearchOptions_Button.Location = new Point(Editor_TextBox.Width, 4); Find_TB.Visible = !Find_TB.Visible; Find_Button.Visible = !Find_Button.Visible; SearchOptions_Button.Visible = !SearchOptions_Button.Visible; if (Option1_CB.Text == "Replace all") { if (Option1_CB.Checked) { Option1_CB.Checked = false; } } Option1_CB.Text = "Subtask"; Option1_CB.Location = new Point(15, Option1_CB.Location.Y); Find_Panel.Visible = !Find_Panel.Visible; } if (op == "replace") { Find_TB.Visible = !Find_TB.Visible; Find_Button.Visible = !Find_Button.Visible; SearchOptions_Button.Visible = !SearchOptions_Button.Visible; Replace_TB.Visible = !Replace_TB.Visible; Replace_Button.Visible = !ShowReplaceMenu_Button.Visible; Replace_TB.Location = new Point(Editor_TextBox.Width - 241, 5); Replace_Button.Location = new Point(Editor_TextBox.Width - 321, 4); Find_TB.Location = new Point(Editor_TextBox.Width - 591, 5); Find_Button.Location = new Point(Editor_TextBox.Width - 671, 4); SearchOptions_Button.Location = new Point(Editor_TextBox.Width, 4); if (Option1_CB.Text == "Subtask") { if (Option1_CB.Checked) { Option1_CB.Checked = false; } } Option1_CB.Text = "Replace all"; Option1_CB.Location = new Point(10, Option1_CB.Location.Y); Find_Panel.Visible = !Find_Panel.Visible; } if (Find_TB.Visible) { Find_TB.Focus(); } else { Editor_TextBox.Focus(); } if (!Find_Panel.Visible) { Find_TB.Text = ""; Replace_TB.Text = ""; SearchOptions_Panel.Visible = false; Editor_TextBox.Size = new Size(Editor_TextBox.Size.Width, Editor_TextBox.Size.Height + 80); tB_line.Size = new Size(tB_line.Size.Width, tB_line.Size.Height + 80); } }