/// <summary> /// Confirms if the user wants to launch the selected /// app. If so, triggers an event to indicate that the user /// wants to launch the app. /// </summary> /// <param name="appInfo"></param> private void handleAppSelect(AppInfo appInfo) { if (DialogUtils.ConfirmScanner("Launch " + appInfo.Name + "?")) { if (EvtLaunchApp != null) { EvtLaunchApp.BeginInvoke(this, appInfo, null, null); } } }
/// <summary> /// Launch the specified app /// </summary> /// <param name="info">info about the app</param> /// <returns>true on success</returns> private bool launchProcess(AppInfo info) { bool retVal = true; var startInfo = new ProcessStartInfo { FileName = info.Path, Arguments = normalizeCommandLine(info.CommandLine) }; try { var process = Process.Start(startInfo); if (process == null) { retVal = false; } else { waitForProcessAndActivate(process); } } catch (Exception ex) { Log.Debug(ex.ToString()); retVal = false; } return retVal; }
/// <summary> /// Invoked when the Functional agent is activated. This is /// the entry point. /// </summary> /// <returns>true on success</returns> public override bool Activate() { ExitCode = CompletionCode.ContextSwitch; _appToLaunchInfo = null; _launchAppScanner = Context.AppPanelManager.CreatePanel("LaunchAppScanner") as LaunchAppScanner; if (_launchAppScanner != null) { _launchAppScanner.FormClosing += _form_FormClosing; _launchAppScanner.EvtQuit += _launchAppScanner_EvtQuit; _launchAppScanner.EvtLaunchApp += _launchAppScanner_EvtLaunchApp; _launchAppScanner.EvtShowScanner += launchAppScanner_EvtShowScanner; Context.AppPanelManager.ShowDialog(_launchAppScanner); } return true; }
/// <summary> /// Request came in to launch an app. Launch /// the specified application. After launching, /// the scanner and the agent are both closed. /// </summary> /// <param name="sender">event sender</param> /// <param name="appinfo">which app to launch</param> private void _launchAppScanner_EvtLaunchApp(object sender, AppInfo appInfo) { _appToLaunchInfo = appInfo; launchProcess(_appToLaunchInfo); closeScanner(); Close(); }
/// <summary> /// Confirms if the user wants to launch the selected /// app. If so, triggers an event to indicate that the user /// wants to launch the app. /// </summary> /// <param name="appInfo"></param> private void handleAppSelect(AppInfo appInfo) { if (DialogUtils.ConfirmScanner(string.Format(Resources.Launch0, appInfo.Name))) { if (EvtLaunchApp != null) { EvtLaunchApp.BeginInvoke(this, appInfo, null, null); } } }