diff --git a/DisplayMagician/Program.cs b/DisplayMagician/Program.cs index 7166f47..6c2e722 100644 --- a/DisplayMagician/Program.cs +++ b/DisplayMagician/Program.cs @@ -132,26 +132,14 @@ namespace DisplayMagician { // This is the CreateProfile command app.Command(DisplayMagicianStartupAction.CreateProfile.ToString(), (createProfileCmd) => { - var argumentProfile = runProfileCmd.Argument("\"Profile_UUID\"", "(required) The UUID of the profile to run from those stored in the profile file.").IsRequired(); - argumentProfile.Validators.Add(new ProfileMustExistValidator()); - //description and help text of the command. createProfileCmd.Description = "Use this command to go directly to the create display profile screen."; createProfileCmd.OnExecute(() => { - try - { - // Lookup the profile - ProfileItem profileToUse = ProfileRepository.AllProfiles.Where(p => p.UUID.Equals(argumentProfile.Value)).First(); - - ApplyProfile(profileToUse); - return 0; - } - catch (Exception) - { - return 1; - } + Console.WriteLine("Starting up and creating a new Display Profile..."); + StartUpApplication(DisplayMagicianStartupAction.CreateProfile); + return 0; }); }); @@ -159,7 +147,7 @@ namespace DisplayMagician { { Console.WriteLine("Starting Normally..."); - StartUpNormally(); + StartUpApplication(); return 0; }); @@ -188,7 +176,7 @@ namespace DisplayMagician { return 0; } - private static void StartUpNormally() + private static void StartUpApplication(DisplayMagicianStartupAction startupAction = DisplayMagicianStartupAction.StartUpNormally) { @@ -280,8 +268,14 @@ namespace DisplayMagician { { Console.WriteLine($"Program/StartUpNormally exception 2: {ex.Message}: {ex.StackTrace} - {ex.InnerException}"); } + IPCService.GetInstance().Status = InstanceStatus.User; - Application.Run(new UIForms.MainForm()); + + // Run the program with normal startup + if (startupAction == DisplayMagicianStartupAction.StartUpNormally) + Application.Run(new MainForm()); + else if (startupAction == DisplayMagicianStartupAction.CreateProfile) + Application.Run(new DisplayProfileForm()); } catch (Exception ex) diff --git a/DisplayMagician/UIForms/MainForm.cs b/DisplayMagician/UIForms/MainForm.cs index 45b35db..6d9b92f 100644 --- a/DisplayMagician/UIForms/MainForm.cs +++ b/DisplayMagician/UIForms/MainForm.cs @@ -21,7 +21,7 @@ namespace DisplayMagician.UIForms private bool allowVisible; // ContextMenu's Show command used private bool allowClose; // ContextMenu's Exit command used - public MainForm() + public MainForm(Form formToOpen = null) { InitializeComponent(); btn_setup_display_profiles.Parent = splitContainer1.Panel1; @@ -52,6 +52,17 @@ namespace DisplayMagician.UIForms cb_minimise_notification_area.Checked = false; } + // If we've been handed a Form of some kind, then open it straight away + if (formToOpen is DisplayProfileForm) + { + var displayProfileForm = new DisplayProfileForm(); + displayProfileForm.ShowDialog(this); + } + else if (formToOpen is ShortcutLibraryForm) + { + var shortcutLibraryForm = new ShortcutLibraryForm(); + shortcutLibraryForm.ShowDialog(this); + } }