Skip to content

Commit

Permalink
Added support for presing keys and minimization to systray. Also, did…
Browse files Browse the repository at this point in the history
… some refining of the colors values and added grey.
  • Loading branch information
tech-chieftain committed Mar 2, 2018
1 parent 0104b1a commit 32fbe4d
Show file tree
Hide file tree
Showing 6 changed files with 462 additions and 31 deletions.
73 changes: 73 additions & 0 deletions exhibit/Combination.cs
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;
}
}
}
}
120 changes: 110 additions & 10 deletions exhibit/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 32fbe4d

Please sign in to comment.