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); }; }
public KeyboardService() { _helper = new KeyboardHelper(); _helper.GoBackGestured = () => { AfterBackGesture?.Invoke(); }; _helper.GoForwardGestured = () => { AfterForwardGesture?.Invoke(); }; _helper.ControlEGestured = () => { AfterControlEGesture?.Invoke(); }; _helper.WindowZGestured = () => { AfterWindowZGesture?.Invoke(); }; }
/// <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); } }; }
private KeyboardService() { _helper = new KeyboardHelper(); _helper.KeyDown = async(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(); } // about else if (e.AltKey && e.ControlKey && e.ShiftKey && e.VirtualKey == Windows.System.VirtualKey.F12) { var about = new Windows.UI.Xaml.Controls.ContentDialog { Title = "Template 10", PrimaryButtonText = "Info", SecondaryButtonText = "Close" }; try { var result = await about.ShowAsync(); if (result == Windows.UI.Xaml.Controls.ContentDialogResult.Primary) { await Windows.System.Launcher.LaunchUriAsync(new Uri("http://aka.ms/template10")); } } catch (System.Runtime.InteropServices.COMException) { DebugWrite("About dialog already showing"); } } // anything else else { e.Handled = false; } }; _helper.PointerGoBackGestured = () => { DebugWrite(caller: nameof(KeyboardHelper.PointerGoBackGestured)); AfterBackGesture?.Invoke(); }; _helper.PointerGoForwardGestured = () => { DebugWrite(caller: nameof(KeyboardHelper.PointerGoForwardGestured)); AfterForwardGesture?.Invoke(); }; }
private KeyboardService() { _helper = new KeyboardHelper(); _helper.KeyDown = (e) => { // Debug.WriteLine($"{e}"); e.Handled = true; // use this to hide and show the menu if (e.WindowsKey && 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(); } // anything else else { e.Handled = false; } }; _helper.GoPointerBackGestured = () => AfterBackGesture?.Invoke(); _helper.PointerGoForwardGestured = () => AfterForwardGesture?.Invoke(); }
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(); }; }
private KeyboardService() { _helper = new KeyboardHelper(); _helper.KeyDown = async(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 to nav back else if (e.VirtualKey == Windows.System.VirtualKey.GoBack) { Debug.WriteLine("GoBack:AfterBackGesture"); AfterBackGesture?.Invoke(); } else if (e.VirtualKey == Windows.System.VirtualKey.NavigationLeft) { Debug.WriteLine("NavigationLeft:AfterBackGesture"); AfterBackGesture?.Invoke(); } else if (e.VirtualKey == Windows.System.VirtualKey.GamepadMenu) { Debug.WriteLine("GamepadMenu:AfterMenuGesture"); AfterMenuGesture?.Invoke(); } else if (e.VirtualKey == Windows.System.VirtualKey.GamepadLeftShoulder) { Debug.WriteLine("GamepadLeftShoulder:AfterBackGesture"); AfterBackGesture?.Invoke(); } else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Back) { Debug.WriteLine("Alt+Back:AfterBackGesture"); AfterBackGesture?.Invoke(); } else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Left) { Debug.WriteLine("Alt+Left:AfterBackGesture"); AfterBackGesture?.Invoke(); } // use this to nav forward else if (e.VirtualKey == Windows.System.VirtualKey.GoForward) { Debug.WriteLine("GoForward:AfterForwardGesture"); AfterForwardGesture?.Invoke(); } else if (e.VirtualKey == Windows.System.VirtualKey.NavigationRight) { Debug.WriteLine("NavigationRight:AfterForwardGesture"); AfterForwardGesture?.Invoke(); } else if (e.VirtualKey == Windows.System.VirtualKey.GamepadRightShoulder) { Debug.WriteLine("GamepadRightShoulder:AfterForwardGesture"); AfterForwardGesture?.Invoke(); } else if (e.OnlyAlt && e.VirtualKey == Windows.System.VirtualKey.Right) { Debug.WriteLine("Alt+Right:AfterForwardGesture"); AfterForwardGesture?.Invoke(); } // anything else else { e.Handled = false; } }; _helper.PointerGoBackGestured = () => { Debug.WriteLine("PointerGoBackGestured"); AfterBackGesture?.Invoke(); }; _helper.PointerGoForwardGestured = () => { Debug.WriteLine("PointerGoForwardGestured"); AfterForwardGesture?.Invoke(); }; }
/// <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(); }; }