Skip to content

Commit

Permalink
Merge pull request #4 from sa-/remove-keyboard-shortcut
Browse files Browse the repository at this point in the history
remove keyboard shortcut
  • Loading branch information
sa- authored May 23, 2020
2 parents fccfc16 + c5905e2 commit 2b3c87e
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 216 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ Grayscaling helps you cut down on screen time by making your computer screen les

## Instructions
Download it from [releases](https://github.com/sa-/grayzen/releases) and open the file. Look for the grey circle in your Tray.

### Timed Color Session
Press Ctrl + Alt + Space to start a Colour Session for 1 minute.
10 changes: 2 additions & 8 deletions grayzen/ColorTransformation/Grayscaler.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace grayzen
namespace grayzen
{
using static NativeMethods;

Expand All @@ -28,7 +22,7 @@ internal static void GoGrey()
};

MagSetFullscreenColorEffect(ref magEffectInvert);

}

internal static void DontTransformColor()
Expand Down
16 changes: 0 additions & 16 deletions grayzen/HotkeyHandling/HotkeyModifierKeys.cs

This file was deleted.

21 changes: 0 additions & 21 deletions grayzen/HotkeyHandling/KeyPressedEventArgs.cs

This file was deleted.

113 changes: 0 additions & 113 deletions grayzen/HotkeyHandling/KeyboardHook.cs

This file was deleted.

4 changes: 1 addition & 3 deletions grayzen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

namespace grayzen
{
using static NativeMethods;

static class Program
{
/// <summary>
Expand All @@ -22,5 +20,5 @@ static void Main()
}



}
1 change: 0 additions & 1 deletion grayzen/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
32 changes: 3 additions & 29 deletions grayzen/State/AppState.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.Threading.Tasks;
using grayzen.HotkeyHandling;
using System.Windows.Forms;

namespace grayzen.State
namespace grayzen.State
{
using static NativeMethods;

Expand All @@ -18,26 +9,9 @@ internal class AppState
internal static void InitApp()
{
MagInitialize();
SetKeyboardShortcut();
GoGrey();
}

private static void SetKeyboardShortcut()
{
KeyboardHook hook = new KeyboardHook();
// register the event that is fired after the key press.
hook.KeyPressed +=
new EventHandler<KeyPressedEventArgs>(hook_KeyPressed);

hook.RegisterHotKey(HotkeyModifierKeys.Control | HotkeyModifierKeys.Alt,
Keys.Space);

void hook_KeyPressed(object sender, KeyPressedEventArgs e)
{
ToggleTimedColourSession(5_000);
}
}

static void ChangeState(State state)
{
AppState.state = state;
Expand All @@ -53,12 +27,12 @@ internal static void ToggleBetweenGrayAndColour()
internal static void ToggleTimedColourSession(int milliseconds)
{
TimedColorSession.ToggleTimedColourSession(milliseconds);

}

static void RenderState()
{
if(state == State.Gray)
if (state == State.Gray)
{
Grayscaler.GoGrey();
}
Expand Down
8 changes: 1 addition & 7 deletions grayzen/State/State.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace grayzen.State
namespace grayzen.State
{
enum State
{
Expand Down
13 changes: 5 additions & 8 deletions grayzen/State/TimedColorSession.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace grayzen.State
{
Expand All @@ -12,7 +8,8 @@ class TimedColorSession

private static void StartTimedColourSession(int milliseconds)
{
if(timer != null ) {
if (timer != null)
{
timer.Dispose();
}
timer = new System.Windows.Forms.Timer();
Expand All @@ -36,14 +33,14 @@ public static void ToggleTimedColourSession(int milliseconds)

public static bool IsRunning()
{
return
timer != null &&
return
timer != null &&
timer.Enabled;
}

public static void EndTimerEarly()
{
if(timer == null) { return; }
if (timer == null) { return; }
timer.Dispose();
AppState.GoGrey();
}
Expand Down
7 changes: 3 additions & 4 deletions grayzen/TrayApplicationContext.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using grayzen.HotkeyHandling;
using grayzen.State;
using grayzen.State;
using System;
using System.Windows.Forms;

namespace grayzen
{


public class TrayApplicationContext : ApplicationContext
{
Expand All @@ -14,7 +13,7 @@ public class TrayApplicationContext : ApplicationContext
public TrayApplicationContext()
{
// Initialize Tray Icon
MenuItem menuItem = new MenuItem("Disable for one minute", DisableForOneMinute);
MenuItem menuItem = new MenuItem("60s colour session (click again to disable)", DisableForOneMinute);
trayIcon = new NotifyIcon()
{
Icon = Properties.Resources.grayzen,
Expand Down
3 changes: 0 additions & 3 deletions grayzen/grayzen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ColorTransformation\Grayscaler.cs" />
<Compile Include="HotkeyHandling\KeyboardHook.cs" />
<Compile Include="HotkeyHandling\KeyPressedEventArgs.cs" />
<Compile Include="HotkeyHandling\HotkeyModifierKeys.cs" />
<Compile Include="ColorTransformation\NativeMethods.cs" />
<Compile Include="State\AppState.cs" />
<Compile Include="State\State.cs" />
Expand Down

0 comments on commit 2b3c87e

Please sign in to comment.