-
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.
Added support for presing keys and minimization to systray. Also, did…
… some refining of the colors values and added grey.
- Loading branch information
tech-chieftain
committed
Mar 2, 2018
1 parent
0104b1a
commit 32fbe4d
Showing
6 changed files
with
462 additions
and
31 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,73 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
using Utilities; | ||
|
||
namespace exhibit | ||
{ | ||
class Combination | ||
{ | ||
public delegate void EventFunction(List<Keys> keys); | ||
|
||
private globalKeyboardHook _gkh = new globalKeyboardHook(); | ||
private EventFunction _f; | ||
private List<Keys> _combinaison; | ||
private List<bool> _pressed = new List<bool>(); | ||
private bool _event = false; | ||
|
||
public Combination(List<Keys> combinaison, EventFunction f) | ||
{ | ||
_f = f; | ||
_combinaison = combinaison; | ||
foreach (Keys k in _combinaison) | ||
{ | ||
_gkh.HookedKeys.Add(k); | ||
_pressed.Add(false); | ||
} | ||
_gkh.KeyDown += new KeyEventHandler(gkh_KeyDown); | ||
_gkh.KeyUp += new KeyEventHandler(gkh_KeyUp); | ||
} | ||
public void Start() | ||
{ | ||
_gkh.hook(); | ||
} | ||
public void Stop() | ||
{ | ||
_gkh.unhook(); | ||
} | ||
private void gkh_KeyUp(object sender, KeyEventArgs e) | ||
{ | ||
e.Handled = true; | ||
_event = false; | ||
_pressed[_combinaison.IndexOf(e.KeyCode)] = false; | ||
} | ||
|
||
private void gkh_KeyDown(object sender, KeyEventArgs e) | ||
{ | ||
e.Handled = true; | ||
if (_combinaison.IndexOf(e.KeyCode) == _combinaison.Count - 1) | ||
{ | ||
bool before_pressed = true; | ||
for (int i = 0; i < _combinaison.IndexOf(e.KeyCode); i++) | ||
{ | ||
if (_pressed[i] == false) | ||
{ | ||
before_pressed = false; | ||
} | ||
} | ||
|
||
if (before_pressed == true && _event == false) | ||
{ | ||
_f(_combinaison); | ||
_event = true; | ||
} | ||
} | ||
else | ||
{ | ||
_pressed[_combinaison.IndexOf(e.KeyCode)] = true; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.