Example #1
0
        private void OkButtonState()
        {
            // Assume OK
            buttonOk.Enabled              = true;
            textBox_name.BackColor        = Color.White;
            textBox_commandline.BackColor = Color.White;
            textBox_arguments.BackColor   = Color.White;
            // Is there a text in the name field
            if (string.IsNullOrEmpty(textBox_name.Text))
            {
                buttonOk.Enabled = false;
            }
            // Check if commandname is unique
            if (_commando == null && !string.IsNullOrEmpty(textBox_name.Text) && ExternalCommandConfig.Commands.Contains(textBox_name.Text))
            {
                buttonOk.Enabled       = false;
                textBox_name.BackColor = Color.Red;
            }
            // Is there a text in the commandline field
            if (string.IsNullOrEmpty(textBox_commandline.Text))
            {
                buttonOk.Enabled = false;
            }

            if (!string.IsNullOrEmpty(textBox_commandline.Text))
            {
                // Added this to be more flexible, using the Greenshot var format
                string cmdPath = FilenameHelper.FillVariables(textBox_commandline.Text, true);
                // And also replace the "DOS" Variables
                cmdPath = FilenameHelper.FillCmdVariables(cmdPath, true);
                // Is the command available?
                if (!File.Exists(cmdPath))
                {
                    buttonOk.Enabled = false;
                    textBox_commandline.BackColor = Color.Red;
                }
            }
            // Are the arguments in a valid format?
            try
            {
                string arguments = FilenameHelper.FillVariables(textBox_arguments.Text, false);
                arguments = FilenameHelper.FillCmdVariables(arguments, false);

                ExternalCommandDestination.FormatArguments(arguments, string.Empty);
            }
            catch
            {
                buttonOk.Enabled            = false;
                textBox_arguments.BackColor = Color.Red;
            }
        }
Example #2
0
 private void OKButtonState()
 {
     // Assume OK
     buttonOk.Enabled              = true;
     textBox_name.BackColor        = Color.White;
     textBox_commandline.BackColor = Color.White;
     textBox_arguments.BackColor   = Color.White;
     // Is there a text in the name field
     if (string.IsNullOrEmpty(textBox_name.Text))
     {
         buttonOk.Enabled = false;
     }
     // Check if commandname is unique
     if (commando == null && !string.IsNullOrEmpty(textBox_name.Text) && config.commands.Contains(textBox_name.Text))
     {
         buttonOk.Enabled       = false;
         textBox_name.BackColor = Color.Red;
     }
     // Is there a text in the commandline field
     if (string.IsNullOrEmpty(textBox_commandline.Text))
     {
         buttonOk.Enabled = false;
     }
     // Is the command available?
     if (!string.IsNullOrEmpty(textBox_commandline.Text) && !File.Exists(textBox_commandline.Text))
     {
         buttonOk.Enabled = false;
         textBox_commandline.BackColor = Color.Red;
     }
     // Are the arguments in a valid format?
     try
     {
         ExternalCommandDestination.FormatArguments(textBox_arguments.Text, string.Empty);
     }
     catch
     {
         buttonOk.Enabled            = false;
         textBox_arguments.BackColor = Color.Red;
     }
 }