Ejemplo n.º 1
0
        private KeyboardService()
        {
            Helper.KeyDown = (e) =>
            {
                e.Handled = true;

                // use this to place focus in search box
                if (e.OnlyControl && e.Character.ToString().ToLower().Equals("e"))
                {
                    AfterControlEGesture?.Invoke();
                }

                // use this for hamburger menu
                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadMenu)
                {
                    AfterMenuGesture?.Invoke();
                }

                // anything else
                else
                {
                    e.Handled = false;
                }

                AfterKeyDown?.Invoke(e);
            };
        }
Ejemplo n.º 2
0
        public GestureService(IBackButtonService backService, IKeyboardService keyService)
        {
            Two.BackService = backService as IBackButtonService2;
            Two.BackService.BackRequested += (s, e) =>
            {
                BackRequested2?.Invoke(s, e);
                if (AllowBackRequested)
                {
                    BackRequested?.Invoke(s, e);
                }
            };

            Two.BackService.ForwardRequested += (s, e) =>
            {
                ForwardRequested2?.Invoke(s, e);
                if (AllowForwardRequested)
                {
                    ForwardRequested?.Invoke(s, e);
                }
            };

            Two.KeyService = keyService as IKeyboardService2;
            Two.KeyService.AfterSearchGesture += (s, e) => AfterSearchGesture?.Invoke(s, e);
            Two.KeyService.AfterMenuGesture   += (s, e) => AfterMenuGesture?.Invoke(s, e);
            Two.KeyService.AfterKeyDown       += (s, e) => AfterKeyDown?.Invoke(s, e);
        }
Ejemplo n.º 3
0
        /// <remarks>
        /// This must be called AFTER the first window is created.
        /// </remarks>
        void IKeyboardService2.Setup()
        {
            _helper = new KeyboardHelper
            {
                KeyDown = (e) =>
                {
                    e.Handled = true;

                    if (e.OnlyControl && e.Character.ToString().ToLower().Equals("e"))
                    {
                        AfterSearchGesture?.Invoke(this, EventArgs.Empty);
                    }
                    else if (e.VirtualKey == Windows.System.VirtualKey.GamepadMenu)
                    {
                        AfterMenuGesture?.Invoke(this, EventArgs.Empty);
                    }
                    else
                    {
                        e.Handled = false;
                    }

                    AfterKeyDown?.Invoke(this, e);
                }
            };
        }
Ejemplo n.º 4
0
        /// <remarks>
        /// This must be called AFTER the first window is created.
        /// </remarks>
        public void Setup()
        {
            if (_Setup)
            {
                return;
            }
            else
            {
                _Setup = true;
            }
            _helper = new KeyboardHelper()
            {
                KeyDown = (e) =>
                {
                    e.Handled = true;

                    // use this to place focus in search box
                    if (e.OnlyControl && e.Character.ToString().ToLower().Equals("e"))
                    {
                        AfterControlEGesture?.Invoke();
                    }

                    // use this for hamburger menu
                    else if (e.VirtualKey == Windows.System.VirtualKey.GamepadMenu)
                    {
                        AfterMenuGesture?.Invoke();
                    }

                    // anything else
                    else
                    {
                        e.Handled = false;
                    }

                    AfterKeyDown?.Invoke(e);
                }
            };
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a KeyboardService instance.
        /// </summary>
        public KeyboardService()
        {
            _keyboardController = new KeyboardController();

            _keyboardController.KeyDown = (e) =>
            {
                e.Handled = true;

                // use this to hide and show the menu
                if (e.OnlyWindows && e.Character.ToString().ToLower().Equals("z"))
                {
                    AfterWindowZGesture?.Invoke();
                }

                // use this to place focus in search box
                else if (e.OnlyControl && e.Character.ToString().ToLower().Equals("e"))
                {
                    AfterControlEGesture?.Invoke();
                }

                // use this to nav back
                else if (e.VirtualKey == Windows.System.VirtualKey.GoBack)
                {
                    AfterBackGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationLeft)
                {
                    AfterBackGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadLeftShoulder)
                {
                    AfterBackGesture?.Invoke();
                }
                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Back)
                {
                    AfterBackGesture?.Invoke();
                }
                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Left)
                {
                    AfterBackGesture?.Invoke();
                }

                // use this to nav forward
                else if (e.VirtualKey == Windows.System.VirtualKey.GoForward)
                {
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationRight)
                {
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadRightShoulder)
                {
                    AfterForwardGesture?.Invoke();
                }
                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Right)
                {
                    AfterForwardGesture?.Invoke();
                }
                else
                {
                    e.Handled = false;
                }

                // call the general callback where pages can subsribe for.
                AfterKeyDown?.Invoke(e);
            };

            _keyboardController.GoBackGestured    = () => { AfterBackGesture?.Invoke(); };
            _keyboardController.GoForwardGestured = () => { AfterForwardGesture?.Invoke(); };
        }