Skip to content

Commit 2e60af2

Browse files
authored
Merge pull request #1 from taylorflatt/dev
Release 1.4.0.0
2 parents cb00c0f + e8a93dc commit 2e60af2

16 files changed

+403
-193
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ A basic portable Windows shutdown timer. I use this personally but it is availab
55

66
Creates timer that will shutdown windows after a specified number of minutes. It is non-intrusive meaning once you set the timer, you can hide it or close it without any problems. At its core, it runs a shutdown command through the windows command prompt with a timer attached.
77

8+
## Requirements
9+
10+
* Windows 10, Windows 8, Windows 7
11+
* [.NET Framework 4.5.2](https://www.microsoft.com/en-us/download/details.aspx?id=42642) or better
12+
813
## Features
914

1015
* Shutdown Windows after specified number of minutes.
@@ -15,22 +20,23 @@ Creates timer that will shutdown windows after a specified number of minutes. It
1520
* Timers created by this program will persist even if the program is shutdown.
1621
* Ability to update from the program any time. It simply pulls the exe from GIT and places it in the directory from which the update was run. In other words, it puts the two versions in the same directory.
1722

18-
## Known Issues
23+
## Usage
1924

20-
There aren't any program breaking issues as of yet. If you discover any, please don't hesitate to contact me or raise an issue. But I am aware of some annoyances and am working on finding solutions to those:
25+
Download the [latest release](https://github.com/taylorflatt/windows-shutdown-timer/releases) and run it somewhere on your desktop. No installation required. Note, if you end up ever updating it via the updater, the new version will be downloaded to the same directory as the old version.
2126

22-
* When the program first starts, if a timer was set by the program previously but has yet to elapse, a check will be run. The check will cause a shutdown notification and a "ding". It doesn't change anything other than simply verify the existence of a timer. I'm looking for ways around this small annoyance. It doesn't happen often though, which is nice.
27+
## Updating
2328

24-
## Requirements
29+
To update, simply choose the "Update" option in the program and it will determine if there is a newer version available. If there is, you have the option to download it. The newer version will be downloaded and placed in the same place as the older version. Once downloaded, it is then safe to remove the old version. Note, your settings will not be preserved (next release).
2530

26-
* Windows 10, Windows 8, Windows 7*
27-
* [.NET Framework 4.5.2](https://www.microsoft.com/en-us/download/details.aspx?id=42642) or better
31+
Otherwise, you can simply download the latest version from the [Release Section](https://github.com/taylorflatt/windows-shutdown-timer/releases).
2832

29-
\*Currently only tested working on Windows 10 and Windows 8. There isn't anything exclusive to Windows 10/8 so it should honestly work just fine on Windows 7.
33+
## Known Issues
3034

31-
## Usage
35+
There aren't any program breaking issues as of yet. If you discover any, please don't hesitate to contact me or raise an issue. But I am aware of some annoyances and am working on finding solutions to those:
3236

33-
Download the [latest release](https://github.com/taylorflatt/windows-shutdown-timer/releases) and run it somewhere on your desktop. No installation required. Note, if you end up ever updating it via the updater, the new version will be downloaded to the same directory as the old version.
37+
* When the program first starts, if a timer was set by the program previously but has yet to elapse, a check will be run. The check will cause a shutdown notification and a "ding". It doesn't change anything other than simply verify the existence of a timer. I'm looking for ways around this small annoyance. It doesn't happen often though, which is nice.
38+
* When the computer is around 15 minutes or less from shutting off, a banner or dialog box on Windows 7, 8, and 10 will display indicating the impending shutdown. This is for any scheduled shutdown and I am looking at ways to remove/disable this function. There isn't an option to perform a quiet reboot like literally every other OS out there.
39+
* After an update, settings are not preserved. This isn't game breaking but it is annoying. This is the next thing I plan on tackling.
3440

3541
## Notes
3642

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.0.0
1+
1.4.0.0

WindowsShutdownTimer.exe

4.5 KB
Binary file not shown.

WindowsShutdownTimer/App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</startup>
1111
<userSettings>
1212
<WindowsShutdownTimer.Properties.Settings>
13-
<setting name="MinimizePref" serializeAs="String">
13+
<setting name="MinimizeToSysTray" serializeAs="String">
1414
<value>False</value>
1515
</setting>
1616
<setting name="LClickOpenSysTray" serializeAs="String">

WindowsShutdownTimer/CustomExceptions.cs

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,77 @@
22

33
namespace WindowsShutdownTimer
44
{
5+
/// <summary>
6+
/// Trouble stopping the timer.
7+
/// </summary>
58
[Serializable]
69
class StopTimerException : Exception
710
{
11+
public string ErrorCode = "";
12+
813
public StopTimerException() { }
914

10-
public StopTimerException(string message) : base(message) { }
15+
public StopTimerException(string message, string code) : base(message)
16+
{
17+
this.ErrorCode = code;
18+
}
1119

12-
public StopTimerException(string message, Exception inner) : base(message, inner) { }
20+
public StopTimerException(string message, Exception inner, string code) : base(message, inner)
21+
{
22+
this.ErrorCode = code;
23+
}
1324
}
1425

26+
/// <summary>
27+
/// Trouble starting the timer.
28+
/// </summary>
1529
[Serializable]
1630
class StartTimerException : Exception
1731
{
32+
public string ErrorCode = "";
33+
1834
public StartTimerException() { }
1935

20-
public StartTimerException(string message) : base(message) { }
36+
public StartTimerException(string message, string code) : base(message)
37+
{
38+
this.ErrorCode = code;
39+
}
40+
41+
public StartTimerException(string message, Exception inner, string code) : base(message, inner)
42+
{
43+
this.ErrorCode = code;
44+
}
45+
}
46+
47+
/// <summary>
48+
/// Trouble checking for a timer.
49+
/// </summary>
50+
[Serializable]
51+
class CheckTimerException : Exception
52+
{
53+
public string ErrorCode = "";
54+
55+
public CheckTimerException() { }
56+
57+
public CheckTimerException(string message, string code) : base(message)
58+
{
59+
this.ErrorCode = code;
60+
}
61+
62+
public CheckTimerException(string message, Exception inner, string code) : base(message, inner)
63+
{
64+
this.ErrorCode = code;
65+
}
66+
}
67+
68+
/// <summary>
69+
/// Used to show that the timer has ended. This isn't a true exception. This seemed easier (to read/understand) than traditional logic to me.
70+
/// </summary>
71+
[Serializable]
72+
class TimerEnded : Exception
73+
{
74+
public TimerEnded() { }
2175

22-
public StartTimerException(string message, Exception inner) : base(message, inner) { }
76+
public TimerEnded(string message) : base(message) { }
2377
}
2478
}

WindowsShutdownTimer/Helpers.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
62

73
namespace WindowsShutdownTimer
84
{
95
public class Helpers
106
{
7+
/// <summary>
8+
/// Since VS won't save a default DateTime object (year as 0001), an extra year needs to be added to
9+
/// any DateTime object. So I redefine the 'default' DateTime (year is now 0002) for reference.
10+
/// </summary>
11+
/// <param name="obj">DateTime object to be reset to default. Exact same as calling default except with an extra year.</param>
1112
public void SetDefaultDateTime(DateTime obj)
1213
{
1314
obj = default(DateTime);

WindowsShutdownTimer/Options.Designer.cs

Lines changed: 33 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WindowsShutdownTimer/Options.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Deployment.Application;
3-
using System.IO;
42
using System.Windows.Forms;
53

64
namespace WindowsShutdownTimer
@@ -23,6 +21,9 @@ public Options(TimerForm parent)
2321
timerWindow = parent;
2422
timerWindow.Enabled = false;
2523

24+
// Setting this in the design menu doesn't work. Must be set here.
25+
this.CenterToParent();
26+
2627
last_shutdown_label_desc.Text = "Last Shutdown: ";
2728

2829
// Because the settings manager won't store a 0001 default DateTime year.
@@ -45,7 +46,7 @@ public Options(TimerForm parent)
4546
/// <param name="e"></param>
4647
private void Options_Load(object sender, EventArgs e)
4748
{
48-
if (Properties.Settings.Default.MinimizePref)
49+
if (Properties.Settings.Default.MinimizeToSysTray)
4950
minimize_to_sys_tray.Checked = true;
5051
else
5152
minimize_to_sys_tray.Checked = false;
@@ -65,9 +66,9 @@ public void save_options_button_Click(object sender, EventArgs e)
6566
{
6667
// Minimize program to system tray rather than to the taskbar.
6768
if (minimize_to_sys_tray.Checked)
68-
Properties.Settings.Default.MinimizePref = true;
69+
Properties.Settings.Default.MinimizeToSysTray = true;
6970
else
70-
Properties.Settings.Default.MinimizePref = false;
71+
Properties.Settings.Default.MinimizeToSysTray = false;
7172

7273
// Single left click to re-show program when clicking icon in system tray.
7374
if (left_click_open_sys_tray.Checked)
@@ -117,7 +118,7 @@ public void check_update_button_Click(object sender, EventArgs e)
117118
if(Convert.ToInt32(webV.GetValue(i)) > Convert.ToInt32(curV.GetValue(i)))
118119
{
119120
DialogResult result = MessageBox.Show("The current version is: " + currentVersion + " and the newest version is " + webVersion + ". Would you " +
120-
"like to download the newest version?", "New Version Found!", MessageBoxButtons.YesNoCancel);
121+
"like to download the newest version?", "New Version Found!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
121122

122123
if (result == DialogResult.Yes)
123124
{
@@ -130,7 +131,7 @@ public void check_update_button_Click(object sender, EventArgs e)
130131
wc.DownloadFile(new Uri(updatedAppLocation), newFilePath);
131132

132133
DialogResult close = MessageBox.Show("You have successfully updated to version " + webVersion + "! The new version was downloaded to the same directory as this " +
133-
"program. Would you like to close this program now?", "Update Completed!", MessageBoxButtons.YesNo);
134+
"program. Would you like to close this program now?", "Update Completed!", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
134135

135136
if (close == DialogResult.Yes)
136137
Application.Exit();
@@ -141,7 +142,7 @@ public void check_update_button_Click(object sender, EventArgs e)
141142
catch
142143
{
143144
DialogResult error = MessageBox.Show("There was an error attempting to grab the latest update. Would you like to " +
144-
"retry or cancel?", "Error Downloading Update!", MessageBoxButtons.RetryCancel);
145+
"retry or cancel?", "Error Downloading Update!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
145146

146147
if (error == DialogResult.Retry)
147148
check_update_button_Click(null, null);
@@ -155,7 +156,7 @@ public void check_update_button_Click(object sender, EventArgs e)
155156
}
156157
}
157158

158-
MessageBox.Show("The current version is: " + currentVersion + " and it is up to date!", "No New Update!", MessageBoxButtons.OK);
159+
MessageBox.Show("The current version is: " + currentVersion + " and it is up to date!", "No New Update!", MessageBoxButtons.OK, MessageBoxIcon.Information);
159160
}
160161
}
161162
}

WindowsShutdownTimer/Program.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ static class Program
2323
[STAThread]
2424
static void Main()
2525
{
26-
bool unqiue;
27-
28-
using (var mutex = new Mutex(true, "WindowsShutdownTimerMutex", out unqiue))
26+
using (var mutex = new Mutex(true, "WindowsShutdownTimerMutex", out bool unqiue))
2927
{
3028
if(unqiue)
3129
{

WindowsShutdownTimer/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.3.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
35+
[assembly: AssemblyVersion("1.4.0.0")]
36+
[assembly: AssemblyFileVersion("1.4.0.0")]

0 commit comments

Comments
 (0)