/// <summary> /// Tests whether or not a given key combination is a valid key stroke by invoking the <see cref="ValidateKeyStroke"/> event. /// </summary> /// <param name="keyStroke">The key combination to be tested.</param> /// <returns>True if the key combination is a valid key stroke; False otherwise.</returns> protected bool IsValidKeyStroke(XKeys keyStroke) { ValidateKeyStrokeEventArgs e = new ValidateKeyStrokeEventArgs(keyStroke); this.OnValidateKeyStroke(e); return(e.IsValid); }
/// <summary> /// Raises the <see cref="ValidateKeyStroke"/> event. /// </summary> /// <param name="e">A <see cref="ValidateKeyStrokeEventArgs"/> that contains the event data.</param> protected virtual void OnValidateKeyStroke(ValidateKeyStrokeEventArgs e) { XKeys key = GetKeyPressed(e.KeyStroke); e.IsValid = !(key == XKeys.ControlKey || key == XKeys.AltKey || key == XKeys.ShiftKey); if (_validateKeyStrokeEventHandler != null) { _validateKeyStrokeEventHandler.Invoke(this, e); } }