Added new CreateProfile startup action

CreateProfile will just open a new DisplayProfile
window and that will be used only from the
Shell Extension.
This commit is contained in:
Terry MacDonald 2020-12-06 21:33:00 +13:00
parent 45e2c32c30
commit 9522af5574
2 changed files with 24 additions and 19 deletions

View File

@ -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);
Console.WriteLine("Starting up and creating a new Display Profile...");
StartUpApplication(DisplayMagicianStartupAction.CreateProfile);
return 0;
}
catch (Exception)
{
return 1;
}
});
});
@ -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)

View File

@ -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);
}
}