public void EditMacro() { ProgramPathContainer pcc = ToolMacros.GetProgramPathContainer(textCommand.Text); using (var dlg = new LocateFileDlg(pcc)) { dlg.ShowDialog(); } }
// 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(); } }
private void TestToolDirMacro() { string path1 = TestFilesDir.GetTestPath("TestToolDirMacro.zip"); RunDlg <ConfigureToolsDlg>(SkylineWindow.ShowConfigureToolsDlg, configureToolsDlg => { configureToolsDlg.RemoveAllTools(); configureToolsDlg.InstallZipTool(path1); Assert.AreEqual("TestToolDirMacro", configureToolsDlg.textTitle.Text); Assert.AreEqual("$(ToolDir)\\HelloWorld.exe", configureToolsDlg.textCommand.Text); Assert.AreEqual("$(ToolDir)\\MSStatsDSS.r", configureToolsDlg.textArguments.Text); Assert.AreEqual(string.Empty, configureToolsDlg.textInitialDirectory.Text); Assert.AreEqual(CheckState.Unchecked, configureToolsDlg.cbOutputImmediateWindow.CheckState); Assert.AreEqual(string.Empty, configureToolsDlg.comboReport.SelectedItem); configureToolsDlg.PopulateListMacroArguments(); string toolDir = configureToolsDlg.ToolDir; string macroToolDir = configureToolsDlg.GetMacroArgumentToolTip(Resources.ToolMacros__listArguments_Tool_Directory); Assert.AreEqual(toolDir, macroToolDir); string inputReportTempPath = configureToolsDlg.GetMacroArgumentToolTip( Resources.ToolMacros__listArguments_Input_Report_Temp_Path); Assert.AreEqual(inputReportTempPath, Resources.ConfigureToolsDlg_PopulateMacroDropdown_File_path_to_a_temporary_report); configureToolsDlg.SaveTools(); ToolDescription tool = Settings.Default.ToolList[0]; Assert.AreEqual(tool.Title, configureToolsDlg.textTitle.Text); Assert.AreEqual(tool.ToolDirPath, toolDir); string expectedcommand = configureToolsDlg.textCommand.Text.Replace("$(ToolDir)", toolDir); string command = ToolMacros.ReplaceMacrosCommand(SkylineWindow.Document, SkylineWindow, tool, SkylineWindow); Assert.AreEqual(expectedcommand, command); string expectedArgument = configureToolsDlg.textArguments.Text.Replace("$(ToolDir)", toolDir); string arguments = ToolMacros.ReplaceMacrosArguments(SkylineWindow.Document, SkylineWindow, tool, SkylineWindow); Assert.AreEqual(expectedArgument, arguments); configureToolsDlg.RemoveAllTools(); configureToolsDlg.OkDialog(); }); }
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); }