/// <summary> /// Called when the user presses the Test regex button. /// We must show a modal dialog allowing the user to test /// the regex and optionally modify it. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event arguments.</param> private void TestRegexBtn_Click(object sender, EventArgs e) { // Grab content of controls so that the tester form // can optionally modify them. string regex = RegexTxt.Text; string format = $"${(element.Group != 0 ? element.Group.ToString(CultureInfo.InvariantCulture) : "&")}"; bool ignoreCase = IgnoreCaseChk.Checked; // Show form and ask user to test. See what happens. using (RegexTesterForm testerForm = new RegexTesterForm()) { DialogResult res = testerForm.TestRegex(ref regex, ref format, ref ignoreCase, this); if (res == DialogResult.OK) { // User pressed OK which means we have updated values. RegexTxt.Text = regex; IgnoreCaseChk.Checked = ignoreCase; } } }
/// <summary> /// Called when the user presses the button to test a regular expression. /// We will show a dialog allowing the user to test the currently-provided /// expression and optionally change it. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event arguments.</param> private void TestBtn_Click(object sender, EventArgs e) { // Grab content of controls so that the tester form // can optionally modify them. string regex = FindTxt.Text; string format = ReplaceTxt.Text; bool ignoreCase = IgnoreCaseChk.Checked; // Show form and ask user to test. See what happens. using (RegexTesterForm testerForm = new RegexTesterForm()) { DialogResult res = testerForm.TestRegex(ref regex, ref format, ref ignoreCase, this); if (res == DialogResult.OK) { // User pressed OK which means we have updated values. FindTxt.Text = regex; ReplaceTxt.Text = format; IgnoreCaseChk.Checked = ignoreCase; } } }