예제 #1
0
        private void Update()
        {
            var keyboard = Keyboard.current;

            if (keyboard == null)
            {
                return;
            }

            if (Enabled)
            {
                if (keyboard.spaceKey.wasPressedThisFrame)
                {
                    JumpForward?.Invoke();
                }

                if (keyboard.aKey.wasPressedThisFrame)
                {
                    MoveLeft?.Invoke();
                }

                if (keyboard.dKey.wasPressedThisFrame)
                {
                    MoveRight?.Invoke();
                }
            }
        }
예제 #2
0
        // This is the method defined for the MoveLeft event. Mark this event as private
        // if you will never override it. Otherwise mark it as protected virtual.

        /// <summary>
        /// Raises the <see cref="MoveLeft"/> event.
        /// </summary>
        protected virtual void OnMoveLeft(MovedLeftEventArgs e)
        {
            // Check to see if the event is handled anywhere (in simple terms).
            // This is where you send data to event handlers.
            // Send the object related to the event as first argument (in my case this control).
            // Send in e which is the event args passed in from onMouseMove with the moveAmountData.
            MoveLeft?.Invoke(this, e);
        }
예제 #3
0
    private void OnTick(object sender, float duration)
    {
        if (Input.GetKey(KeyCode.D))
        {
            MoveRight?.Invoke(this, duration);
        }

        if (Input.GetKey(KeyCode.A))
        {
            MoveLeft?.Invoke(this, duration);
        }
    }
        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;
                    }
                }
            }
        }
예제 #5
0
 public void Left()
 {
     MoveLeft?.Invoke();
 }
        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());
                    }
                }
            }
        }
예제 #7
0
 private void lblLeft_Click(object sender, EventArgs e)
 {
     MoveLeft?.Invoke(this, null);
 }
예제 #8
0
 public void IsMoveLeft()
 {
     GameManager.instance.UpdateLeftKeyPressed(true);
     GameManager.instance.UpdateRightKeyPressed(false);
     MoveLeft.Invoke();
 }