private async void Channel_ControlChanged(HIDMapping mapping) { #if DEBUG System.Diagnostics.Debug.WriteLine("Control changed"); #endif await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => { this.ProcessInput(mapping); }); }
private void ProcessInput(HIDMapping mapping) { var focussedElement = FocusManager.GetFocusedElement() as UIElement; if (focussedElement != null) { this.processInputForMap(mapping, this.boxToButtonMappings, this.map, focussedElement); this.processInputForMap(mapping, this.boxToButtonMappingsAlt, this.mapAlt, focussedElement); this.RefreshBindings(); } }
private void processInputForMap( HIDMapping mapping, Dictionary <UIElement, Utility.Button> map, HIDButtonMap buttonMap, UIElement uiElement) { Utility.Button button; if (map.TryGetValue(uiElement, out button)) { buttonMap[button] = mapping; FocusManager.TryMoveFocus(FocusNavigationDirection.Next); FocusManager.TryMoveFocus(FocusNavigationDirection.Next); } }
private void refreshBindingsForMap(Dictionary <UIElement, Utility.Button> map, HIDButtonMap buttonMap) { if (buttonMap != null) { HIDMapping mapping = default(HIDMapping); foreach (var item in map) { TextBox textBox = item.Key as TextBox; if (textBox == null) { continue; } if (buttonMap.TryGetValue(item.Value, out mapping)) { textBox.Text = mapping.DisplayName; } else { textBox.Text = string.Empty; } } } else { foreach (var item in map) { TextBox textBox = item.Key as TextBox; if (textBox == null) { continue; } textBox.Text = string.Empty; } } }