Exemplo n.º 1
0
        /// <summary>
        /// Shows the regular expression test window.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItemRegexTester_Click(object sender, RoutedEventArgs e)
        {
            var win = new RegexTestWindow
            {
                Owner = App.MainWindow,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                CancelButtonText      = "Close",
                SaveButtonVisible     = false
            };

            win.Show();
        }
        /// <summary>
        /// Shows the regular expression test window.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItemRegexTester_Click(object sender, RoutedEventArgs e)
        {
            // Set the initial text for the editor.
            var win = new RegexTestWindow();

            // Startup position of the dialog should be in the center of the parent window.  The
            // owner has to be set for this to work.
            win.Owner = App.MainWindow;
            win.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            win.CancelButtonText      = "Close";
            win.SaveButtonVisible     = false;

            // Show the Lua dialog.
            win.ShowDialog();
        }
        /// <summary>
        /// The ability to send the selected text in the terminal to the regular expression tester.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItemTestSelectionRegEx_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var item  = sender as MenuItem;
                var cm    = (ContextMenu)item?.Parent;
                var popup = (Popup)cm?.Parent;

                var terminal = popup?.PlacementTarget as AvalonTerminal;

                if (terminal == null)
                {
                    return;
                }

                // Set the initial text for the editor.
                // Startup position of the dialog should be in the center of the parent window.  The
                // owner has to be set for this to work.
                var win = new RegexTestWindow
                {
                    Owner = App.MainWindow,
                    WindowStartupLocation = WindowStartupLocation.CenterOwner,
                    CancelButtonText      = "Close",
                    SaveButtonVisible     = false
                };

                // Remove any ANSI codes from the selected text.
                var sb = new StringBuilder(terminal.SelectedText);
                Colorizer.RemoveAllAnsiCodes(sb);
                win.Pattern = sb.ToString();
                win.EscapePattern();
                win.TextBoxTest1.SetText(sb.ToString());

                // Show the Lua dialog.
                win.ShowDialog();
            }
            catch (Exception ex)
            {
                this.Interp.Conveyor.EchoLog(ex.Message, Common.Models.LogType.Error);

                if (!string.IsNullOrWhiteSpace(ex.StackTrace))
                {
                    this.Interp.Conveyor.EchoLog(ex.StackTrace, Common.Models.LogType.Error);
                }
            }
        }