-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0dc0167
Showing
14 changed files
with
2,690 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/.vs | ||
bin | ||
obj | ||
*.user | ||
/WatchSleepBlockers.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2020 Michael Rosack ([email protected]) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
WatchSleepBlockers | ||
================== | ||
|
||
A simple .NET Core 3.1 WinForms application to let you know if your computer is doing something that'll prevent it from sleeping. | ||
|
||
Emoji from https://openmoji.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30621.155 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WatchSleepBlockers", "WatchSleepBlockers\WatchSleepBlockers.csproj", "{3EEB7F63-73E5-4239-8CAA-D7FCDA7BDFFC}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{3EEB7F63-73E5-4239-8CAA-D7FCDA7BDFFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3EEB7F63-73E5-4239-8CAA-D7FCDA7BDFFC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3EEB7F63-73E5-4239-8CAA-D7FCDA7BDFFC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3EEB7F63-73E5-4239-8CAA-D7FCDA7BDFFC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {AFD3F70E-CAF1-4735-9226-E885BBADA317} | ||
EndGlobalSection | ||
EndGlobal |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace WatchSleepBlockers | ||
{ | ||
public partial class MainForm : Form | ||
{ | ||
public MainForm() | ||
{ | ||
InitializeComponent(); | ||
checkPowercfgTimer_Tick(null, null); | ||
} | ||
|
||
private void MainForm_Resize(object sender, EventArgs e) | ||
{ | ||
if (this.WindowState == FormWindowState.Minimized) | ||
{ | ||
Hide(); | ||
trayIcon.Visible = true; | ||
} | ||
} | ||
|
||
private void trayIcon_MouseClick(object sender, MouseEventArgs e) | ||
{ | ||
Show(); | ||
this.WindowState = FormWindowState.Normal; | ||
trayIcon.Visible = false; | ||
|
||
} | ||
|
||
private async void checkPowercfgTimer_Tick(object sender, EventArgs e) | ||
{ | ||
var requests = await PowercfgRequestParser.GetActiveRequests(); | ||
Icon icon; | ||
|
||
if (requests.Length == 0) | ||
{ | ||
blockersLabel.Text = "There is nothing preventing this computer from sleeping!"; | ||
icon = new System.Drawing.Icon("sleeping_emoji.ico"); | ||
} | ||
else | ||
{ | ||
blockersLabel.Text = "The following issues are preventing the computer from sleeping: " + Environment.NewLine + Environment.NewLine; | ||
icon = new System.Drawing.Icon("angry_face_with_horns.ico"); | ||
|
||
foreach (var request in requests) | ||
{ | ||
blockersLabel.Text += request + Environment.NewLine; | ||
} | ||
} | ||
|
||
this.Icon = icon; | ||
trayIcon.Icon = icon; | ||
} | ||
} | ||
} |
Oops, something went wrong.