Пример #1
0
        public void EditMacro()
        {
            ProgramPathContainer pcc = ToolMacros.GetProgramPathContainer(textCommand.Text);

            using (var dlg = new LocateFileDlg(pcc))
            {
                dlg.ShowDialog();
            }
        }
Пример #2
0
        // Cannot test methods below because of common dialogs

        private void btnFindCommand_Click(object sender, EventArgs e)
        {
            ProgramPathContainer pcc = ToolMacros.GetProgramPathContainer(textCommand.Text);

            if (pcc != null)
            {
                contextMenuCommand.Show(btnFindCommand.Parent, btnFindCommand.Left, btnFindCommand.Bottom + 1);
            }
            else
            {
                CommandBtnClick();
            }
        }
Пример #3
0
        private bool CheckPassToolInternal(int toolIndex)
        {
            ToolDescription tool;

            if (toolIndex < ToolList.Count && toolIndex >= 0)
            {
                tool = ToolList[toolIndex];
            }
            else
            {
                return(true);
            }
            if (tool.Title == string.Empty)
            {
                MessageDlg.Show(this, Resources.ConfigureToolsDlg_CheckPassTool_You_must_enter_a_valid_title_for_the_tool);
                textTitle.Focus();
                return(false);
            }
            //Ensure the tool Title is unique.
            if (!IsUniqueTitle(tool.Title))
            {
                MessageDlg.Show(this, Resources.ConfigureToolsDlg_CheckPassToolInternal_Tool_titles_must_be_unique__please_enter_a_unique_title_for_this_tool_);
                textTitle.Focus();
                return(false);
            }

            if (tool.Command == string.Empty)
            {
                MessageDlg.Show(this, string.Format(Resources.ConfigureToolsDlg_CheckPassTool_The_command_cannot_be_blank__please_enter_a_valid_command_for__0_, tool.Title));
                textCommand.Focus();
                return(false);
            }
            if (tool.IsWebPage)
            {
                try
                {
// ReSharper disable ObjectCreationAsStatement
                    new Uri(tool.Command);
// ReSharper restore ObjectCreationAsStatement
                }
                catch (Exception)
                {
                    MessageDlg.Show(this, Resources.ConfigureToolsDlg_CheckPassToolInternal_Please_specify_a_valid_URL_);
                    textCommand.Focus();
                    return(false);
                }

                return(true);
            }
            //If it is not a $(ProgramPath()) macro then do other checks.
            if (ToolMacros.GetProgramPathContainer(tool.Command) == null)
            {
                string supportedTypes = String.Join("; ", EXTENSIONS); // Not L10N
                supportedTypes = supportedTypes.Replace(".", "*.");    // Not L10N
                if (!CheckExtension(tool.Command))
                {
                    MessageDlg.Show(this, string.Format(TextUtil.LineSeparate(
                                                            Resources.ConfigureToolsDlg_CheckPassTool_The_command_for__0__must_be_of_a_supported_type,
                                                            Resources.ConfigureToolsDlg_CheckPassTool_Supported_Types___1_,
                                                            Resources.ConfigureToolsDlg_CheckPassTool_if_you_would_like_the_command_to_launch_a_link__make_sure_to_include_http____or_https___),
                                                        tool.Title, supportedTypes));
                    textCommand.Focus();
                    return(false);
                }
                string adjustedCommand = tool.Command;
                if (adjustedCommand.Contains(ToolMacros.TOOL_DIR))
                {
                    if (String.IsNullOrEmpty(tool.ToolDirPath))
                    {
                        MessageDlg.Show(this,
                                        Resources.ConfigureToolsDlg_CheckPassToolInternal__ToolDir__is_not_a_valid_macro_for_a_tool_that_was_not_installed_and_therefore_does_not_have_a_Tool_Directory_);
                        textCommand.Focus();
                        return(false);
                    }
                    else
                    {
                        adjustedCommand = adjustedCommand.Replace(ToolMacros.TOOL_DIR, tool.ToolDirPath);
                    }
                }
                if (!File.Exists(adjustedCommand))
                {
                    if (DialogResult.Yes == MultiButtonMsgDlg.Show(
                            this,
                            string.Format(TextUtil.LineSeparate(
                                              Resources.ConfigureToolsDlg_CheckPassTool__The_command_for__0__may_not_exist_in_that_location__Would_you_like_to_edit_it__,
                                              Resources.ConfigureToolsDlg_CheckPassTool__Note__if_you_would_like_the_command_to_launch_a_link__make_sure_to_include_http____or_https___),
                                          tool.Title),
                            MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false))
                    {
                        textCommand.Focus();
                        return(false);
                    }
                }
            }

            if (tool.Arguments.Contains(ToolMacros.INPUT_REPORT_TEMP_PATH) && string.IsNullOrEmpty(tool.ReportTitle))
            {
                MessageDlg.Show(this, TextUtil.LineSeparate(
                                    string.Format(Resources.ConfigureToolsDlg_CheckPassToolInternal_You_have_provided__0__as_an_argument_but_have_not_selected_a_report_, ToolMacros.INPUT_REPORT_TEMP_PATH),
                                    string.Format(Resources.ConfigureToolsDlg_CheckPassToolInternal_Please_select_a_report_or_remove__0__from_arguments_, ToolMacros.INPUT_REPORT_TEMP_PATH)));
                comboReport.Focus();
                return(false);
            }
            return(true);
        }