Predefined keys of this dictionary.
Inheritance: KeysBase
Esempio n. 1
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     // http://support.microsoft.com/kb/320584
     const int WM_KEYDOWN = 0x100;
     if (msg.Msg == WM_KEYDOWN)
     {
         if (keyData.Equals(Keys.Control | Keys.A))
         {
             base.SelectAll();
             return true;
         }
         if (keyData.Equals(Keys.Control | Keys.Back))
         {
             if (SelectionStart - 1 < 0)
                 return true;
             int min = Math.Min(SelectionStart, Text.Length - 1);
             int lastSpace = Text.LastIndexOf(' ', min, min);
             if (lastSpace == -1) // we delete all except symbols after selection
             {
                 Text = Text.Substring(SelectionStart);
                 return true;
             }
             string start =  Text.Substring(0, lastSpace);
             string end = Text.Substring(Math.Min(SelectionStart, Text.Length));
             Text = start + end;
             base.Select(lastSpace, 0);
             return true;
         }
     }
     return base.ProcessCmdKey(ref msg, keyData);
 }
        /// <summary>
        /// Initialise a new instance of the KryptonRibbonGroupNumericUpDown class.
        /// </summary>
        public KryptonRibbonGroupNumericUpDown()
        {
            // Default fields
            _visible = true;
            _enabled = true;
            _itemSizeCurrent = GroupItemSize.Medium;
            _shortcutKeys = Keys.None;
            _keyTip = "X";

            // Create the actual numeric up-down control and set initial settings
            _numericUpDown = new KryptonNumericUpDown();
            _numericUpDown.InputControlStyle = InputControlStyle.Ribbon;
            _numericUpDown.AlwaysActive = false;
            _numericUpDown.MinimumSize = new Size(121, 0);
            _numericUpDown.MaximumSize = new Size(121, 0);
            _numericUpDown.TabStop = false;

            // Hook into events to expose via this container
            _numericUpDown.ValueChanged += new EventHandler(OnNumericUpDownValueChanged);
            _numericUpDown.GotFocus += new EventHandler(OnNumericUpDownGotFocus);
            _numericUpDown.LostFocus += new EventHandler(OnNumericUpDownLostFocus);
            _numericUpDown.KeyDown += new KeyEventHandler(OnNumericUpDownKeyDown);
            _numericUpDown.KeyUp += new KeyEventHandler(OnNumericUpDownKeyUp);
            _numericUpDown.KeyPress += new KeyPressEventHandler(OnNumericUpDownKeyPress);
            _numericUpDown.PreviewKeyDown += new PreviewKeyDownEventHandler(OnNumericUpDownPreviewKeyDown);

            // Ensure we can track mouse events on the numeric up-down
            MonitorControl(_numericUpDown);
        }
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            // focus package combo box
            if (keyData == (Keys.Alt | Keys.P))
            {
                packageComboBox.Focus();
                return true;

            } // focus fragrance combo box
            else if (keyData == (Keys.Alt | Keys.F))
            {
                fragranceComboBox.Focus();
                return true;

            } // focus exterior list box
            else if (keyData == (Keys.Alt | Keys.E))
            {
                exteriorListBox.Focus();
                return true;

            } // focus interior listbox
            else if (keyData == (Keys.Alt | Keys.I))
            {
                interiorListBox.Focus();
                return true;
            }

            // return flase as the key combo wasn't found
            return false;
        }
        protected override bool ProcessDialogKey(Keys keyData) {
            if (keyData == Keys.Escape) {
                SelectedIndex = originalSelectedIndex;
            }

            return base.ProcessDialogKey(keyData);
        }
Esempio n. 5
0
    public void Update(GameTime gameTime, Keys k, Keys p)
    {
        if (Playertype == 0)
        {
            KeyboardState currentKeyboardState = Keyboard.GetState();
            if (currentKeyboardState.IsKeyDown(k)) // getal geeft bewegingssnelheid aan. k is voor omlaag bewegen. 
            {
                Position.Y += 6;
            }

            else if (currentKeyboardState.IsKeyDown(p)) // getal geeft bewegingssnelheid aan. p is voor omhoog bewegen. 
            {
                Position.Y -= 6;
            }
        }
        else if (Playertype == 1)
        {
            for (int i = 0; i <= 5; i++)
            {
                if (this.MiddlePaddle > Pong.getGameState.PlayingBall.MiddleBall)
                {
                    Position.Y -= 1;
                }
                else if (this.MiddlePaddle < Pong.getGameState.PlayingBall.MiddleBall)
                {
                    Position.Y += 1;
                }
            }
        }
        BoundsPaddle.X = (int)Position.X;
        BoundsPaddle.Y = (int)Position.Y;
    }
Esempio n. 6
0
 public KeyboardCombo(Keys key)
 {
     Key = key;
     Alt = false;
     Control = false;
     Shift = false;
 }
Esempio n. 7
0
        public ModuleProperty(MacroList p, MacroModule mod, Keys shortcut)
        {
            _parent = p;
            _prevShortCut = shortcut;
            _module = mod==null? new MacroModule(0) : (MacroModule)mod.Clone();
            //
            // Windows �t�H�[�� �f�U�C�i �T�|�[�g�ɕK�v�ł��B
            //
            InitializeComponent();

            this._titleLabel.Text = GApp.Strings.GetString("Form.ModuleProperty._titleLabel");
            this._pathLabel.Text = GApp.Strings.GetString("Form.ModuleProperty._pathLabel");
            this._additionalAssemblyLabel.Text = GApp.Strings.GetString("Form.ModuleProperty._additionalAssemblyLabel");
            this._shortcutLabel.Text = GApp.Strings.GetString("Form.ModuleProperty._shortcutLabel");
            this._debugOption.Text = GApp.Strings.GetString("Form.ModuleProperty._debugOption");
            this._okButton.Text = GApp.Strings.GetString("Common.OK");
            this._cancelButton.Text = GApp.Strings.GetString("Common.Cancel");
            this.Text = GApp.Strings.GetString("Form.ModuleProperty.Text");

            if(mod!=null) {
                _title.Text = _module.Title;
                _path.Text = _module.Path;
                _additionalAssembly.Text = Concat(_module.AdditionalAssemblies);
                _debugOption.Checked = _module.DebugMode;
                _shortcut.Key = shortcut;
            }
        }
Esempio n. 8
0
 protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, Keys keyData)
 {
     if (processKey(keyData))
         return true;
     else
         return base.ProcessCmdKey(ref msg, keyData);
 }
Esempio n. 9
0
 public KeyboardCombo(Keys key, bool alt, bool control, bool shift)
 {
     Key = key;
     Alt = alt;
     Control = control;
     Shift = shift;
 }
Esempio n. 10
0
 private void InvokeKeyPressed(Keys key)
 {
     if (this.KeyPressed != null)
     {
         this.KeyPressed.Invoke(this, new KeyPressedEventArgs(key));
     }
 }
Esempio n. 11
0
        public string Convert(Keys[] keys)
        {
            string output = "";
            bool usesShift = (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift));

            foreach (Keys key in keys)
            {
                if (key >= Keys.A && key <= Keys.Z)
                    output += key.ToString();
                else if (key >= Keys.NumPad0 && key <= Keys.NumPad9)
                    output += ((int)(key - Keys.NumPad0)).ToString();
                else if (key >= Keys.D0 && key <= Keys.D9)
                {
                    string num = ((int)(key - Keys.D0)).ToString();
                    output += num;
                }
                else if(key == Keys.Space)
                {
                    output += " ";
                }
                else if(key == Keys.OemPeriod)
                {
                    output += ".";
                }

                if (!usesShift) output = output.ToLower();
            }
            return output;
        }
Esempio n. 12
0
        /// <summary>
        /// Gets a character from key information.
        /// </summary>
        /// <param name="key">Pressing key</param>
        /// <param name="shitKeyPressed">Is shift key pressed?</param>
        /// <param name="character">Converted character from key input.</param>
        /// <returns>Returns true when it gets a character</returns>
        public static bool KeyToString(Keys key, bool shitKeyPressed,
                                                                    out char character)
        {
            bool result = false;
            character = ' ';
            CharPair charPair;

            if ((Keys.A <= key && key <= Keys.Z) || key == Keys.Space)
            {
                // Use as is if it is A~Z, or Space key.
                character = (shitKeyPressed) ? (char)key : Char.ToLower((char)key);
                result = true;
            }
            else if (keyMap.TryGetValue(key, out charPair))
            {
                // Otherwise, convert by key map.
                if (!shitKeyPressed)
                {
                    character = charPair.NormalChar;
                    result = true;
                }
                else if (charPair.ShiftChar.HasValue)
                {
                    character = charPair.ShiftChar.Value;
                    result = true;
                }
            }

            return result;
        }
Esempio n. 13
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if ((keyData == Keys.PageDown))
     {
         dataGridView1.ClearSelection();
         dataGridView4.ClearSelection();
         dataGridView4.Focus();
         dataGridView4.Rows[0].Selected = true;
         showDetail(dataGridView4.Rows[0].Cells[1].Value.ToString());
         return true;
     }
     else if (keyData == Keys.PageUp)
     {
         dataGridView1.ClearSelection();
         dataGridView4.ClearSelection();
         dataGridView1.Focus();
         dataGridView1.Rows[0].Selected = true;
         showDetail(dataGridView1.Rows[0].Cells[1].Value.ToString());
         return true;
     }
     else
     {
         return base.ProcessCmdKey(ref msg, keyData);
     }
 }
Esempio n. 14
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if (keyData == Keys.Enter)
     {
         if (!(this.current_focused_control is Button))
         {
             if (this.current_focused_control.Name == this.mskNewSernum.Name)
             {
                 if (ValidateSN.Check(this.mskNewSernum.Text))
                 {
                     SendKeys.Send("{TAB}");
                     return true;
                 }
             }
             else
             {
                 SendKeys.Send("{TAB}");
                 return true;
             }
         }
     }
     if (keyData == Keys.Escape)
     {
         this.DialogResult = DialogResult.Cancel;
         this.Close();
         return true;
     }
     return base.ProcessCmdKey(ref msg, keyData);
 }
Esempio n. 15
0
        public Arrow(Keys lastKey, object obj)
        {
            Image = new Image();
            switch (lastKey)
            {
                case Keys.W:
                    Image.Path = "Gameplay/Projectiles/arrow_up";
                    break;
                case Keys.S:
                    Image.Path = "Gameplay/Projectiles/arrow_down";
                    break;
                case Keys.A:
                    Image.Path = "Gameplay/Projectiles/arrow_left";
                    break;
                case Keys.D:
                    Image.Path = "Gameplay/Projectiles/arrow_right";
                    break;
            }

            DirectionKey = lastKey;

            if (obj.GetType() == typeof(Player))
            {
                Player p = (Player)obj;
                Image.Position = p.Image.Position;
            }
            MoveSpeed = 250f;
            Image.Scale = new Vector2(1, 2);
            Image.LoadContent();
        }
Esempio n. 16
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
                case Keys.F5:
                    _refresh.PerformClick();
                    return true;

                case Keys.Home:
                    _home.PerformClick();
                    return true;

                case Keys.Control | Keys.F:
                    _search.Focus();
                    _search.SelectAll();
                    break;

                case Keys.Escape:
                    if (_isNavigating)
                        _stop.PerformClick();
                    else
                        Close();

                    return true;

                case Keys.Control | Keys.P:
                    _print.PerformClick();
                    break;
            }

            return base.ProcessCmdKey(ref msg, keyData);
        }
Esempio n. 17
0
 public void LoadFromJson(JObject jsonData)
 {
     string tempTriggerKey = (string)jsonData["trigger key"];         // Load String from json
     VirtualKeyCode vkCode = KeyTranslater.GetKeyCode(tempTriggerKey); // Convert the string to a keycode using the Keytranslator
     triggerKey = (Keys)vkCode;                                        // Cast the Vkeycode to a key and save to the class
     commandWord = (string)jsonData["command word"];
 }
Esempio n. 18
0
 // Constructor
 public void GlobalHotkey(int modifier, Keys key, Form form)
 {
     this.modifier = modifier;
     this.key = (int)key;
     this.hWnd = form.Handle;
     id = this.GetHashCode();
 }
Esempio n. 19
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     char cCaracter = (char)keyData;
     if (char.IsLetterOrDigit(cCaracter) || keyData == Keys.Space)
     {
         this.lblBusqueda.Text += cCaracter;
     }
     else
     {
         switch (keyData)
         {
             case Keys.Escape:
                 if (this.lblBusqueda.Text == "")
                     this.Close();
                 else
                     this.lblBusqueda.Text = "";
                 break;
             case Keys.Back:
                 if (this.lblBusqueda.Text != "")
                     this.lblBusqueda.Text = this.lblBusqueda.Text.Izquierda(this.lblBusqueda.Text.Length - 1);
                 break;
             case Keys.Enter:
                 this.dgvListado_CellDoubleClick(this, null);
                 break;
             case Keys.Up:
                 break;
             case Keys.Down:
                 break;
             // default:
                 // return base.ProcessCmdKey(ref msg, keyData);
         }
     }
     return false;
 }
Esempio n. 20
0
        /// <summary>
        /// Gets the human readable representation of the given keys.
        /// </summary>
        /// <param name="keys">Pressed keys</param>
        /// <returns>Keys separated by plus sign</returns>
        public static string GetShortcutString(Keys keys)
        {
            if (keys == Keys.None)
            {
                return string.Empty;
            }

            List<string> singleKeys = new List<string>();

            if ((keys & Keys.Control) == Keys.Control)
            {
                singleKeys.Add("Control");
                keys = keys ^ Keys.Control;
            }
            if ((keys & Keys.Alt) == Keys.Alt)
            {
                singleKeys.Add("Alt");
                keys = keys ^ Keys.Alt;
            }
            if ((keys & Keys.Shift) == Keys.Shift)
            {
                singleKeys.Add("Shift");
                keys = keys ^ Keys.Shift;
            }

            foreach (Keys key in EndKeys)
            {
                if (keys == key)
                {
                    singleKeys.Add(new KeysConverter().ConvertTo(key, typeof(string)) as string);
                }
            }

            return String.Join("+", singleKeys.ToArray());
        }
Esempio n. 21
0
        /// <summary>
        /// Sets the char value for the specified key and key modifier combination
        /// </summary>
        /// <param name="key">The key for which to set the corresponding char value</param>
        /// <param name="mod">The key modifier for which to set the corresponding char value</param>
        /// <param name="ch">The char value to set for the specified key and key modifier</param>
        public static void SetCharacter(Keys key, KeyModifier mod, char ch)
        {
            if (!mMap.ContainsKey(key))
                mMap.Add(key, new Dictionary<KeyModifier, char>());

            mMap[key][mod] = ch;
        }
        public static KeyboardShortcut FromKeys(Keys keys)
        {
            KeyboardShortcut ks = new KeyboardShortcut();

            // check for modifers and remove from val
            if (IsSet(keys, Keys.Control))
            {
                ks.Modifiers |= Keys.Control;
                keys ^= Keys.Control;
            }
            if (IsSet(keys, Keys.Alt))
            {
                ks.Modifiers |= Keys.Alt;
                keys ^= Keys.Alt;
            }
            if (IsSet(keys, Keys.Shift))
            {
                ks.Modifiers |= Keys.Shift;
                keys ^= Keys.Shift;
            }

            // remaining should be the key
            ks.Key = keys;

            return ks;
        }
Esempio n. 23
0
        /// <summary>
        /// キー情報から文字を取得する
        /// </summary>
        /// <param name="key">押下されたキー</param>
        /// <param name="shitKeyPressed">シフトキーが押されていたか?</param>
        /// <param name="character">キー入力から変換された文字</param>
        /// <returns>文字取得が成功した場合trueを返す</returns>
        public static bool KeyToString(Keys key, bool shitKeyPressed,
                                                                    out char character)
        {
            bool result = false;
            character = ' ';
            CharPair charPair;

            if ((Keys.A <= key && key <= Keys.Z) || key == Keys.Space)
            {
                // A~Z、スペースキーはそのまま文字コードとして使用する
                character = (shitKeyPressed) ? (char)key : Char.ToLower((char)key);
                result = true;
            }
            else if (keyMap.TryGetValue(key, out charPair))
            {
                // それ以外の場合はKeyMapの情報を元に変換する
                if (!shitKeyPressed)
                {
                    character = charPair.NormalChar;
                    result = true;
                }
                else if (charPair.ShiftChar.HasValue)
                {
                    character = charPair.ShiftChar.Value;
                    result = true;
                }
            }

            return result;
        }
Esempio n. 24
0
        public virtual Action<KeyboardState, GameTime> Unregister(Keys key)
        {
            Action<KeyboardState, GameTime> action = _keyboardInput[key];
            _keyboardInput.Remove(key);

            return action;
        }
        public static void ProcessKeyPreview(ref Message m, Keys ModifierKeys)
        {
            const int WM_KEYDOWN = 0x100;
            //const int WM_KEYUP = 0x101;
            const int WM_CHAR = 0x102;
            const int WM_SYSCHAR = 0x106;
            const int WM_SYSKEYDOWN = 0x104;
            //const int WM_SYSKEYUP = 0x105;
            const int WM_IME_CHAR = 0x286;

            KeyEventArgs e = null;

            if ((m.Msg != WM_CHAR) && (m.Msg != WM_SYSCHAR) && (m.Msg != WM_IME_CHAR))
            {
                e = new KeyEventArgs(((Keys)((int)((long)m.WParam))) | ModifierKeys);
                if ((m.Msg == WM_KEYDOWN) || (m.Msg == WM_SYSKEYDOWN))
                    control.TrappedKeyDown(e);

                // Remove any WM_CHAR type messages if supresskeypress is true.
                if (e.SuppressKeyPress)
                {
                    RemovePendingMessages(WM_CHAR, WM_CHAR);
                    RemovePendingMessages(WM_SYSCHAR, WM_SYSCHAR);
                    RemovePendingMessages(WM_IME_CHAR, WM_IME_CHAR);
                }
            }
        }
Esempio n. 26
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData.HasFlag(Keys.Control))
            {
                if (keyData.HasFlag(Keys.O))
                {
                    OpenMenuItem.PerformClick();
                    return true;
                }
                if (keyData.HasFlag(Keys.Alt) && keyData.HasFlag(Keys.Shift) && keyData.HasFlag(Keys.S))
                {
                    SaveDecryptedMenuItem.PerformClick();
                    return true;
                }
                if (keyData.HasFlag(Keys.Shift) && keyData.HasFlag(Keys.S))
                {
                    SaveEncryptedMenuItem.PerformClick();
                    return true;
                }
                if (keyData.HasFlag(Keys.S))
                {
                    SaveMenuItem.PerformClick();
                    return true;
                }
            }

            return m_tabPages.Any(tabPage => tabPage.OnHotkey(keyData)) || base.ProcessCmdKey(ref msg, keyData);
        }
        public void Update(GameTime time)
        {
            oldState = currentState;
            currentState = Microsoft.Xna.Framework.Input.Keyboard.GetState();
            shiftDown = currentState.IsKeyDown(Keys.LeftShift) || currentState.IsKeyDown(Keys.RightShift);

            currentlyPressed = currentState.GetPressedKeys();
            previouslyPressed = oldState.GetPressedKeys();

            if (currentlyPressed.Length != previouslyPressed.Length)
            {
                keyHoldTimer = 0.0f;
                keyHeld = false;
                lastKeyHeld = FindLastKeyPressed();
            }

            if (!keyHeld && currentlyPressed.Length > 0)
            {
                keyHoldTimer += (float)time.ElapsedGameTime.TotalMilliseconds;
                if (keyHoldTimer > keyHoldWait)
                {
                    keyHeld = true;
                }
            }
        }
Esempio n. 28
0
 public static bool IsKeyDown(Keys key)
 {
     if (kbState.IsKeyDown(key))
         return true;
     else
         return false;
 }
Esempio n. 29
0
            /// <summary>
            /// Wait until the key gets pressed.
            /// </summary>
            /// <param name="k"></param>
            public void Wait(Keys k)
            {
                if (k == Keys.None)
                    throw new ArgumentException("Must submit valid Key definition!");
                _endKey = k;

                if (this.TimeOutVal.HasValue)
                {
                    _timeoutTimer = new System.Threading.Timer(new System.Threading.TimerCallback(OnTimoutTick));
                    _timeoutTimer.Change(this.TimeOutVal.Value, Timeout.Infinite);
                }
                _keyboardHook.IAKeyEvent += OnKeyEvent;

                while (true)
                {
                    lock (abortLock)
                    {
                        if (abort)
                            break;
                    }
                    Application.DoEvents(); // This is necessary if the Wait Method gets called on the Main GUI Thread
                    Thread.Sleep(2);
                }
                _keyboardHook.IAKeyEvent -= OnKeyEvent;
            }
Esempio n. 30
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if ((keyData & Keys.F5) == Keys.F5)
                this.TriggerCompileButtonClicked();

            return base.ProcessCmdKey(ref msg, keyData);
        }
Esempio n. 31
0
 public bool IsKeyPressed(Keys key)
 {
     return(_currentKeyboardState.IsKeyDown(key) && _lastKeyboarstState.IsKeyUp(key));
 }
Esempio n. 32
0
 public void SetKey(Keys key) => SetKey(new Key(key));
Esempio n. 33
0
 public override bool OnKeyPress(Keys _key)
 {
     return(m_CaptureScreenUI.OnKeyPress(_key));
 }
Esempio n. 34
0
 public bool IsKeyReleased(Keys k)
 {
     return(_previousKeyboardState.IsKeyDown(k) && _currentKeyboardState.IsKeyUp(k));
 }
        public virtual bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewWantsInputKey)
        {
            switch ((keyData & Keys.KeyCode))
            {
            case Keys.PageUp:
            case Keys.Next:
                if (!this.valueChanged)
                {
                    break;
                }
                return(true);

            case Keys.End:
            case Keys.Home:
                if (this.SelectionLength == this.Text.Length)
                {
                    break;
                }
                return(true);

            case Keys.Left:
                if (((this.RightToLeft != RightToLeft.No) || ((this.SelectionLength == 0) && (base.SelectionStart == 0))) && ((this.RightToLeft != RightToLeft.Yes) || ((this.SelectionLength == 0) && (base.SelectionStart == this.Text.Length))))
                {
                    break;
                }
                return(true);

            case Keys.Up:
                if ((this.Text.IndexOf("\r\n") < 0) || ((base.SelectionStart + this.SelectionLength) < this.Text.IndexOf("\r\n")))
                {
                    break;
                }
                return(true);

            case Keys.Right:
                if (((this.RightToLeft != RightToLeft.No) || ((this.SelectionLength == 0) && (base.SelectionStart == this.Text.Length))) && ((this.RightToLeft != RightToLeft.Yes) || ((this.SelectionLength == 0) && (base.SelectionStart == 0))))
                {
                    break;
                }
                return(true);

            case Keys.Down:
            {
                int startIndex = base.SelectionStart + this.SelectionLength;
                if (this.Text.IndexOf("\r\n", startIndex) == -1)
                {
                    break;
                }
                return(true);
            }

            case Keys.Delete:
                if ((this.SelectionLength <= 0) && (base.SelectionStart >= this.Text.Length))
                {
                    break;
                }
                return(true);

            case Keys.Enter:
                if ((((keyData & (Keys.Alt | Keys.Control | Keys.Shift)) == Keys.Shift) && this.Multiline) && base.AcceptsReturn)
                {
                    return(true);
                }
                break;
            }
            return(!dataGridViewWantsInputKey);
        }
Esempio n. 36
0
 private void textBox1_KeyDown(object sender, KeyEventArgs e)
 {
     textBox1.Text = e.KeyCode.ToString();
     enteredKey    = e.KeyCode;
 }
Esempio n. 37
0
 public ShortCutTrigger(Keys shortCutKeys, TriggerState resultState)
 {
     this.shortCut = shortCutKeys;
     this.result = resultState;
 }
Esempio n. 38
0
        public static HotkeySettings[] CreateDefaultSettings()
        {
            HotkeyCommand Hk(object en, Keys k) => new HotkeyCommand((int)en, en.ToString())
            {
                KeyData = k
            };

            const Keys OpenWithDifftoolHotkey   = Keys.F3;
            const Keys OpenAsTempFileHotkey     = Keys.Control | Keys.F3;
            const Keys OpenAsTempFileWithHotkey = Keys.Shift | Keys.Control | Keys.F3;
            const Keys EditFileHotkey           = Keys.F4;
            const Keys OpenFileHotkey           = Keys.Shift | Keys.F4;
            const Keys OpenFileWithHotkey       = Keys.Shift | Keys.Control | Keys.F4;
            const Keys ShowHistoryHotkey        = Keys.H;
            const Keys BlameHotkey = Keys.B;

            return(new[]
            {
                new HotkeySettings(
                    FormCommit.HotkeySettingsName,
                    Hk(FormCommit.Command.AddSelectionToCommitMessage, Keys.C),
                    Hk(FormCommit.Command.AddToGitIgnore, Keys.None),
                    Hk(FormCommit.Command.DeleteSelectedFiles, Keys.Delete),
                    Hk(FormCommit.Command.EditFile, EditFileHotkey),
                    Hk(FormCommit.Command.FocusUnstagedFiles, Keys.Control | Keys.D1),
                    Hk(FormCommit.Command.FocusSelectedDiff, Keys.Control | Keys.D2),
                    Hk(FormCommit.Command.FocusStagedFiles, Keys.Control | Keys.D3),
                    Hk(FormCommit.Command.FocusCommitMessage, Keys.Control | Keys.D4),
                    Hk(FormCommit.Command.OpenFile, OpenFileHotkey),
                    Hk(FormCommit.Command.OpenFileWith, OpenFileWithHotkey),
                    Hk(FormCommit.Command.OpenWithDifftool, OpenWithDifftoolHotkey),
                    Hk(FormCommit.Command.ResetSelectedFiles, Keys.R),
                    Hk(FormCommit.Command.StageSelectedFile, Keys.S),
                    Hk(FormCommit.Command.UnStageSelectedFile, Keys.U),
                    Hk(FormCommit.Command.ShowHistory, ShowHistoryHotkey),
                    Hk(FormCommit.Command.StageAll, Keys.Control | Keys.S),
                    Hk(FormCommit.Command.ToggleSelectionFilter, Keys.Control | Keys.F)),
                new HotkeySettings(
                    FormBrowse.HotkeySettingsName,
                    Hk(FormBrowse.Command.AddNotes, Keys.Control | Keys.Shift | Keys.N),
                    Hk(FormBrowse.Command.CheckoutBranch, Keys.Control | Keys.Decimal),
                    Hk(FormBrowse.Command.CloseRepository, Keys.Control | Keys.W),
                    Hk(FormBrowse.Command.Commit, Keys.Control | Keys.Space),
                    Hk(FormBrowse.Command.EditFile, EditFileHotkey),
                    Hk(FormBrowse.Command.FindFileInSelectedCommit, Keys.Control | Keys.Shift | Keys.F),
                    Hk(FormBrowse.Command.FocusBranchTree, Keys.Control | Keys.D0),
                    Hk(FormBrowse.Command.FocusRevisionGrid, Keys.Control | Keys.D1),
                    Hk(FormBrowse.Command.FocusCommitInfo, Keys.Control | Keys.D2),
                    Hk(FormBrowse.Command.FocusDiff, Keys.Control | Keys.D3),
                    Hk(FormBrowse.Command.FocusFileTree, Keys.Control | Keys.D4),
                    Hk(FormBrowse.Command.FocusGpgInfo, Keys.Control | Keys.D5),
                    Hk(FormBrowse.Command.FocusGitConsole, Keys.Control | Keys.D6),
                    Hk(FormBrowse.Command.FocusBuildServerStatus, Keys.Control | Keys.D7),
                    Hk(FormBrowse.Command.FocusNextTab, Keys.Control | Keys.Tab),
                    Hk(FormBrowse.Command.FocusPrevTab, Keys.Control | Keys.Shift | Keys.Tab),
                    Hk(FormBrowse.Command.FocusFilter, Keys.Control | Keys.E),
                    Hk(FormBrowse.Command.GitBash, Keys.Control | Keys.G),
                    Hk(FormBrowse.Command.GitGui, Keys.None),
                    Hk(FormBrowse.Command.GitGitK, Keys.None),
                    Hk(FormBrowse.Command.GoToSubmodule, Keys.None),
                    Hk(FormBrowse.Command.GoToSuperproject, Keys.None),
                    Hk(FormBrowse.Command.OpenAsTempFile, OpenAsTempFileHotkey),
                    Hk(FormBrowse.Command.OpenAsTempFileWith, OpenAsTempFileWithHotkey),
                    Hk(FormBrowse.Command.OpenSettings, Keys.Control | Keys.Oemcomma),
                    Hk(FormBrowse.Command.OpenWithDifftool, OpenWithDifftoolHotkey),
                    Hk(FormBrowse.Command.QuickFetch, Keys.Control | Keys.Shift | Keys.Down),
                    Hk(FormBrowse.Command.QuickPull, Keys.Control | Keys.Shift | Keys.P),
                    Hk(FormBrowse.Command.QuickPush, Keys.Control | Keys.Shift | Keys.Up),
                    Hk(FormBrowse.Command.Stash, Keys.Control | Keys.Alt | Keys.Up),
                    Hk(FormBrowse.Command.StashPop, Keys.Control | Keys.Alt | Keys.Down),
                    Hk(FormBrowse.Command.ToggleBranchTreePanel, Keys.Control | Keys.Alt | Keys.C)),
                new HotkeySettings(
                    RevisionGridControl.HotkeySettingsName,
                    Hk(RevisionGridControl.Commands.CompareSelectedCommits, Keys.None),
                    Hk(RevisionGridControl.Commands.CompareToBase, Keys.Control | Keys.R),
                    Hk(RevisionGridControl.Commands.CompareToBranch, Keys.None),
                    Hk(RevisionGridControl.Commands.CompareToCurrentBranch, Keys.None),
                    Hk(RevisionGridControl.Commands.CompareToWorkingDirectory, Keys.Control | Keys.D),
                    Hk(RevisionGridControl.Commands.CreateFixupCommit, Keys.Control | Keys.X),
                    Hk(RevisionGridControl.Commands.GoToCommit, Keys.Control | Keys.Shift | Keys.G),
                    Hk(RevisionGridControl.Commands.GoToParent, Keys.Control | Keys.P),
                    Hk(RevisionGridControl.Commands.GoToChild, Keys.Control | Keys.N),
                    Hk(RevisionGridControl.Commands.NextQuickSearch, Keys.Alt | Keys.Down),
                    Hk(RevisionGridControl.Commands.PrevQuickSearch, Keys.Alt | Keys.Up),
                    Hk(RevisionGridControl.Commands.RevisionFilter, Keys.Control | Keys.F),
                    Hk(RevisionGridControl.Commands.SelectCurrentRevision, Keys.Control | Keys.Shift | Keys.C),
                    Hk(RevisionGridControl.Commands.SelectAsBaseToCompare, Keys.Control | Keys.L),
                    Hk(RevisionGridControl.Commands.ShowAllBranches, Keys.Control | Keys.Shift | Keys.A),
                    Hk(RevisionGridControl.Commands.ShowCurrentBranchOnly, Keys.Control | Keys.Shift | Keys.U),
                    Hk(RevisionGridControl.Commands.ShowFilteredBranches, Keys.Control | Keys.Shift | Keys.T),
                    Hk(RevisionGridControl.Commands.ShowFirstParent, Keys.Control | Keys.Shift | Keys.S),
                    Hk(RevisionGridControl.Commands.ShowRemoteBranches, Keys.Control | Keys.Shift | Keys.R),
                    Hk(RevisionGridControl.Commands.ToggleRevisionGraph, Keys.None),
                    Hk(RevisionGridControl.Commands.ToggleAuthorDateCommitDate, Keys.None),
                    Hk(RevisionGridControl.Commands.ToggleOrderRevisionsByDate, Keys.None),
                    Hk(RevisionGridControl.Commands.ToggleShowRelativeDate, Keys.None),
                    Hk(RevisionGridControl.Commands.ToggleDrawNonRelativesGray, Keys.None),
                    Hk(RevisionGridControl.Commands.ToggleShowGitNotes, Keys.None),
                    Hk(RevisionGridControl.Commands.ToggleShowMergeCommits, Keys.Control | Keys.Shift | Keys.M),
                    Hk(RevisionGridControl.Commands.ToggleShowTags, Keys.Control | Keys.Alt | Keys.T),
                    Hk(RevisionGridControl.Commands.ToggleHighlightSelectedBranch, Keys.Control | Keys.Shift | Keys.B)),
                new HotkeySettings(
                    FileViewer.HotkeySettingsName,
                    Hk(FileViewer.Commands.Find, Keys.Control | Keys.F),
                    Hk(FileViewer.Commands.FindNextOrOpenWithDifftool, OpenWithDifftoolHotkey),
                    Hk(FileViewer.Commands.FindPrevious, Keys.Shift | OpenWithDifftoolHotkey),
                    Hk(FileViewer.Commands.GoToLine, Keys.Control | Keys.G),
                    Hk(FileViewer.Commands.IncreaseNumberOfVisibleLines, Keys.None),
                    Hk(FileViewer.Commands.DecreaseNumberOfVisibleLines, Keys.None),
                    Hk(FileViewer.Commands.NextChange, Keys.Alt | Keys.Down),
                    Hk(FileViewer.Commands.PreviousChange, Keys.Alt | Keys.Up),
                    Hk(FileViewer.Commands.ShowEntireFile, Keys.None),
                    Hk(FileViewer.Commands.TreatFileAsText, Keys.None)),
                new HotkeySettings(
                    FormResolveConflicts.HotkeySettingsName,
                    Hk(FormResolveConflicts.Commands.ChooseBase, Keys.B),
                    Hk(FormResolveConflicts.Commands.ChooseLocal, Keys.L),
                    Hk(FormResolveConflicts.Commands.ChooseRemote, Keys.R),
                    Hk(FormResolveConflicts.Commands.Merge, Keys.M),
                    Hk(FormResolveConflicts.Commands.Rescan, Keys.F5)),
                new HotkeySettings(
                    RevisionDiffControl.HotkeySettingsName,
                    Hk(RevisionDiffControl.Command.Blame, BlameHotkey),
                    Hk(RevisionDiffControl.Command.DeleteSelectedFiles, Keys.Delete),
                    Hk(RevisionDiffControl.Command.EditFile, EditFileHotkey),
                    Hk(RevisionDiffControl.Command.OpenAsTempFile, OpenAsTempFileHotkey),
                    Hk(RevisionDiffControl.Command.OpenAsTempFileWith, OpenAsTempFileWithHotkey),
                    Hk(RevisionDiffControl.Command.OpenWithDifftool, OpenWithDifftoolHotkey),
                    Hk(RevisionDiffControl.Command.ShowHistory, ShowHistoryHotkey)),
                new HotkeySettings(
                    RevisionFileTreeControl.HotkeySettingsName,
                    Hk(RevisionFileTreeControl.Command.Blame, BlameHotkey),
                    Hk(RevisionFileTreeControl.Command.EditFile, EditFileHotkey),
                    Hk(RevisionFileTreeControl.Command.OpenAsTempFile, OpenAsTempFileHotkey),
                    Hk(RevisionFileTreeControl.Command.OpenAsTempFileWith, OpenAsTempFileWithHotkey),
                    Hk(RevisionFileTreeControl.Command.OpenWithDifftool, OpenWithDifftoolHotkey),
                    Hk(RevisionFileTreeControl.Command.ShowHistory, ShowHistoryHotkey)),
                new HotkeySettings(
                    FormSettings.HotkeySettingsName,
                    LoadScriptHotkeys())
            });

            HotkeyCommand[] LoadScriptHotkeys()
            {
                /* define unusable int for identifying a shortcut for a custom script is pressed
                 * all integers above 9000 represent a script hotkey
                 * these integers are never matched in the 'switch' routine on a form and
                 * therefore execute the 'default' action
                 */
                return(ScriptManager
                       .GetScripts()
                       .Where(s => !s.Name.IsNullOrEmpty())
                       .Select(s => new HotkeyCommand(s.HotkeyCommandIdentifier, s.Name)
                {
                    KeyData = Keys.None
                })
                       .ToArray());
            }
        }
Esempio n. 39
0
 bool IsKeyUp(Keys key) => state.IsKeyUp(key) && prevState.IsKeyDown(key);
Esempio n. 40
0
 /// <summary>
 /// Returns whether the hotkey is already assigned.
 /// </summary>
 public static bool IsUniqueKey(Keys keyData)
 {
     return(_usedKeys.Contains(keyData));
 }
Esempio n. 41
0
 bool IsKeyHold(Keys key) => state.IsKeyDown(key);
Esempio n. 42
0
 protected override void OnKeyDown(Keys keyCode)
 {
     GetElementById("ErrMsg").Style = "display:none";
     InputNumber("UserNo", keyCode);
     base.OnKeyDown(keyCode);
 }
Esempio n. 43
0
 /// <include file='doc\Menu.uex' path='docs/doc[@for="ContextMenu.ProcessCmdKey"]/*' />
 /// <devdoc>
 /// </devdoc>
 /// <internalonly/>
 protected internal virtual bool ProcessCmdKey(ref Message msg, Keys keyData, Control control)
 {
     sourceControl = control;
     return(ProcessCmdKey(ref msg, keyData));
 }
Esempio n. 44
0
 bool IsKeyDown(Keys key) => state.IsKeyDown(key) && !prevState.IsKeyDown(key);
Esempio n. 45
0
 /// <summary>
 /// Returns whether the key is down this tick
 /// </summary>
 public static bool KeyDown(Keys keyCode)
 {
     return currentKeyboardState.IsKeyDown(keyCode);
 }
Esempio n. 46
0
        public static ECHotkey RegisterHotkey(Keys _key, Keys _modifiers, ECHotKeyHelperDelegate _callback)
        {
            int keyAndModifiers = (int)_key | (int)_modifiers;

            return(RegisterHotkey((Keys)keyAndModifiers, _callback));
        }
Esempio n. 47
0
		public static bool KeyboardKeyPressed(Keys key)
		{
			return keyboardState.IsKeyDown (key);
		}
Esempio n. 48
0
 /// <summary>
 /// Returns whether the key was pressed this tick
 /// </summary>
 public static bool KeyPressed(Keys keyCode)
 {
     return oldKeyboardState.IsKeyUp(keyCode) && currentKeyboardState.IsKeyDown(keyCode);
 }
        /// <summary>
        /// Adds the string representation of the given key to another
        /// string. Backspace removes a character. Applies the second
        /// character on a US keyboard if shift is pressed, e.g.
        /// uppercase and symbols instead of numbers.
        /// </summary>
        /// <param name="str">
        /// A string to append the key to.
        /// </param>
        /// <param name="key">
        /// The key to append to the string.
        /// </param>
        /// <param name="shiftPressed">
        /// Whether or not shift is active. Capslock is detected automatically.
        /// </param>
        public static string KeyToString(
            String str,
            Keys key,
            bool shiftPressed)
        {
            //Checks for backspace.
            if (key == Keys.Back && str.Length != 0)
            {
                str = str.Remove(str.Length - 1);
            }

            //Checks for letters.
            else if (IsLetter(key))
            {
                if (Console.CapsLock == true || shiftPressed)
                {
                    str += key.ToString();
                }
                else
                {
                    str += key.ToString().ToLower();
                }
            }

            //Checks for keys that have shift-based variants.
            else if (shiftPressed)
            {
                //Digits
                if (key == Keys.D0 || key == Keys.NumPad0)
                {
                    str += ")";
                }
                else if (key == Keys.D1 || key == Keys.NumPad1)
                {
                    str += "!";
                }
                else if (key == Keys.D2 || key == Keys.NumPad2)
                {
                    str += "@";
                }
                else if (key == Keys.D3 || key == Keys.NumPad3)
                {
                    str += "#";
                }
                else if (key == Keys.D4 || key == Keys.NumPad4)
                {
                    str += "$";
                }
                else if (key == Keys.D5 || key == Keys.NumPad5)
                {
                    str += "%";
                }
                else if (key == Keys.D6 || key == Keys.NumPad6)
                {
                    str += "^";
                }
                else if (key == Keys.D7 || key == Keys.NumPad7)
                {
                    str += "&";
                }
                else if (key == Keys.D8 || key == Keys.NumPad8)
                {
                    str += "*";
                }
                else if (key == Keys.D9 || key == Keys.NumPad9)
                {
                    str += "(";
                }

                //Punctuation
                else if (key == Keys.OemTilde)
                {
                    str += "~";
                }
                else if (key == Keys.OemOpenBrackets)
                {
                    str += "{";
                }
                else if (key == Keys.OemCloseBrackets)
                {
                    str += "}";
                }
                else if (key == Keys.OemSemicolon)
                {
                    str += ":";
                }
                else if (key == Keys.OemQuotes)
                {
                    str += "\"";
                }
                else if (key == Keys.OemComma)
                {
                    str += "<";
                }
                else if (key == Keys.OemPeriod || key == Keys.Decimal)
                {
                    str += ">";
                }
                else if (key == Keys.OemQuestion)
                {
                    str += "?";
                }
                else if (key == Keys.OemMinus)
                {
                    str += "_";
                }
                else if (key == Keys.OemPlus)
                {
                    str += "+";
                }
                else if (key == Keys.OemPipe)
                {
                    str += "|";
                }
            }
            else
            {
                //Digits
                if (key == Keys.D0 || key == Keys.NumPad0)
                {
                    str += "0";
                }
                else if (key == Keys.D1 || key == Keys.NumPad1)
                {
                    str += "1";
                }
                else if (key == Keys.D2 || key == Keys.NumPad2)
                {
                    str += "2";
                }
                else if (key == Keys.D3 || key == Keys.NumPad3)
                {
                    str += "3";
                }
                else if (key == Keys.D4 || key == Keys.NumPad4)
                {
                    str += "4";
                }
                else if (key == Keys.D5 || key == Keys.NumPad5)
                {
                    str += "5";
                }
                else if (key == Keys.D6 || key == Keys.NumPad6)
                {
                    str += "6";
                }
                else if (key == Keys.D7 || key == Keys.NumPad7)
                {
                    str += "7";
                }
                else if (key == Keys.D8 || key == Keys.NumPad8)
                {
                    str += "8";
                }
                else if (key == Keys.D9 || key == Keys.NumPad9)
                {
                    str += "9";
                }

                //Punctuation
                if (key == Keys.OemTilde)
                {
                    str += "`";
                }
                else if (key == Keys.OemOpenBrackets)
                {
                    str += "[";
                }
                else if (key == Keys.OemCloseBrackets)
                {
                    str += "]";
                }
                else if (key == Keys.OemSemicolon)
                {
                    str += ";";
                }
                else if (key == Keys.OemQuotes)
                {
                    str += "'";
                }
                else if (key == Keys.OemComma)
                {
                    str += ",";
                }
                else if (key == Keys.OemPeriod || key == Keys.Decimal)
                {
                    str += ".";
                }
                else if (key == Keys.OemQuestion)
                {
                    str += "/";
                }
                else if (key == Keys.OemMinus)
                {
                    str += "-";
                }
                else if (key == Keys.OemPlus)
                {
                    str += "=";
                }
                else if (key == Keys.OemPipe)
                {
                    str += @"\";
                }
            }

            //Miscellaneous keys and punctuation
            if (key == Keys.Space)
            {
                str += " ";
            }
            else if (key == Keys.Divide)
            {
                str += "/";
            }
            else if (key == Keys.Add)
            {
                str += "+";
            }
            else if (key == Keys.Subtract)
            {
                str += "-";
            }
            else if (key == Keys.Multiply)
            {
                str += "*";
            }

            //If the key pressed was other (like unprintable chars)
            return(str);
        }
Esempio n. 50
0
 public virtual TriggerState OnCommandKey(Keys keyData)
 {
     return(TriggerState.None);
 }
Esempio n. 51
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            gf.ArrowInput(keyData);

            return(base.ProcessCmdKey(ref msg, keyData));
        }
Esempio n. 52
0
		public static bool KeyboardKeyJustPressed(Keys key)
		{
			return keyboardState.IsKeyDown(key) &&
				keysPressedLastFrame.Contains(key) == false;
		}
Esempio n. 53
0
        private void SelectByKey(Keys keys, string keyInput = "", bool keepSelection = false)
        {
            int iRowBefore  = iRowKey;
            int iMenuBefore = iMenuKey;

            Menu         menu             = menus[iMenuKey];
            DataGridView dgv              = null;
            DataGridView dgvBefore        = null;
            Menu         menuFromSelected = null;
            string       textselected     = string.Empty;
            bool         isStillSelected  = IsAnyMenuSelectedByKey(ref dgv, ref menuFromSelected, ref textselected);

            if (isStillSelected)
            {
                if (keepSelection)
                {
                    // If current selection is still valid for this search then skip selecting different item
                    if (textselected.StartsWith(keyInput, true, CultureInfo.InvariantCulture))
                    {
                        return;
                    }
                }

                dgvBefore = dgv;
            }
            else
            {
                ResetSelectedByKey();
                menu = menus[iMenuKey];
                dgv  = menu.GetDataGridView();
            }

            bool toClear = false;

            switch (keys)
            {
            case Keys.Enter:
                if (iRowKey > -1 &&
                    dgv.Rows.Count > iRowKey)
                {
                    RowData trigger = (RowData)dgv.Rows[iRowKey].Cells[2].Value;
                    if (trigger.IsMenuOpen || !trigger.ContainsMenu)
                    {
                        trigger.MouseDown(dgv, null);
                        trigger.DoubleClick(
                            new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0));
                    }
                    else
                    {
                        RowDeselected(iRowBefore, dgvBefore);
                        SelectRow(dgv, iRowKey);
                        EnterPressed.Invoke(dgv, iRowKey);
                    }
                }

                break;

            case Keys.Up:
                if (SelectMatchedReverse(dgv, iRowKey) ||
                    SelectMatchedReverse(dgv, dgv.Rows.Count - 1))
                {
                    RowDeselected(iRowBefore, dgvBefore);
                    SelectRow(dgv, iRowKey);
                    toClear = true;
                }

                break;

            case Keys.Down:
                if (SelectMatched(dgv, iRowKey) ||
                    SelectMatched(dgv, 0))
                {
                    RowDeselected(iRowBefore, dgvBefore);
                    SelectRow(dgv, iRowKey);
                    toClear = true;
                }

                break;

            case Keys.Left:
                int iMenuKeyNext = iMenuKey + 1;
                if (isStillSelected)
                {
                    if (menuFromSelected != null &&
                        menuFromSelected == menus[iMenuKeyNext])
                    {
                        dgv = menuFromSelected.GetDataGridView();
                        if (dgv.Rows.Count > 0)
                        {
                            iMenuKey += 1;
                            iRowKey   = -1;
                            if (SelectMatched(dgv, iRowKey) ||
                                SelectMatched(dgv, 0))
                            {
                                RowDeselected(iRowBefore, dgvBefore);
                                SelectRow(dgv, iRowKey);
                                toClear = true;
                            }
                        }
                    }
                }
                else
                {
                    iRowKey  = -1;
                    iMenuKey = menus.Where(m => m != null).Count() - 1;
                    if (menus[iMenuKey] != null)
                    {
                        dgv = menus[iMenuKey].GetDataGridView();
                        if (SelectMatched(dgv, iRowKey) ||
                            SelectMatched(dgv, 0))
                        {
                            RowDeselected(iRowBefore, dgvBefore);
                            SelectRow(dgv, iRowKey);
                            toClear = true;
                        }
                    }
                }

                break;

            case Keys.Right:
                if (iMenuKey > 0)
                {
                    if (menus[iMenuKey - 1] != null)
                    {
                        iMenuKey -= 1;
                        iRowKey   = -1;
                        menu      = menus[iMenuKey];
                        dgv       = menu.GetDataGridView();
                        if (SelectMatched(dgv, dgv.SelectedRows[0].Index) ||
                            SelectMatched(dgv, 0))
                        {
                            RowDeselected(iRowBefore, dgvBefore);
                            SelectRow(dgv, iRowKey);
                            toClear = true;
                        }
                    }
                }
                else
                {
                    RowDeselected(iRowBefore, dgvBefore);
                    iMenuKey = 0;
                    iRowKey  = -1;
                    toClear  = true;
                    Cleared?.Invoke();
                }

                break;

            case Keys.Escape:
                RowDeselected(iRowBefore, dgvBefore);
                iMenuKey = 0;
                iRowKey  = -1;
                toClear  = true;
                ClosePressed?.Invoke();
                break;

            default:
                if (!string.IsNullOrEmpty(keyInput))
                {
                    if (SelectMatched(dgv, iRowKey, keyInput) ||
                        SelectMatched(dgv, 0, keyInput))
                    {
                        RowDeselected(iRowBefore, null);
                        SelectRow(dgv, iRowKey);
                        toClear = true;
                    }
                    else if (isStillSelected)
                    {
                        iRowKey = iRowBefore - 1;
                        if (SelectMatched(dgv, iRowKey, keyInput) ||
                            SelectMatched(dgv, 0, keyInput))
                        {
                            RowDeselected(iRowBefore, null);
                            SelectRow(dgv, iRowKey);
                        }
                        else
                        {
                            iRowKey = iRowBefore;
                        }
                    }
                }

                break;
            }

            if (isStillSelected && toClear)
            {
                ClearIsSelectedByKey(iMenuBefore, iRowBefore);
            }
        }
 public static extern void keybd_event(Keys bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
Esempio n. 55
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            const int WM_KEYDOWN    = 0x100;
            const int WM_SYSKEYDOWN = 0x104;

            if (keyData == (Keys.Shift | Keys.ShiftKey))
            {
                return(true);
            }

            if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
            {
                //bool bShiftKey = (keyData.HasFlag(Keys.Shift));
                //Keys keyDataLower = keyData;
                //keyData.GetHashCode();
                //keyDataLower.GetTypeCode

                switch (keyData)
                {
                case Keys.A: PlaySound('a'); break;

                case Keys.B: PlaySound('b'); break;

                case Keys.C: PlaySound('c'); break;

                case Keys.D: PlaySound('d'); break;

                case Keys.E: PlaySound('e'); break;

                case Keys.F: PlaySound('f'); break;

                case Keys.G: PlaySound('g'); break;

                case Keys.H: PlaySound('h'); break;

                case Keys.I: PlaySound('i'); break;

                case Keys.J: PlaySound('j'); break;

                case Keys.K: PlaySound('k'); break;

                case Keys.L: PlaySound('l'); break;

                case Keys.M: PlaySound('m'); break;

                case Keys.N: PlaySound('n'); break;

                case Keys.O: PlaySound('o'); break;

                case Keys.P: PlaySound('p'); break;

                case Keys.Q: PlaySound('q'); break;

                case Keys.R: PlaySound('r'); break;

                case Keys.S: PlaySound('s'); break;

                case Keys.T: PlaySound('t'); break;

                case Keys.U: PlaySound('u'); break;

                case Keys.V: PlaySound('v'); break;

                case Keys.W: PlaySound('w'); break;

                case Keys.X: PlaySound('x'); break;

                case Keys.Y: PlaySound('y'); break;

                case Keys.Z: PlaySound('z'); break;

                case Keys.Shift | Keys.A: PlaySound('A'); break;

                case Keys.Shift | Keys.B: PlaySound('B'); break;

                case Keys.Shift | Keys.C: PlaySound('C'); break;

                case Keys.Shift | Keys.D: PlaySound('D'); break;

                case Keys.Shift | Keys.E: PlaySound('E'); break;

                case Keys.Shift | Keys.F: PlaySound('F'); break;

                case Keys.Shift | Keys.G: PlaySound('G'); break;

                case Keys.Shift | Keys.H: PlaySound('H'); break;

                case Keys.Shift | Keys.I: PlaySound('I'); break;

                case Keys.Shift | Keys.J: PlaySound('J'); break;

                case Keys.Shift | Keys.K: PlaySound('K'); break;

                case Keys.Shift | Keys.L: PlaySound('L'); break;

                case Keys.Shift | Keys.M: PlaySound('M'); break;

                case Keys.Shift | Keys.N: PlaySound('N'); break;

                case Keys.Shift | Keys.O: PlaySound('O'); break;

                case Keys.Shift | Keys.P: PlaySound('P'); break;

                case Keys.Shift | Keys.Q: PlaySound('Q'); break;

                case Keys.Shift | Keys.R: PlaySound('R'); break;

                case Keys.Shift | Keys.S: PlaySound('S'); break;

                case Keys.Shift | Keys.T: PlaySound('T'); break;

                case Keys.Shift | Keys.U: PlaySound('U'); break;

                case Keys.Shift | Keys.V: PlaySound('V'); break;

                case Keys.Shift | Keys.W: PlaySound('W'); break;

                case Keys.Shift | Keys.X: PlaySound('X'); break;

                case Keys.Shift | Keys.Y: PlaySound('Y'); break;

                case Keys.Shift | Keys.Z: PlaySound('Z'); break;

                case Keys.D1: PlaySound('1'); break;

                case Keys.D2: PlaySound('2'); break;

                case Keys.D3: PlaySound('3'); break;

                case Keys.D4: PlaySound('4'); break;

                case Keys.D5: PlaySound('5'); break;

                case Keys.D6: PlaySound('6'); break;

                case Keys.D7: PlaySound('7'); break;

                case Keys.D8: PlaySound('8'); break;

                case Keys.D9: PlaySound('9'); break;

                case Keys.D0: PlaySound('0'); break;

                case Keys.Shift | Keys.D1: PlaySound('!'); break;

                case Keys.Shift | Keys.D2: PlaySound('@'); break;

                case Keys.Shift | Keys.D3: PlaySound('#'); break;

                case Keys.Shift | Keys.D4: PlaySound('$'); break;

                case Keys.Shift | Keys.D5: PlaySound('%'); break;

                case Keys.Shift | Keys.D6: PlaySound('^'); break;

                case Keys.Shift | Keys.D7: PlaySound('&'); break;

                case Keys.Shift | Keys.D8: PlaySound('*'); break;

                case Keys.Shift | Keys.D9: PlaySound('('); break;

                case Keys.Shift | Keys.D0: PlaySound(')'); break;

                case Keys.OemCloseBrackets: PlaySound(']'); break;

                case Keys.Shift | Keys.OemCloseBrackets: PlaySound('}'); break;

                case Keys.Oemcomma: PlaySound(','); break;

                case Keys.Shift | Keys.Oemcomma: PlaySound('<'); break;

                case Keys.OemMinus: PlaySound('-'); break;

                case Keys.Shift | Keys.OemMinus: PlaySound('_'); break;

                case Keys.OemOpenBrackets: PlaySound('['); break;

                case Keys.Shift | Keys.OemOpenBrackets: PlaySound('{'); break;

                case Keys.OemPeriod: PlaySound('.'); break;

                case Keys.Shift | Keys.OemPeriod: PlaySound('>'); break;

                case Keys.Oemplus: PlaySound('='); break;

                case Keys.Shift | Keys.Oemplus: PlaySound('+'); break;

                case Keys.OemQuestion: PlaySound('/'); break;

                case Keys.Shift | Keys.OemQuestion: PlaySound('?'); break;

                case Keys.OemQuotes: PlaySound('\''); break;

                case Keys.Shift | Keys.OemQuotes: PlaySound('"'); break;

                case Keys.OemSemicolon: PlaySound(';'); break;

                case Keys.Shift | Keys.OemSemicolon: PlaySound(':'); break;

                case Keys.Space: StopSound(); break;

                case Keys.Shift | Keys.Space: StopSound(); break;
                }
            }

            return(true);
        }
Esempio n. 56
0
        internal void CmdKeyProcessed(object sender, Keys keys)
        {
            switch (keys)
            {
            case Keys.Enter:
            case Keys.Up:
            case Keys.Down:
            case Keys.Left:
            case Keys.Right:
            case Keys.Escape:
                SelectByKey(keys);
                break;

            case Keys.Control | Keys.F:
                Menu menu = menus[iMenuKey];
                menu.FocusTextBox();
                break;

            case Keys.Tab:
            {
                Menu currentMenu           = (Menu)sender;
                int  indexOfTheCurrentMenu = GetMenuIndex(currentMenu);
                int  indexMax = menus.Where(m => m != null).Count() - 1;
                int  indexNew = 0;
                if (indexOfTheCurrentMenu > 0)
                {
                    indexNew = indexOfTheCurrentMenu - 1;
                }
                else
                {
                    indexNew = indexMax;
                }

                menus[indexNew].FocusTextBox();
            }

            break;

            case Keys.Tab | Keys.Shift:
            {
                Menu currentMenu           = (Menu)sender;
                int  indexOfTheCurrentMenu = GetMenuIndex(currentMenu);
                int  indexMax = menus.Where(m => m != null).Count() - 1;
                int  indexNew = 0;
                if (indexOfTheCurrentMenu < indexMax)
                {
                    indexNew = indexOfTheCurrentMenu + 1;
                }
                else
                {
                    indexNew = 0;
                }

                menus[indexNew].FocusTextBox();
            }

            break;

            case Keys.Apps:
            {
                DataGridView dgv = menus[iMenuKey].GetDataGridView();

                if (iRowKey > -1 &&
                    dgv.Rows.Count > iRowKey)
                {
                    Point          pt      = dgv.GetCellDisplayRectangle(2, iRowKey, false).Location;
                    RowData        trigger = (RowData)dgv.Rows[iRowKey].Cells[2].Value;
                    MouseEventArgs mea     = new MouseEventArgs(MouseButtons.Right, 1, pt.X, pt.Y, 0);
                    trigger.MouseDown(dgv, mea);
                }
            }

            break;

            default:
                break;
            }

            int GetMenuIndex(in Menu currentMenu)
            {
                int index = 0;

                foreach (Menu menuFindIndex in menus.Where(m => m != null))
                {
                    if (currentMenu == menuFindIndex)
                    {
                        break;
                    }

                    index++;
                }

                return(index);
            }
        }
Esempio n. 57
0
 public KeyboardKeys(OverlapBehaviors overlapBehavior, Keys left, Keys right, Keys up, Keys down)
 {
     OverlapBehavior = overlapBehavior;
     Left            = left;
     Right           = right;
     Up   = up;
     Down = down;
 }
Esempio n. 58
0
 static extern short GetAsyncKeyState(Keys key);
Esempio n. 59
0
 public static bool IsHotkey(this KeyEventArgs eventData, Keys key, bool ctrl = false, bool shift = false, bool alt = false)
 {
     return(eventData.KeyCode == key && eventData.Control == ctrl && eventData.Shift == shift && eventData.Alt == alt);
 }
Esempio n. 60
0
        protected internal override bool ProcessKeyMessage(ref Message m)
        {
            Keys key          = (Keys) unchecked ((int)(long)m.WParam);
            Keys modifierKeys = ModifierKeys;

            if ((key | modifierKeys) == Keys.Enter || (key | modifierKeys) == Keys.Escape || ((key | modifierKeys) == (Keys.Enter | Keys.Control))
                )
            {
                // enter and escape keys are sent directly to the DataGrid
                // for those keys, eat the WM_CHAR part of the KeyMessage
                //
                if (m.Msg == Interop.WindowMessages.WM_CHAR)
                {
                    return(true);
                }

                return(ProcessKeyPreview(ref m));
            }

            if (m.Msg == Interop.WindowMessages.WM_CHAR)
            {
                if (key == Keys.LineFeed)           // eat the LineFeed we get when the user presses Ctrl-Enter in a gridTextBox
                {
                    return(true);
                }

                return(ProcessKeyEventArgs(ref m));
            }

            // now the edit control will be always on top of the grid
            // we only want to process the WM_KEYUP message ( the same way the grid was doing when the grid was getting all
            // the keys )
            if (m.Msg == Interop.WindowMessages.WM_KEYUP)
            {
                return(true);
            }

            Keys keyData = key & Keys.KeyCode;

            switch (keyData)
            {
            case Keys.Right:
                // here is the deal with Keys.Right:
                // if the end of the selection is at the end of the string
                // send this character to the dataGrid
                // else, process the KeyEvent
                //
                if (SelectionStart + SelectionLength == Text.Length)
                {
                    return(ProcessKeyPreview(ref m));
                }

                return(ProcessKeyEventArgs(ref m));

            case Keys.Left:
                // if the end of the selection is at the begining of the string
                // or if the entire text is selected and we did not start editing
                // send this character to the dataGrid
                // else, process the KeyEvent
                //
                if (SelectionStart + SelectionLength == 0 ||
                    (IsInEditOrNavigateMode && SelectionLength == Text.Length))
                {
                    return(ProcessKeyPreview(ref m));
                }

                return(ProcessKeyEventArgs(ref m));

            case Keys.Down:
                // if the end of the selection is on the last line of the text then
                // send this character to the dataGrid
                // else, process the KeyEvent
                //
                int end = SelectionStart + SelectionLength;
                if (Text.IndexOf("\r\n", end) == -1)
                {
                    return(ProcessKeyPreview(ref m));
                }

                return(ProcessKeyEventArgs(ref m));

            case Keys.Up:
                // if the end of the selection is on the first line of the text then
                // send this character to the dataGrid
                // else, process the KeyEvent
                //
                if (Text.IndexOf("\r\n") < 0 || SelectionStart + SelectionLength < Text.IndexOf("\r\n"))
                {
                    return(ProcessKeyPreview(ref m));
                }

                return(ProcessKeyEventArgs(ref m));

            case Keys.Home:
            case Keys.End:
                if (SelectionLength == Text.Length)
                {
                    return(ProcessKeyPreview(ref m));
                }
                else
                {
                    return(ProcessKeyEventArgs(ref m));
                }

            case Keys.Prior:
            case Keys.Next:
            case Keys.Oemplus:
            case Keys.Add:
            case Keys.OemMinus:
            case Keys.Subtract:
                if (IsInEditOrNavigateMode)
                {
                    // this will ultimately call parent's ProcessKeyPreview
                    // in our case, DataGrid's ProcessKeyPreview
                    return(ProcessKeyPreview(ref m));
                }
                else
                {
                    return(ProcessKeyEventArgs(ref m));
                }

            case Keys.Space:
                if (IsInEditOrNavigateMode && (Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                {
                    // when we get a SHIFT-SPACEBAR message, disregard the WM_CHAR part of the message
                    if (m.Msg == Interop.WindowMessages.WM_CHAR)
                    {
                        return(true);
                    }

                    // if the user pressed the SHIFT key at the same time with
                    // the space key, send the key message to the DataGrid
                    return(ProcessKeyPreview(ref m));
                }
                return(ProcessKeyEventArgs(ref m));

            case Keys.A:
                if (IsInEditOrNavigateMode && (Control.ModifierKeys & Keys.Control) == Keys.Control)
                {
                    // when we get a Control-A message, disregard the WM_CHAR part of the message
                    if (m.Msg == Interop.WindowMessages.WM_CHAR)
                    {
                        return(true);
                    }

                    // if the user pressed the Control key at the same time with
                    // the space key, send the key message to the DataGrid
                    return(ProcessKeyPreview(ref m));
                }
                return(ProcessKeyEventArgs(ref m));

            case Keys.F2:
                IsInEditOrNavigateMode = false;
                // do not select all the text, but
                // position the caret at the end of the text
                SelectionStart = Text.Length;
                return(true);

            case Keys.Delete:
                if (IsInEditOrNavigateMode)
                {
                    // pass the delete to the parent, in our case, the DataGrid
                    // if the dataGrid used the key, then we aren't gonne
                    // use it anymore, else we are
                    if (ProcessKeyPreview(ref m))
                    {
                        return(true);
                    }
                    else
                    {
                        // the edit control will use the
                        // delete key: we are in Edit mode now:
                        IsInEditOrNavigateMode = false;
                        dataGrid.ColumnStartedEditing(Bounds);

                        return(ProcessKeyEventArgs(ref m));
                    }
                }
                else
                {
                    return(ProcessKeyEventArgs(ref m));
                }

            case Keys.Tab:
                // the TextBox gets the Control-Tab messages,
                // not the parent
                if ((ModifierKeys & Keys.Control) == Keys.Control)
                {
                    return(ProcessKeyPreview(ref m));
                }
                else
                {
                    return(ProcessKeyEventArgs(ref m));
                }

            default:
                return(ProcessKeyEventArgs(ref m));
            }
        }