private KeyboardService()
        {
            _helper         = new KeyboardHelper();
            _helper.KeyDown = e =>
            {
                e.Handled = true;

                // use this to nav back
                if (e.VirtualKey == Windows.System.VirtualKey.GoBack)
                {
                    DebugWrite("GoBack", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke(e.VirtualKey);
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationLeft)
                {
                    DebugWrite("NavigationLeft", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke(e.VirtualKey);
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadMenu)
                {
                    DebugWrite("GamepadMenu", caller: nameof(AfterMenuGesture));
                    AfterMenuGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadLeftShoulder)
                {
                    DebugWrite("GamepadLeftShoulder", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke(e.VirtualKey);
                }
                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Back)
                {
                    DebugWrite("Alt+Back", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke(e.VirtualKey);
                }
                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Left)
                {
                    DebugWrite("Alt+Left", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke(e.VirtualKey);
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.Escape)
                {
                    DebugWrite("Escape", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke(e.VirtualKey);
                }
                // use this to nav forward
                else if (e.VirtualKey == Windows.System.VirtualKey.GoForward)
                {
                    DebugWrite("GoForward", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationRight)
                {
                    DebugWrite("NavigationRight", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadRightShoulder)
                {
                    DebugWrite("GamepadRightShoulder", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Right)
                {
                    DebugWrite("Alt+Right", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }

                // anything else
                else
                {
                    e.Handled = false;
                }
            };
            _helper.PointerGoBackGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoBackGestured));
                AfterBackGesture?.Invoke(Windows.System.VirtualKey.GoBack);
            };
            _helper.PointerGoForwardGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoForwardGestured));
                AfterForwardGesture?.Invoke();
            };
        }
Exemplo n.º 2
0
        private KeyboardService()
        {
            _helper         = new KeyboardHelper();
            _helper.KeyDown = async(e) =>
            {
                e.Handled = true;

                // use this to hide and show the menu
                if (e.WindowsKey && e.Character.ToString().ToLower().Equals("z"))
                {
                    DebugWrite("Windows+Z", caller: nameof(AfterWindowZGesture));
                    AfterWindowZGesture?.Invoke();
                }

                // use this to place focus in search box
                else if (e.OnlyControl && e.Character.ToString().ToLower().Equals("e"))
                {
                    DebugWrite("Control+E", caller: nameof(AfterControlEGesture));
                    AfterControlEGesture?.Invoke();
                }

                // use this to nav back
                else if (e.VirtualKey == Windows.System.VirtualKey.GoBack)
                {
                    DebugWrite("GoBack", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationLeft)
                {
                    DebugWrite("NavigationLeft", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadLeftShoulder)
                {
                    DebugWrite("GamepadLeftShoulder", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Back)
                {
                    DebugWrite("Alt+Back", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Left)
                {
                    DebugWrite("Alt+Left", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                // use this to nav forward
                else if (e.VirtualKey == Windows.System.VirtualKey.GoForward)
                {
                    DebugWrite("GoForward", caller: nameof(AfterBackGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationRight)
                {
                    DebugWrite("NavigationRight", caller: nameof(AfterBackGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadRightShoulder)
                {
                    DebugWrite("GamepadRightShoulder", caller: nameof(AfterBackGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Right)
                {
                    DebugWrite("Alt+Right", caller: nameof(AfterBackGesture));
                    AfterForwardGesture?.Invoke();
                }

                // about
                else if (e.AltKey && e.ControlKey && e.ShiftKey && e.VirtualKey == Windows.System.VirtualKey.A)
                {
                    var open  = new Action(async() => { await Windows.System.Launcher.LaunchUriAsync(new Uri("http://aka.ms/template10")); });
                    var about = new Windows.UI.Xaml.Controls.ContentDialog
                    {
                        Title                = "Template 10",
                        Content              = "Congratulations. This project uses Template 10, an open source framework for Windows 10 apps written against the Universal Windows Platform.",
                        PrimaryButtonText    = "Info",
                        PrimaryButtonCommand = new Mvvm.DelegateCommand(open),
                        SecondaryButtonText  = "Close"
                    };
                    await about.ShowAsync();
                }

                // anything else
                else
                {
                    e.Handled = false;
                }
            };
            _helper.PointerGoBackGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoBackGestured));
                AfterBackGesture?.Invoke();
            };
            _helper.PointerGoForwardGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoForwardGestured));
                AfterForwardGesture?.Invoke();
            };
        }
Exemplo n.º 3
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(); };
        }
Exemplo n.º 4
0
 public KeyboardService()
 {
     _helper = new KeyboardHelper();
     _helper.GoBackGestured    = () => { AfterBackGesture?.Invoke(); };
     _helper.GoForwardGestured = () => { AfterForwardGesture?.Invoke(); };
 }
Exemplo n.º 5
0
        private KeyboardService()
        {
            _helper         = new KeyboardHelper();
            _helper.KeyDown = (e) =>
            {
                e.Handled = true;

                // use this to place focus in search box
                if (e.OnlyControl && e.Character.ToString().ToLower().Equals("e"))
                {
                    DebugWrite("Control+E", caller: nameof(AfterControlEGesture));
                    AfterControlEGesture?.Invoke();
                }

                // use this to nav back
                else if (e.VirtualKey == Windows.System.VirtualKey.GoBack)
                {
                    DebugWrite("GoBack", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationLeft)
                {
                    DebugWrite("NavigationLeft", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadMenu)
                {
                    DebugWrite("GamepadMenu", caller: nameof(AfterMenuGesture));
                    AfterMenuGesture?.Invoke();
                }

                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadLeftShoulder)
                {
                    DebugWrite("GamepadLeftShoulder", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Back)
                {
                    DebugWrite("Alt+Back", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Left)
                {
                    DebugWrite("Alt+Left", caller: nameof(AfterBackGesture));
                    AfterBackGesture?.Invoke();
                }

                // use this to nav forward
                else if (e.VirtualKey == Windows.System.VirtualKey.GoForward)
                {
                    DebugWrite("GoForward", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.NavigationRight)
                {
                    DebugWrite("NavigationRight", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.VirtualKey == Windows.System.VirtualKey.GamepadRightShoulder)
                {
                    DebugWrite("GamepadRightShoulder", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }
                else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Right)
                {
                    DebugWrite("Alt+Right", caller: nameof(AfterForwardGesture));
                    AfterForwardGesture?.Invoke();
                }

                // anything else
                else
                {
                    e.Handled = false;
                }
            };
            _helper.PointerGoBackGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoBackGestured));
                AfterBackGesture?.Invoke();
            };
            _helper.PointerGoForwardGestured = () =>
            {
                DebugWrite(caller: nameof(KeyboardHelper.PointerGoForwardGestured));
                AfterForwardGesture?.Invoke();
            };
        }