diff --git a/GoToSleep/CountdownForm.Designer.cs b/GoToSleep/CountdownForm.Designer.cs index 0ec1ec3..ffa4c33 100644 --- a/GoToSleep/CountdownForm.Designer.cs +++ b/GoToSleep/CountdownForm.Designer.cs @@ -28,17 +28,27 @@ /// private void InitializeComponent() { + components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CountdownForm)); countdown = new Label(); cancel = new Button(); execNow = new Button(); tableLayoutPanel1 = new TableLayoutPanel(); + HideToSystemTray = new Button(); + trayIcon = new NotifyIcon(components); + notificationMenu = new ContextMenuStrip(components); + actionPHToolStripMenuItem = new ToolStripMenuItem(); + cDPHToolStripMenuItem = new ToolStripMenuItem(); + executeToolStripMenuItem = new ToolStripMenuItem(); + cancelToolStripMenuItem = new ToolStripMenuItem(); tableLayoutPanel1.SuspendLayout(); + notificationMenu.SuspendLayout(); SuspendLayout(); // // countdown // countdown.AutoSize = true; - tableLayoutPanel1.SetColumnSpan(countdown, 2); + tableLayoutPanel1.SetColumnSpan(countdown, 3); countdown.Dock = DockStyle.Fill; countdown.Font = new Font("Segoe UI", 27.75F, FontStyle.Regular, GraphicsUnit.Point, 238); countdown.Location = new Point(3, 0); @@ -52,7 +62,7 @@ // cancel // cancel.Anchor = AnchorStyles.Left; - cancel.Location = new Point(245, 68); + cancel.Location = new Point(285, 68); cancel.Name = "cancel"; cancel.Size = new Size(75, 23); cancel.TabIndex = 1; @@ -63,7 +73,7 @@ // execNow // execNow.Anchor = AnchorStyles.Right; - execNow.Location = new Point(164, 68); + execNow.Location = new Point(123, 68); execNow.Name = "execNow"; execNow.Size = new Size(75, 23); execNow.TabIndex = 2; @@ -73,12 +83,14 @@ // // tableLayoutPanel1 // - tableLayoutPanel1.ColumnCount = 2; + tableLayoutPanel1.ColumnCount = 3; tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 81F)); tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tableLayoutPanel1.Controls.Add(HideToSystemTray, 1, 1); tableLayoutPanel1.Controls.Add(countdown, 0, 0); - tableLayoutPanel1.Controls.Add(cancel, 1, 1); tableLayoutPanel1.Controls.Add(execNow, 0, 1); + tableLayoutPanel1.Controls.Add(cancel, 2, 1); tableLayoutPanel1.Dock = DockStyle.Fill; tableLayoutPanel1.Location = new Point(0, 0); tableLayoutPanel1.Name = "tableLayoutPanel1"; @@ -88,6 +100,57 @@ tableLayoutPanel1.Size = new Size(484, 96); tableLayoutPanel1.TabIndex = 3; // + // HideToSystemTray + // + HideToSystemTray.Anchor = AnchorStyles.Right; + HideToSystemTray.Location = new Point(204, 68); + HideToSystemTray.Name = "HideToSystemTray"; + HideToSystemTray.Size = new Size(75, 23); + HideToSystemTray.TabIndex = 3; + HideToSystemTray.Text = "Hide"; + HideToSystemTray.UseVisualStyleBackColor = true; + HideToSystemTray.Click += hideToSystemTray; + // + // trayIcon + // + trayIcon.ContextMenuStrip = notificationMenu; + trayIcon.Icon = (Icon)resources.GetObject("trayIcon.Icon"); + trayIcon.Text = "notifyIcon1"; + trayIcon.DoubleClick += restoreFromSystemTray; + // + // notificationMenu + // + notificationMenu.Items.AddRange(new ToolStripItem[] { actionPHToolStripMenuItem, cDPHToolStripMenuItem, executeToolStripMenuItem, cancelToolStripMenuItem }); + notificationMenu.Name = "contextMenuStrip1"; + notificationMenu.Size = new Size(137, 92); + // + // actionPHToolStripMenuItem + // + actionPHToolStripMenuItem.Enabled = false; + actionPHToolStripMenuItem.Name = "actionPHToolStripMenuItem"; + actionPHToolStripMenuItem.Size = new Size(136, 22); + actionPHToolStripMenuItem.Text = "Placeholder"; + // + // cDPHToolStripMenuItem + // + cDPHToolStripMenuItem.Name = "cDPHToolStripMenuItem"; + cDPHToolStripMenuItem.Size = new Size(136, 22); + cDPHToolStripMenuItem.Text = "Placeholder"; + // + // executeToolStripMenuItem + // + executeToolStripMenuItem.Name = "executeToolStripMenuItem"; + executeToolStripMenuItem.Size = new Size(136, 22); + executeToolStripMenuItem.Text = "Execute"; + executeToolStripMenuItem.Click += execNowTray_Click; + // + // cancelToolStripMenuItem + // + cancelToolStripMenuItem.Name = "cancelToolStripMenuItem"; + cancelToolStripMenuItem.Size = new Size(136, 22); + cancelToolStripMenuItem.Text = "Cancel"; + cancelToolStripMenuItem.Click += cancelTray_Click; + // // CountdownForm // AutoScaleDimensions = new SizeF(7F, 15F); @@ -97,8 +160,10 @@ MinimumSize = new Size(500, 135); Name = "CountdownForm"; Text = "CountdownForm"; + Resize += onResize; tableLayoutPanel1.ResumeLayout(false); tableLayoutPanel1.PerformLayout(); + notificationMenu.ResumeLayout(false); ResumeLayout(false); } @@ -108,5 +173,12 @@ private Button cancel; private Button execNow; private TableLayoutPanel tableLayoutPanel1; + private Button HideToSystemTray; + private NotifyIcon trayIcon; + private ContextMenuStrip notificationMenu; + private ToolStripMenuItem actionPHToolStripMenuItem; + private ToolStripMenuItem cDPHToolStripMenuItem; + private ToolStripMenuItem executeToolStripMenuItem; + private ToolStripMenuItem cancelToolStripMenuItem; } } \ No newline at end of file diff --git a/GoToSleep/CountdownForm.cs b/GoToSleep/CountdownForm.cs index a2a12e6..f695fb2 100644 --- a/GoToSleep/CountdownForm.cs +++ b/GoToSleep/CountdownForm.cs @@ -7,6 +7,7 @@ using System.Drawing; using System.Text; using System.Windows.Forms; using System.Threading; +using System.Runtime.CompilerServices; namespace GoToSleep { @@ -15,14 +16,39 @@ namespace GoToSleep public bool active = true; private PowerDownData task; private Thread taskThread; - public CountdownForm(PowerDownData taskData) + + private FormCollection windowsToRestore; + + private Form parent; + + + public CountdownForm(PowerDownData taskData, Form parent) { + this.parent = parent; + task = taskData; InitializeComponent(); this.Text = task.actionType.ToString() + " Countdown"; countdown.Text = getTimerText(); taskThread = new Thread(threadFunction); taskThread.Start(); + windowsToRestore = Application.OpenForms; + + // Remove placeholders and replace with labels because the editor + // doesn't let you add the lables directly. + notificationMenu.Items.RemoveAt(0); + notificationMenu.Items.RemoveAt(0); + notificationMenu.Items.Insert(0, new ToolStripLabel()); + notificationMenu.Items.Insert(0, new ToolStripLabel()); + + notificationMenu.Items[0].Text = task.actionType.ToString(); + notificationMenu.Items[0].Padding = new Padding { Top = 1, Bottom = 1 }; + + notificationMenu.Items[1].Text = countdown.Text; + notificationMenu.Items[1].Padding = new Padding { Top = 1, Bottom = 1 }; + + trayIcon.Text = task.actionType.ToString() + "\n" + countdown.Text; + } string getTimerText() { @@ -32,12 +58,15 @@ namespace GoToSleep void updateTimer() { - + try { countdown.Invoke((MethodInvoker)delegate { + // both controls should be owned by same thread countdown.Text = getTimerText(); + notificationMenu.Items[1].Text = countdown.Text; + trayIcon.Text = task.actionType.ToString() + "\n" + countdown.Text; }); } catch @@ -71,7 +100,7 @@ namespace GoToSleep { this.Close(); }); - + } private void execNow_Click(object sender, EventArgs e) @@ -87,6 +116,14 @@ 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; } @@ -95,5 +132,48 @@ namespace GoToSleep { } + + private void onResize(object sender, EventArgs e) + { + return; + // do we even want this behavior? + //if (this.WindowState == FormWindowState.Minimized) + //{ + // hideToSystemTray(sender, e); + //} + } + + private void hideToSystemTray(object sender, EventArgs e) + { + foreach (Form form in Application.OpenForms) + { + form.Visible = false; + } + trayIcon.Visible = true; + } + + private void restoreFromSystemTray(object sender, EventArgs e) + { + foreach (Form form in this.windowsToRestore) + { + form.Show(); + } + this.Activate(); + trayIcon.Visible = false; + } + + private void execNowTray_Click(object sender, EventArgs e) + { + parent.Visible = true; + trayIcon.Visible = false; + execNow_Click(sender, e); + } + + private void cancelTray_Click(object sender, EventArgs e) + { + parent.Visible = true; + trayIcon.Visible = false; + cancel_Click(sender, e); + } } } diff --git a/GoToSleep/CountdownForm.resx b/GoToSleep/CountdownForm.resx index 8b2ff64..730516b 100644 --- a/GoToSleep/CountdownForm.resx +++ b/GoToSleep/CountdownForm.resx @@ -117,4 +117,87 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 131, 17 + + + + + AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAgBAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAP///////////////wAAAP8AAAD///////////////////////////8AAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAA//////////8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP////////////// + ////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////wAAAP8AAAD///////// + //8AAAD/AAAA/wAAAP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////AAAA/wAA + AP//////AAAAAP//////////////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////////////////wAAAAAAAAAA//////// + //8AAAD/AAAA/wAAAP//////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////// + //////////////////8AAAD/AAAA////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAP8AAAD/AAAA/wAA + AP///////////////////////////wAAAP8AAAD/AAAA//////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP///////////wAAAP8AAAD///////////8AAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAD/////AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP//////AAAA/wAAAP8AAAD///////// + //8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAP////8AAAD/AAAA/wAAAP////////////////8AAAD/AAAA////////////AAAA/wAA + AP8AAAD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////8AAAD/AAAA/wAAAP////////////////8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD//////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP// + ////////////////////////AAAAAAAAAAAAAAAA//////////8AAAD/AAAA/wAAAP///////////wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP//////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAA//////////8AAAD/AAAA//////////////////////////////////////8AAAD/AAAA//// + //////////////////////////////////////////////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAD/////AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD//////////////////////wAA + AP8AAAD/AAAA////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP///////////wAAAP8AAAD/AAAA////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAP8AAAD/AAAA////////////AAAA/wAA + AP8AAAD/AAAA/////////////////wAAAP8AAAD///////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAP8AAAD/AAAA//// + ////////////////////////////////////////AAAA/wAAAP8AAAD///////////8AAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAA/wAA + AP8AAAD/////////////////AAAA/wAAAP8AAAD/AAAA/wAAAP//////AAAA/wAAAP8AAAD//////wAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAD/////AAAA/wAAAP8AAAD///////////8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP//////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAP//////////AAAA/wAAAP8AAAD///////////////////////////8AAAD/AAAA/wAA + AP8AAAD/AAAA//////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////AAAA/wAAAP8AAAD//////wAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////////AAAA/wAAAP8AAAD//////wAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAP////////////////////////////////////8AAAAA////////////////AAAA/wAA + AP8AAAD//////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAA/////wAAAP8AAAD/AAAA//////////////////////////////////// + ////////AAAA/wAAAP///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP//////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////////wAAAP8AAAD/AAAA/wAA + AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA//////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAD//////////////////////////////////////////////////////////wAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + + \ No newline at end of file diff --git a/GoToSleep/GoToSleep.csproj b/GoToSleep/GoToSleep.csproj index 4722b37..61658bd 100644 --- a/GoToSleep/GoToSleep.csproj +++ b/GoToSleep/GoToSleep.csproj @@ -30,6 +30,11 @@ + + True + True + Resources.resx + True True @@ -37,6 +42,13 @@ + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator diff --git a/GoToSleep/Properties/Resources.Designer.cs b/GoToSleep/Properties/Resources.Designer.cs new file mode 100644 index 0000000..f563881 --- /dev/null +++ b/GoToSleep/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace GoToSleep.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GoToSleep.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/GoToSleep/Properties/Resources.resx b/GoToSleep/Properties/Resources.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/GoToSleep/Properties/Resources.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GoToSleep/SystemPowerManager.cs b/GoToSleep/SystemPowerManager.cs index 2ec3153..f5cfc4e 100644 --- a/GoToSleep/SystemPowerManager.cs +++ b/GoToSleep/SystemPowerManager.cs @@ -43,6 +43,8 @@ namespace GoToSleep } Form parentForm; + CountdownForm? progressPopup; + string prepareTimeString(string s) { // make sure there are spaces between numbers and units, for the parser @@ -139,10 +141,9 @@ namespace GoToSleep return; } - using (var progressPopup = new CountdownForm(PowerDownData.Shutdown(target))) - { - progressPopup.ShowDialog(parentForm); - } + progressPopup = new CountdownForm(PowerDownData.Shutdown(target), parentForm); + progressPopup.Show(); + parentForm.Enabled = false; } public void suspend(string timeString) @@ -162,10 +163,9 @@ namespace GoToSleep return; } - using (var progressPopup = new CountdownForm(PowerDownData.Suspend(target))) - { - progressPopup.ShowDialog(parentForm); - } + progressPopup = new CountdownForm(PowerDownData.Suspend(target), parentForm); + progressPopup.Show(); + parentForm.Enabled = false; } public void hibernate(string timeString) @@ -185,10 +185,9 @@ namespace GoToSleep return; } - using (var progressPopup = new CountdownForm(PowerDownData.Hibernate(target))) - { - progressPopup.ShowDialog(parentForm); - } + progressPopup = new CountdownForm(PowerDownData.Hibernate(target), parentForm); + progressPopup.Show(); + parentForm.Enabled = false; } public void restart(string timeString) @@ -208,10 +207,9 @@ namespace GoToSleep return; } - using (var progressPopup = new CountdownForm(PowerDownData.Restart(target))) - { - progressPopup.ShowDialog(parentForm); - } + progressPopup = new CountdownForm(PowerDownData.Restart(target), parentForm); + progressPopup.Show(); + parentForm.Enabled = false; } } }