예제 #1
0
        public void handleInput()
        {
            mouse    = Mouse.GetState();
            keyboard = Keyboard.GetState();

            // add key functionality here
            if (mouse.RightButton == ButtonState.Released && RightMousePS == ButtonState.Pressed)
            {
                if (RightClick != null)
                {
                    RightClick.execute();
                }
            }

            if (keyboard.IsKeyDown(Keys.Escape))
            {
                if (EscapeKey != null)
                {
                    EscapeKey.execute();
                }
            }


            RightMousePS = mouse.RightButton;
        }
예제 #2
0
 void DetectKeys()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         Jump?.Invoke();
     }
     if (Input.GetKey(KeyCode.Space))
     {
         Jumping?.Invoke();
     }
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         EscapeKey?.Invoke();
     }
 }
예제 #3
0
    private void ProcessCancelType(EscapeKey escapeKey)
    {
        if (escapeKey == EscapeKey.GlobalSetting)
        {
            escapeKey = GlobalEscapeSetting;
        }

        switch (escapeKey)
        {
        case EscapeKey.BackOneLevel:
            StartCancelProcess(BackOneLevel);
            break;

        case EscapeKey.BackToHome:
            StartCancelProcess(BackToHome);
            break;

        case EscapeKey.None:
            break;

        case EscapeKey.GlobalSetting:
            break;
        }
    }
        private void UserControl_KeyDown(object sender, KeyEventArgs e)
        {
            if (KeyValidator.IsUpKey(e.Key))
            {
                e.Handled = true;
                MoveUp?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsDownKey(e.Key))
            {
                e.Handled = true;
                MoveDown?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsLeftKey(e.Key))
            {
                e.Handled = true;
                MoveLeft?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsRightKey(e.Key))
            {
                e.Handled = true;
                MoveRight?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsPageDownKey(e.Key))
            {
                e.Handled = true;
                MovePageDown?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsPageUpKey(e.Key))
            {
                e.Handled = true;
                MovePageUp?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsDeleteKey(e.Key))
            {
                if (!ReadOnlyMode)
                {
                    e.Handled = true;
                    ByteDeleted?.Invoke(this, new EventArgs());

                    return;
                }
            }
            else if (KeyValidator.IsBackspaceKey(e.Key))
            {
                e.Handled = true;
                ByteDeleted?.Invoke(this, new EventArgs());

                MovePrevious?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsEscapeKey(e.Key))
            {
                e.Handled = true;
                EscapeKey?.Invoke(this, new EventArgs());
                return;
            }

            //MODIFY BYTE
            if (!ReadOnlyMode)
            {
                if (KeyValidator.IsHexKey(e.Key))
                {
                    string key;
                    if (KeyValidator.IsNumericKey(e.Key))
                    {
                        key = KeyValidator.GetDigitFromKey(e.Key).ToString();
                    }
                    else
                    {
                        key = e.Key.ToString().ToLower();
                    }

                    switch (_keyDownLabel)
                    {
                    case KeyDownLabel.FirstChar:
                        FirstHexChar.Content = key;
                        _keyDownLabel        = KeyDownLabel.SecondChar;
                        Action = ByteAction.Modified;
                        Byte   = ByteConverters.HexToByte(FirstHexChar.Content.ToString() + SecondHexChar.Content.ToString())[0];
                        break;

                    case KeyDownLabel.SecondChar:
                        SecondHexChar.Content = key;
                        _keyDownLabel         = KeyDownLabel.NextPosition;

                        Action = ByteAction.Modified;
                        Byte   = ByteConverters.HexToByte(FirstHexChar.Content.ToString() + SecondHexChar.Content.ToString())[0];

                        //Move focus event
                        MoveNext?.Invoke(this, new EventArgs());
                        break;
                    }
                }
            }
        }
        private void UserControl_KeyDown(object sender, KeyEventArgs e)
        {
            if (KeyValidator.IsIgnoredKey(e.Key))
            {
                e.Handled = true;
                return;
            }
            else if (KeyValidator.IsUpKey(e.Key))
            {
                e.Handled = true;
                MoveUp?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsDownKey(e.Key))
            {
                e.Handled = true;
                MoveDown?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsLeftKey(e.Key))
            {
                e.Handled = true;
                MoveLeft?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsRightKey(e.Key))
            {
                e.Handled = true;
                MoveRight?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsPageDownKey(e.Key))
            {
                e.Handled = true;
                MovePageDown?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsPageUpKey(e.Key))
            {
                e.Handled = true;
                MovePageUp?.Invoke(this, new EventArgs());

                return;
            }
            else if (KeyValidator.IsDeleteKey(e.Key))
            {
                if (!ReadOnlyMode)
                {
                    e.Handled = true;
                    ByteDeleted?.Invoke(this, new EventArgs());

                    return;
                }
            }
            else if (KeyValidator.IsBackspaceKey(e.Key))
            {
                if (!ReadOnlyMode)
                {
                    e.Handled = true;
                    ByteDeleted?.Invoke(this, new EventArgs());

                    MovePrevious?.Invoke(this, new EventArgs());

                    return;
                }
            }
            else if (KeyValidator.IsEscapeKey(e.Key))
            {
                e.Handled = true;
                EscapeKey?.Invoke(this, new EventArgs());
                return;
            }

            //MODIFY ASCII...
            //TODO : MAKE BETTER KEYDETECTION AND EXPORT IN KEYVALIDATOR
            if (!ReadOnlyMode)
            {
                bool isok = false;

                if (Keyboard.GetKeyStates(Key.CapsLock) == KeyStates.Toggled)
                {
                    if (Keyboard.Modifiers != ModifierKeys.Shift && e.Key != Key.RightShift && e.Key != Key.LeftShift)
                    {
                        StringByteLabel.Content = ByteConverters.ByteToChar((byte)KeyInterop.VirtualKeyFromKey(e.Key));
                        isok = true;
                    }
                    else if (Keyboard.Modifiers == ModifierKeys.Shift && e.Key != Key.RightShift && e.Key != Key.LeftShift)
                    {
                        isok = true;
                        StringByteLabel.Content = ByteConverters.ByteToChar((byte)KeyInterop.VirtualKeyFromKey(e.Key)).ToString().ToLower();
                    }
                }
                else
                {
                    if (Keyboard.Modifiers != ModifierKeys.Shift && e.Key != Key.RightShift && e.Key != Key.LeftShift)
                    {
                        StringByteLabel.Content = ByteConverters.ByteToChar((byte)KeyInterop.VirtualKeyFromKey(e.Key)).ToString().ToLower();
                        isok = true;
                    }
                    else if (Keyboard.Modifiers == ModifierKeys.Shift && e.Key != Key.RightShift && e.Key != Key.LeftShift)
                    {
                        isok = true;
                        StringByteLabel.Content = ByteConverters.ByteToChar((byte)KeyInterop.VirtualKeyFromKey(e.Key));
                    }
                }

                //Move focus event
                if (isok)
                {
                    if (MoveNext != null)
                    {
                        Action = ByteAction.Modified;
                        Byte   = ByteConverters.CharToByte(StringByteLabel.Content.ToString()[0]);

                        MoveNext(this, new EventArgs());
                    }
                }
            }
        }