private void EscapeArgument()
 {
     textBoxOutput.Text = ArgumentParser.EscapeArgument(textBoxInput.Text);
 }
        public ArgumentParserForm()
        {
            Icon = Properties.Resources.Icon;

            textBoxClicks      = 0;
            textBoxClicksTimer = new Timer();

            argumentParser = new ArgumentParser();

            InitializeComponent();
            Text = Program.GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Text;

            statusBarPanel = new StatusBarPanel()
            {
                BorderStyle = StatusBarPanelBorderStyle.Sunken,
                AutoSize    = StatusBarPanelAutoSize.Spring,
                Alignment   = HorizontalAlignment.Left
            };
            statusBar.Panels.Add(statusBarPanel);

            statusBarPanelCapsLock = new StatusBarPanel()
            {
                BorderStyle = StatusBarPanelBorderStyle.Sunken,
                Alignment   = HorizontalAlignment.Center,
                Width       = 42
            };
            statusBar.Panels.Add(statusBarPanelCapsLock);

            statusBarPanelNumLock = new StatusBarPanel()
            {
                BorderStyle = StatusBarPanelBorderStyle.Sunken,
                Alignment   = HorizontalAlignment.Center,
                Width       = 42
            };
            statusBar.Panels.Add(statusBarPanelNumLock);

            statusBarPanelInsert = new StatusBarPanel()
            {
                BorderStyle = StatusBarPanelBorderStyle.Sunken,
                Alignment   = HorizontalAlignment.Center,
                Width       = 42
            };
            statusBar.Panels.Add(statusBarPanelInsert);

            statusBarPanelScrollLock = new StatusBarPanel()
            {
                BorderStyle = StatusBarPanelBorderStyle.Sunken,
                Alignment   = HorizontalAlignment.Center,
                Width       = 42
            };
            statusBar.Panels.Add(statusBarPanelScrollLock);

            statusBar.ContextMenu = new ContextMenu();
            statusBar.ContextMenu.MenuItems.Add(new MenuItem(Properties.Resources.MenuItemCopy, new EventHandler((sender, e) => {
                if (!string.IsNullOrEmpty(statusBarPanel.Text))
                {
                    try {
                        Clipboard.SetText(statusBarPanel.Text);
                    } catch (Exception exception) {
                        Debug.WriteLine(exception);
                        ErrorLog.WriteLine(exception);
                    }
                }
            })));
            statusBar.ContextMenu.Popup += new EventHandler((sender, e) => {
                ((ContextMenu)sender).MenuItems[0].Visible = !string.IsNullOrEmpty(statusBarPanel.Text);
            });

            SubscribeEvents();

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("/c ");
            stringBuilder.Append(ArgumentParser.EscapeArgument(Constants.ExampleCaption));
            stringBuilder.Append(" /t ");
            stringBuilder.Append(ArgumentParser.EscapeArgument(Constants.ExampleText));
            stringBuilder.Append(" /b 7 /i 8 /d 2 /e /m 0 /w /s /o ");
            stringBuilder.Append(ArgumentParser.EscapeArgument(Constants.ExampleOutputFilePath));
            textBox1.Text = stringBuilder.ToString();

            textBoxInput.Text = Constants.ExampleOutputFilePath;
        }
Beispiel #3
0
        private string GenerateCode()
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (showMessageBox)
            {
                stringBuilder.Append(Constants.CodeGeneratorMsgBoxInst);
                if (setParent)
                {
                    stringBuilder.Append(Constants.CodeGeneratorThis);
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                }
                stringBuilder.Append(string.IsNullOrEmpty(text) ? Constants.CodeGeneratorNull : ArgumentParser.EscapeArgument(text));
                if (!string.IsNullOrEmpty(caption) || boxButtons > 0 || boxIcon > 0 || boxDefaultButton > 0)
                {
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                    stringBuilder.Append(string.IsNullOrEmpty(caption) ? Constants.CodeGeneratorNull : ArgumentParser.EscapeArgument(caption));
                }
                if (boxButtons > 0 || boxIcon > 0 || formDefaultButton > 0)
                {
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                    stringBuilder.Append(string.Join(".", new string[] { typeof(MessageBoxButtons).Name, boxButtons.ToString() }));
                }
                if (boxIcon > 0 || formDefaultButton > 0)
                {
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                    stringBuilder.Append(string.Join(".", new string[] { typeof(MessageBoxIcon).Name, boxIcon.ToString() }));
                }
                if (boxDefaultButton > 0)
                {
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                    stringBuilder.Append(string.Join(".", new string[] { typeof(MessageBoxDefaultButton).Name, boxDefaultButton.ToString() }));
                }
                stringBuilder.Append(Constants.CodeGeneratorEndBracketAndSemicolon);
            }
            else
            {
                stringBuilder.Append(Constants.CodeGeneratorMsgFormInst);
                if (setParent)
                {
                    stringBuilder.Append(Constants.CodeGeneratorThis);
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                }
                stringBuilder.Append(string.IsNullOrEmpty(text) ? Constants.CodeGeneratorNull : ArgumentParser.EscapeArgument(text));
                if (!string.IsNullOrEmpty(caption) || formButtons > 0 || formBoxIcon > 0 || formDefaultButton > 0 || centerScreen || showHelpButton || maximumWidth > 0 && maximumWidth != MessageForm.defaultWidth || noWrap)
                {
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                    stringBuilder.Append(string.IsNullOrEmpty(caption) ? Constants.CodeGeneratorNull : ArgumentParser.EscapeArgument(caption));
                }
                if (formButtons > 0 || formBoxIcon > 0 || formDefaultButton > 0 || centerScreen || showHelpButton || maximumWidth > 0 && maximumWidth != MessageForm.defaultWidth || noWrap)
                {
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                    stringBuilder.Append(string.Join(".", new string[] { typeof(MessageForm.Buttons).Namespace, typeof(MessageForm.Buttons).Name, formButtons.ToString() }));
                }
                if (formBoxIcon > 0 || formDefaultButton > 0 || centerScreen || showHelpButton || maximumWidth > 0 && maximumWidth != MessageForm.defaultWidth || noWrap)
                {
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                    stringBuilder.Append(string.Join(".", new string[] { typeof(MessageForm.BoxIcon).Namespace, typeof(MessageForm.BoxIcon).Name, formBoxIcon.ToString() }));
                }
                if (formDefaultButton > 0 || centerScreen || showHelpButton || maximumWidth > 0 && maximumWidth != MessageForm.defaultWidth || noWrap)
                {
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                    stringBuilder.Append(string.Join(".", new string[] { typeof(MessageForm.DefaultButton).Namespace, typeof(MessageForm.DefaultButton).Name, formDefaultButton.ToString() }));
                }
                if (centerScreen || showHelpButton || maximumWidth > 0 && maximumWidth != MessageForm.defaultWidth || noWrap)
                {
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                    stringBuilder.Append(centerScreen.ToString().ToLowerInvariant());
                }
                if (showHelpButton || maximumWidth > 0 && maximumWidth != MessageForm.defaultWidth || noWrap)
                {
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                    stringBuilder.Append(showHelpButton.ToString().ToLowerInvariant());
                }
                if (maximumWidth > 0 && maximumWidth != MessageForm.defaultWidth || noWrap)
                {
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                    stringBuilder.Append(maximumWidth > 0 && maximumWidth != MessageForm.defaultWidth ? maximumWidth.ToString() : 0.ToString());
                }
                if (noWrap)
                {
                    stringBuilder.Append(Constants.CodeGeneratorCommaAndSpace);
                    stringBuilder.Append(noWrap.ToString().ToLowerInvariant());
                }
                stringBuilder.AppendLine(Constants.CodeGeneratorEndBracketAndSemicolon);
                stringBuilder.Append(Constants.CodeGeneratorMsgFormShowDlg);
                if (setParent)
                {
                    stringBuilder.Append(Constants.CodeGeneratorThis);
                }
                stringBuilder.Append(Constants.CodeGeneratorEndBracketAndSemicolon);
            }
            return(stringBuilder.ToString());
        }