private void LaunchApplication(ref int i, SubApplication subApplication) { Process p; // Check if application is already open Process[] processName = Process.GetProcessesByName(subApplication.Exe.Replace(".exe", "")); try { if (processName.Length == 0) { p = new Process(); p.StartInfo.FileName = subApplication.InstallPath + subApplication.Exe; p.Start(); i += 1; } } catch (Win32Exception) { MessageBox.Show(subApplication.Name + " could not be started.\n\n- Check that application is installed correctly.\n- Check that the 'install path' in the configuration XML file is valid.", "Check Installation", MessageBoxButton.OK, MessageBoxImage.Error); //throw; } }
public void AddNewApplication() { if (SelectedApplication != null) { Class.SubApplication subApp = new SubApplication(); subApp.Setup("New App", "<path>", "<exe>", false, true, true, SelectedApplication.Name); SelectedApplication.SubItems.Add(subApp); SelectedApplication = subApp; } else { Class.TopApplication topApp = new TopApplication(); topApp.Setup("New Top App", true); ApplicationsCollection.Add(topApp); SelectedApplication = topApp; } }
private void OpeningSubApplications(int i, SubApplication application) { try { foreach (SubApplication subApplication in application.SubItems) { if (subApplication.IsSelected == true) { LaunchApplication(ref i, subApplication); } if (subApplication.SubItems.Any()) { OpeningSubApplications(i, subApplication); } } } catch (Exception) { MessageBox.Show("Executable is missing from install directory.\n\nCheck the executable paths in the configuration XML file.", "Executable Missing", MessageBoxButton.OK, MessageBoxImage.Error); } }