Ejemplo n.º 1
0
        /// <summary>Specifies the entire information about this HotKey.
        /// </summary>
        /// <returns>A string representation of the information.</returns>
        public string FullInfo()
        {
            string bhot = "";
            string chot = "";

            bhot = HotKeyShared.CombineShortcut(BaseModifier, BaseKey);
            chot = HotKeyShared.CombineShortcut(ChordModifier, ChordKey);

            return(String.Format("{0} ; {1} ; {2} ; {3}Enabled ; ChordHotKey", Name, bhot, chot, Enabled ? "" : "Not "));
        }
Ejemplo n.º 2
0
 /// <summary>Information about this Hotkey.
 /// </summary>
 /// <returns>The properties of the hotkey.</returns>
 public string FullInfo()
 {
     return(string.Format("{0} ; {1} ; {2} ; {3}Enabled ; LocalHotKey", Name, HotKeyShared.CombineShortcut(Modifier, Key), WhenToRaise, Enabled ? "" : "Not "));
 }
Ejemplo n.º 3
0
 /// <summary>Specifies the Chord information of this HotKey.
 /// </summary>
 /// <returns>A string representation of the information.</returns>
 public string ChordInfo()
 {
     return(HotKeyShared.CombineShortcut(ChordModifier, ChordKey));
 }
Ejemplo n.º 4
0
 /// <summary>Specifies the base information of this HotKey.
 /// </summary>
 /// <returns>A string representation of the information.</returns>
 public string BaseInfo()
 {
     return(HotKeyShared.CombineShortcut(BaseModifier, BaseKey));
 }
Ejemplo n.º 5
0
 /// <summary>Checks if a hotkey has already been registered as a Local or Global HotKey.
 /// </summary>
 /// <param name="key">The key of the HotKey.</param>
 /// <param name="modifier">The modifier of the HotKey.</param>
 /// <param name="ToCheck">The HotKey type to check.</param>
 /// <returns>True if the HotKey is already registered, false otherwise.</returns>
 public bool HotKeyExists(Keys key, ModifierKeys modifier, CheckKey ToCheck)
 {
     return(HotKeyExists(HotKeyShared.CombineShortcut(modifier, key), ToCheck));
 }
Ejemplo n.º 6
0
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            try
            {
                Keys KeyPressed = (Keys)wParam;

                Microsoft.VisualBasic.Devices.Keyboard UserKeyBoard = new Microsoft.VisualBasic.Devices.Keyboard();
                bool AltPressed     = UserKeyBoard.AltKeyDown;
                bool ControlPressed = UserKeyBoard.CtrlKeyDown;
                bool ShiftPressed   = UserKeyBoard.ShiftKeyDown;

                ModifierKeys LocalModifier = ModifierKeys.None;
                if (AltPressed)
                {
                    LocalModifier = ModifierKeys.Alt;
                }
                if (ControlPressed)
                {
                    LocalModifier |= ModifierKeys.Control;
                }
                if (ShiftPressed)
                {
                    LocalModifier |= ModifierKeys.Shift;
                }

                switch ((KeyboardMessages)msg)
                {
                case KeyboardMessages.WmSyskeydown:
                case KeyboardMessages.WmKeydown:
                    switch (KeyPressed)
                    {
                    case Keys.Control:
                    case Keys.ControlKey:
                    case Keys.LControlKey:
                    case Keys.RControlKey:
                    case Keys.Shift:
                    case Keys.ShiftKey:
                    case Keys.LShiftKey:
                    case Keys.RShiftKey:
                    case Keys.Alt:
                    case Keys.Menu:
                    case Keys.LMenu:
                    case Keys.RMenu:
                    case Keys.LWin:
                        return(IntPtr.Zero);

                        //case Keys.Back:
                        //    this.Text = Keys.None.ToString();
                        //    return IntPtr.Zero;
                    }

                    if (LocalModifier != ModifierKeys.None)
                    {
                        this.Text = HotKeyShared.CombineShortcut(LocalModifier, KeyPressed);
                    }
                    else
                    {
                        if (ForceModifiers)
                        {
                            ShowErrorMessage();
                        }
                        else
                        {
                            this.Text = KeyPressed.ToString();
                        }
                    }
                    return(IntPtr.Zero);

                case KeyboardMessages.WmSyskeyup:
                case KeyboardMessages.WmKeyup:
                    if (!String.IsNullOrWhiteSpace(Text.Trim()) || this.Text != Keys.None.ToString())
                    {
                        if (HotKeyIsSetEvent != null)
                        {
                            var e = new HotKeyIsSetEventArgs(HotKeyIsSetEvent, UserKey, UserModifier);
                            base.RaiseEvent(e);
                            if (e.Cancel)
                            {
                                this.Text = "";
                            }
                        }
                    }
                    return(IntPtr.Zero);
                }
            }
            catch (OverflowException) { }

            return(IntPtr.Zero);
        }
Ejemplo n.º 7
0
        private void TextBoxKeyDown(object sender, KeyEventArgs e)
        {
            ClearErrorMessage();

            Microsoft.VisualBasic.Devices.Keyboard UserKeyBoard = new Microsoft.VisualBasic.Devices.Keyboard();
            bool AltPressed     = UserKeyBoard.AltKeyDown;
            bool ControlPressed = UserKeyBoard.CtrlKeyDown;
            bool ShiftPressed   = UserKeyBoard.ShiftKeyDown;

            ModifierKeys LocalModifier = ModifierKeys.None;

            if (AltPressed)
            {
                LocalModifier = ModifierKeys.Alt;
            }
            if (ControlPressed)
            {
                LocalModifier |= ModifierKeys.Control;
            }
            if (ShiftPressed)
            {
                LocalModifier |= ModifierKeys.Shift;
            }

            switch (e.Key)
            {
            case Key.Back:
                this.Text = CheckModifier(LocalModifier) ? HotKeyShared.CombineShortcut(LocalModifier, Keys.Back) : "";
                e.Handled = true;
                break;

            case Key.Space:
                this.Text = CheckModifier(LocalModifier) ? HotKeyShared.CombineShortcut(LocalModifier, Keys.Space) : "";
                e.Handled = true;
                break;

            case Key.Delete:
                this.Text = CheckModifier(LocalModifier) ? HotKeyShared.CombineShortcut(LocalModifier, Keys.Delete) : "";
                e.Handled = true;
                break;

            case Key.Home:
                this.Text = CheckModifier(LocalModifier) ? HotKeyShared.CombineShortcut(LocalModifier, Keys.Home) : "";
                e.Handled = true;
                break;

            case Key.PageUp:
                this.Text = CheckModifier(LocalModifier) ? HotKeyShared.CombineShortcut(LocalModifier, Keys.PageUp) : "";
                e.Handled = true;
                break;

            case Key.Next:
                this.Text = CheckModifier(LocalModifier) ? HotKeyShared.CombineShortcut(LocalModifier, Keys.Next) : "";
                e.Handled = true;
                break;

            case Key.End:
                this.Text = CheckModifier(LocalModifier) ? HotKeyShared.CombineShortcut(LocalModifier, Keys.End) : "";
                break;

            case Key.Up:
                this.Text = CheckModifier(LocalModifier) ? HotKeyShared.CombineShortcut(LocalModifier, Keys.Up) : "";
                break;

            case Key.Down:
                this.Text = CheckModifier(LocalModifier) ? HotKeyShared.CombineShortcut(LocalModifier, Keys.Down) : "";
                break;

            case Key.Right:
                this.Text = CheckModifier(LocalModifier) ? HotKeyShared.CombineShortcut(LocalModifier, Keys.Right) : "";
                break;

            case Key.Left:
                this.Text = CheckModifier(LocalModifier) ? HotKeyShared.CombineShortcut(LocalModifier, Keys.Left) : "";
                break;
            }
        }