private ObservableCollection <ContextMenuItem> BuildMenu(List <DeviceBindingNode> deviceBindingNodes) { var menuList = new ObservableCollection <ContextMenuItem>(); if (deviceBindingNodes == null) { return(menuList); } foreach (var deviceBindingNode in deviceBindingNodes) { RelayCommand cmd = null; if (deviceBindingNode.IsBinding) { if (Category != null && deviceBindingNode.DeviceBinding.DeviceBindingCategory != Category) { continue; } cmd = new RelayCommand(c => { DeviceBinding.SetDeviceGuid(GetSelectedDevice().Guid); DeviceBinding.SetKeyTypeValue(deviceBindingNode.DeviceBinding.KeyType, deviceBindingNode.DeviceBinding.KeyValue, deviceBindingNode.DeviceBinding.KeySubValue); }); } var menu = new ContextMenuItem(deviceBindingNode.Title, BuildMenu(deviceBindingNode.ChildrenNodes), cmd); if (deviceBindingNode.IsBinding || !deviceBindingNode.IsBinding && menu.Children.Count > 0) { menuList.Add(menu); } } return(menuList); }
private void LoadDeviceInputs() { var devicelist = DeviceBinding.Profile.GetDeviceList(DeviceBinding); Devices = new ObservableCollection <ComboBoxItemViewModel>(); foreach (var device in devicelist) { Devices.Add(new ComboBoxItemViewModel(device.Title, device.Guid)); } ComboBoxItemViewModel selectedDevice = null; foreach (var comboBoxItem in Devices) { if (comboBoxItem.Value == DeviceBinding.DeviceGuid) { selectedDevice = comboBoxItem; break; } } if (Devices.Count == 0) { Devices.Add(new ComboBoxItemViewModel("No device group", Guid.Empty)); } if (selectedDevice == null) { selectedDevice = Devices[0]; DeviceBinding.SetDeviceGuid(selectedDevice.Value); } DeviceNumberBox.ItemsSource = Devices; DeviceNumberBox.SelectedItem = selectedDevice; }
private void DeviceNumberBox_OnSelected(object sender, RoutedEventArgs e) { if (!HasLoaded) { return; } if (DeviceSelectionBox.SelectedItem == null) { return; } DeviceBinding.SetDeviceGuid(GetSelectedDevice().Guid); LoadContextMenu(); }
private void DeviceNumberBox_OnSelected(object sender, RoutedEventArgs e) { if (!HasLoaded) { return; } if (DeviceNumberBox.SelectedItem == null) { return; } DeviceBinding.SetDeviceGuid(((ComboBoxItemViewModel)DeviceNumberBox.SelectedItem).Value); LoadContextMenu(); }
private void InputChanged(ProviderDescriptor providerDescriptor, DeviceDescriptor deviceDescriptor, BindingReport bindingReport, int value) { if (!DeviceBinding.MapCategory(bindingReport.Category).Equals(_deviceBinding.DeviceBindingCategory)) { return; } if (!IsInputValid(bindingReport.Category, value)) { return; } var device = FindDevice(providerDescriptor, deviceDescriptor); _deviceBinding.SetDeviceGuid(device.Guid); _deviceBinding.SetKeyTypeValue((int)bindingReport.BindingDescriptor.Type, bindingReport.BindingDescriptor.Index, bindingReport.BindingDescriptor.SubIndex); EndBindMode(); }