diff --git a/GoToSleep/CountdownForm.Designer.cs b/GoToSleep/CountdownForm.Designer.cs index ffa4c33..79a80fe 100644 --- a/GoToSleep/CountdownForm.Designer.cs +++ b/GoToSleep/CountdownForm.Designer.cs @@ -160,6 +160,7 @@ MinimumSize = new Size(500, 135); Name = "CountdownForm"; Text = "CountdownForm"; + Shown += CountdownForm_Shown; Resize += onResize; tableLayoutPanel1.ResumeLayout(false); tableLayoutPanel1.PerformLayout(); diff --git a/GoToSleep/CountdownForm.cs b/GoToSleep/CountdownForm.cs index f695fb2..8ed1ca7 100644 --- a/GoToSleep/CountdownForm.cs +++ b/GoToSleep/CountdownForm.cs @@ -13,7 +13,7 @@ namespace GoToSleep { public partial class CountdownForm : Form { - public bool active = true; + public volatile bool active = true; private PowerDownData task; private Thread taskThread; @@ -50,6 +50,7 @@ namespace GoToSleep trayIcon.Text = task.actionType.ToString() + "\n" + countdown.Text; } + string getTimerText() { var timeRemaining = task.when - DateTime.Now; @@ -116,16 +117,10 @@ namespace GoToSleep protected override void OnFormClosing(FormClosingEventArgs e) { - if (e.CloseReason == CloseReason.None && this.Visible == false) - { - // the window has been minimzed to tray, do not destroy it - e.Cancel = true; - return; - } parent.Enabled = true; trayIcon.Visible = false; - base.OnFormClosing(e); active = false; + base.OnFormClosing(e); } private void countdown_Click(object sender, EventArgs e) @@ -175,5 +170,10 @@ namespace GoToSleep trayIcon.Visible = false; cancel_Click(sender, e); } + + private void CountdownForm_Shown(object sender, EventArgs e) + { + parent.Enabled = false; + } } } diff --git a/GoToSleep/SystemPowerManager.cs b/GoToSleep/SystemPowerManager.cs index f5cfc4e..1eb57b4 100644 --- a/GoToSleep/SystemPowerManager.cs +++ b/GoToSleep/SystemPowerManager.cs @@ -143,7 +143,6 @@ namespace GoToSleep progressPopup = new CountdownForm(PowerDownData.Shutdown(target), parentForm); progressPopup.Show(); - parentForm.Enabled = false; } public void suspend(string timeString) @@ -165,7 +164,6 @@ namespace GoToSleep progressPopup = new CountdownForm(PowerDownData.Suspend(target), parentForm); progressPopup.Show(); - parentForm.Enabled = false; } public void hibernate(string timeString) @@ -187,7 +185,6 @@ namespace GoToSleep progressPopup = new CountdownForm(PowerDownData.Hibernate(target), parentForm); progressPopup.Show(); - parentForm.Enabled = false; } public void restart(string timeString) @@ -209,7 +206,6 @@ namespace GoToSleep progressPopup = new CountdownForm(PowerDownData.Restart(target), parentForm); progressPopup.Show(); - parentForm.Enabled = false; } } } diff --git a/README.md b/README.md index 6d117fd..226227f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # GoToSleep +![Screenshot of working application](./img/program.png) + Simple utility to schedule automatic system suspension/shutdown using natural language Utilizes Microsoft.Recognizers.Text to process the natural text input and generate user-friendly countdown popup. * [Download Latest x64 Standalone Release (50 MB)](https://github.com/Kamil118/GoToSleep/releases/latest/download/GoToSleep-x64_STANDALONE.exe) (Probably what you are looking for) -* [Download Latest x64 trimmed release (4.5 MB)](https://github.com/Kamil118/GoToSleep/releases/latest/download/GoToSleep-x64_dotnet.exe) (Requires .NET 10 runtime installed) \ No newline at end of file +* [Download Latest x64 trimmed release (4.5 MB)](https://github.com/Kamil118/GoToSleep/releases/download/v1.0.9/GoToSleep-x64-dotnet.exe) (Requires .NET 10 runtime installed) \ No newline at end of file diff --git a/img/program.png b/img/program.png new file mode 100644 index 0000000..808ebb1 Binary files /dev/null and b/img/program.png differ