Exemple #1
0
        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.DeviceBindingInfo.DeviceBindingCategory != Category)
                    {
                        continue;
                    }
                    cmd = new RelayCommand(c =>
                    {
                        DeviceBinding.SetDeviceConfigurationGuid(GetSelectedDeviceConfiguration().Guid);
                        DeviceBinding.SetKeyTypeValue(deviceBindingNode.DeviceBindingInfo.KeyType, deviceBindingNode.DeviceBindingInfo.KeyValue, deviceBindingNode.DeviceBindingInfo.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);
        }
Exemple #2
0
 private void DeviceNumberBox_OnSelected(object sender, RoutedEventArgs e)
 {
     if (!HasLoaded)
     {
         return;
     }
     if (DeviceSelectionBox.SelectedItem == null)
     {
         return;
     }
     DeviceBinding.SetDeviceConfigurationGuid(GetSelectedDeviceConfiguration().Guid);
     LoadContextMenu();
 }
        private void InputChanged(ProviderDescriptor providerDescriptor, DeviceDescriptor deviceDescriptor, BindingReport bindingReport, short value)
        {
            if (!DeviceBinding.MapCategory(bindingReport.Category).Equals(_deviceBinding.DeviceBindingCategory))
            {
                return;
            }
            if (!IsInputValid(bindingReport.Category, value))
            {
                return;
            }

            var deviceConfiguration = FindDeviceConfiguration(providerDescriptor, deviceDescriptor);

            _deviceBinding.SetDeviceConfigurationGuid(deviceConfiguration.Guid);
            _deviceBinding.SetKeyTypeValue((int)bindingReport.BindingDescriptor.Type, bindingReport.BindingDescriptor.Index, bindingReport.BindingDescriptor.SubIndex);
            EndBindMode();
        }