diff --git a/DisplayMagician/DisplayMagician.csproj b/DisplayMagician/DisplayMagician.csproj index 3757afb..611c7a9 100644 --- a/DisplayMagician/DisplayMagician.csproj +++ b/DisplayMagician/DisplayMagician.csproj @@ -232,6 +232,9 @@ 1.6.4 + + 1.2.0 + 2.8.0.16 @@ -239,7 +242,7 @@ 1.2.0.1 - 1.11.24 + 1.11.29 1.0.2.1-beta @@ -257,7 +260,7 @@ 3.0.0 - 3.3.0-beta2.final + 3.3.2 runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/DisplayMagician/ProgramSettings.cs b/DisplayMagician/ProgramSettings.cs index cb5a5ae..4c4ba8f 100644 --- a/DisplayMagician/ProgramSettings.cs +++ b/DisplayMagician/ProgramSettings.cs @@ -20,11 +20,28 @@ namespace DisplayMagician #endregion #region Instance Variables + private bool _startOnBootUp = false; private bool _minimiseOnStart = false; private string _logLevel = NLog.LogLevel.Warn.ToString(); #endregion #region Class Properties + public bool StartOnBootUp + { + get + { + return _startOnBootUp; + } + set + { + _startOnBootUp = value; + + // Because a value has changed, we need to save the setting + // to remember it for later. + if (_programSettingsLoaded) + SaveSettings(); + } + } public bool MinimiseOnStart { get { diff --git a/DisplayMagician/ShortcutRepository.cs b/DisplayMagician/ShortcutRepository.cs index d8a4ef8..053ffcd 100644 --- a/DisplayMagician/ShortcutRepository.cs +++ b/DisplayMagician/ShortcutRepository.cs @@ -743,12 +743,18 @@ namespace DisplayMagician Console.WriteLine($"Starting Steam Game: {steamGameToRun.Name}"); var steamProcess = Process.Start(address); + // Delay 500ms + Thread.Sleep(500); + // Wait for Steam game to update if needed for (int secs = 0; secs >= (shortcutToUse.StartTimeout * 1000); secs += 500) { if (!steamGameToRun.IsUpdating) { + // Delay 500ms + Thread.Sleep(500); + if (steamGameToRun.IsRunning) { logger.Info($"Found the '{steamGameToRun.Name}' process has started"); diff --git a/DisplayMagician/UIForms/SettingsForm.Designer.cs b/DisplayMagician/UIForms/SettingsForm.Designer.cs index 53af8bd..825810f 100644 --- a/DisplayMagician/UIForms/SettingsForm.Designer.cs +++ b/DisplayMagician/UIForms/SettingsForm.Designer.cs @@ -33,6 +33,7 @@ namespace DisplayMagician.UIForms this.cmb_loglevel = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); this.btn_back = new System.Windows.Forms.Button(); + this.cb_start_on_boot = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // cb_minimise_notification_area @@ -42,7 +43,7 @@ namespace DisplayMagician.UIForms this.cb_minimise_notification_area.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); this.cb_minimise_notification_area.ForeColor = System.Drawing.Color.White; this.cb_minimise_notification_area.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.cb_minimise_notification_area.Location = new System.Drawing.Point(73, 41); + this.cb_minimise_notification_area.Location = new System.Drawing.Point(59, 61); this.cb_minimise_notification_area.Name = "cb_minimise_notification_area"; this.cb_minimise_notification_area.Size = new System.Drawing.Size(332, 20); this.cb_minimise_notification_area.TabIndex = 6; @@ -53,9 +54,9 @@ namespace DisplayMagician.UIForms // this.cmb_loglevel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cmb_loglevel.FormattingEnabled = true; - this.cmb_loglevel.Location = new System.Drawing.Point(213, 86); + this.cmb_loglevel.Location = new System.Drawing.Point(199, 100); this.cmb_loglevel.Name = "cmb_loglevel"; - this.cmb_loglevel.Size = new System.Drawing.Size(275, 24); + this.cmb_loglevel.Size = new System.Drawing.Size(294, 24); this.cmb_loglevel.TabIndex = 7; // // label1 @@ -63,7 +64,7 @@ namespace DisplayMagician.UIForms this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.ForeColor = System.Drawing.Color.Transparent; - this.label1.Location = new System.Drawing.Point(70, 89); + this.label1.Location = new System.Drawing.Point(56, 103); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(137, 16); this.label1.TabIndex = 8; @@ -85,12 +86,27 @@ namespace DisplayMagician.UIForms this.btn_back.UseVisualStyleBackColor = true; this.btn_back.Click += new System.EventHandler(this.btn_back_Click); // + // cb_start_on_boot + // + this.cb_start_on_boot.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.cb_start_on_boot.AutoSize = true; + this.cb_start_on_boot.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F); + this.cb_start_on_boot.ForeColor = System.Drawing.Color.White; + this.cb_start_on_boot.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.cb_start_on_boot.Location = new System.Drawing.Point(59, 25); + this.cb_start_on_boot.Name = "cb_start_on_boot"; + this.cb_start_on_boot.Size = new System.Drawing.Size(389, 20); + this.cb_start_on_boot.TabIndex = 10; + this.cb_start_on_boot.Text = "Start DisplayMagician automatically when the computer starts"; + this.cb_start_on_boot.UseVisualStyleBackColor = true; + // // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Black; this.ClientSize = new System.Drawing.Size(544, 187); + this.Controls.Add(this.cb_start_on_boot); this.Controls.Add(this.btn_back); this.Controls.Add(this.label1); this.Controls.Add(this.cmb_loglevel); @@ -117,5 +133,6 @@ namespace DisplayMagician.UIForms private System.Windows.Forms.ComboBox cmb_loglevel; private System.Windows.Forms.Label label1; private System.Windows.Forms.Button btn_back; + private System.Windows.Forms.CheckBox cb_start_on_boot; } } \ No newline at end of file diff --git a/DisplayMagician/UIForms/SettingsForm.cs b/DisplayMagician/UIForms/SettingsForm.cs index 52f28dd..315b70e 100644 --- a/DisplayMagician/UIForms/SettingsForm.cs +++ b/DisplayMagician/UIForms/SettingsForm.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using WK.Libraries.BootMeUpNS; namespace DisplayMagician.UIForms { @@ -36,12 +37,19 @@ namespace DisplayMagician.UIForms private void SettingsForm_Load(object sender, EventArgs e) { + // start displaymagician when computer starts + if (Program.AppProgramSettings.StartOnBootUp) + cb_start_on_boot.Checked = true; + else + cb_start_on_boot.Checked = false; + // setup minimise on start if (Program.AppProgramSettings.MinimiseOnStart) cb_minimise_notification_area.Checked = true; else cb_minimise_notification_area.Checked = false; + // setup loglevel on start switch (Program.AppProgramSettings.LogLevel) { @@ -73,6 +81,30 @@ namespace DisplayMagician.UIForms private void SettingsForm_FormClosing(object sender, FormClosingEventArgs e) { + var bootMeUp = new BootMeUp(); + + bootMeUp.UseAlternativeOnFail = true; + bootMeUp.BootArea = BootMeUp.BootAreas.Registry; + bootMeUp.TargetUser = BootMeUp.TargetUsers.CurrentUser; + + // save start on Boot up + if (cb_start_on_boot.Checked) + { + Program.AppProgramSettings.StartOnBootUp = true; + bootMeUp.Enabled = true; + if (!bootMeUp.Successful) + MessageBox.Show("There was an issue setting DisplayMagician to run when the computer starts. Please try launching DisplayMagician again as Admin to see if that helps."); + } + + else + { + Program.AppProgramSettings.StartOnBootUp = false; + bootMeUp.Enabled = false; + if (!bootMeUp.Successful) + MessageBox.Show("There was an issue stopping DisplayMagician from running when the computer starts. Please try launching DisplayMagician again as Admin to see if that helps."); + + } + // save minimise on close if (cb_minimise_notification_area.Checked) Program.AppProgramSettings.MinimiseOnStart = true;