示例#1
0
        public GamePadWrapper(DependencyObject owner)
        {
            _owner = owner;
            WpfGamePad.AddThumbLeftChangeHandler(owner, OnBlockPosChanged);
            WpfGamePad.AddTriggerLeftChangeHandler(owner, OnChangeCase);
            WpfGamePad.AddTriggerRightChangeHandler(owner, OnChangeSymbols);

            WpfGamePad.AddButtonADownHandler(owner, OnCharUp);
            WpfGamePad.AddButtonBDownHandler(owner, OnCharRight);
            WpfGamePad.AddButtonXDownHandler(owner, OnCharLeft);
            WpfGamePad.AddButtonYDownHandler(owner, OnCharDown);
            WpfGamePad.AddDPadLeftDownHandler(owner, OnMoveLeftDown);
            WpfGamePad.AddDPadRightDownHandler(owner, OnMoveRightDown);
            WpfGamePad.AddDPadDownDownHandler(owner, OnEnterDown);
            WpfGamePad.AddButtonStartDownHandler(owner, OnEnterDown);
            WpfGamePad.AddButtonLeftShoulderDownHandler(owner, OnDeleteDown);
            WpfGamePad.AddButtonRightShoulderDownHandler(owner, OnSpaceDown);

            WpfGamePad.AddDPadLeftUpHandler(owner, OnMoveLeftUp);
            WpfGamePad.AddDPadRightUpHandler(owner, OnMoveRightUp);
            WpfGamePad.AddDPadDownUpHandler(owner, OnEnterUp);
            WpfGamePad.AddButtonStartUpHandler(owner, OnEnterUp);
            WpfGamePad.AddButtonLeftShoulderUpHandler(owner, OnDeleteUp);
            WpfGamePad.AddButtonRightShoulderUpHandler(owner, OnSpaceUp);
        }
示例#2
0
        public void Enable()
        {
            BlockNavigator.SetIsDisabled(this, true);
            WpfGamePad.AddThumbLeftChangeHandler(this, OnLeftThumbChanged);
            WpfGamePad.AddButtonADownHandler(this, OnButtonA);
            WpfGamePad.AddButtonBDownHandler(this, OnButtonB);
            WpfGamePad.SetRegistered(this, true);
            WpfGamePad.SetIsFocused(this, true);

            CenterHighlight.Visibility = Visibility.Visible;
            HighlightKnob.Visibility   = Visibility.Collapsed;
            _activeButtonIndex         = -1;

            Canvas.SetLeft(CenterHighlight, _centerHighlightCanvasSize.X / 2 - CenterHighlight.Width / 2);
            Canvas.SetTop(CenterHighlight, _centerHighlightCanvasSize.Y / 2 - CenterHighlight.Height / 2);
        }