private static bool deviceBindingMatchesNode(DeviceBinding deviceBinding, DeviceBindingNode deviceBindingNode) { return(deviceBindingNode.IsBinding && deviceBindingNode.DeviceBindingInfo.KeyType == deviceBinding.KeyType && deviceBindingNode.DeviceBindingInfo.KeySubValue == deviceBinding.KeySubValue && deviceBindingNode.DeviceBindingInfo.KeyValue == deviceBinding.KeyValue); }
private static List <DeviceBindingNode> BuildDeviceBindingMenu(List <DeviceReportNode> deviceNodes, DeviceIoType type) { var result = new List <DeviceBindingNode>(); if (deviceNodes == null) { return(result); } foreach (var deviceNode in deviceNodes) { var groupNode = new DeviceBindingNode() { Title = deviceNode.Title, ChildrenNodes = BuildDeviceBindingMenu(deviceNode.Nodes, type), }; if (groupNode.ChildrenNodes == null) { groupNode.ChildrenNodes = new List <DeviceBindingNode>(); } foreach (var bindingInfo in deviceNode.Bindings) { var bindingNode = new DeviceBindingNode() { Title = bindingInfo.Title, DeviceBindingInfo = new DeviceBindingInfo() { KeyType = (int)bindingInfo.BindingDescriptor.Type, KeyValue = bindingInfo.BindingDescriptor.Index, KeySubValue = bindingInfo.BindingDescriptor.SubIndex, DeviceBindingCategory = DeviceBinding.MapCategory(bindingInfo.Category), Blockable = bindingInfo.Blockable } }; groupNode.ChildrenNodes.Add(bindingNode); } result.Add(groupNode); } return(result.Count != 0 ? result : null); }
private static List <DeviceBindingNode> GetDeviceBindingMenu(List <DeviceReportNode> deviceNodes, DeviceIoType type) { var result = new List <DeviceBindingNode>(); if (deviceNodes == null) { return(result); } foreach (var deviceNode in deviceNodes) { var groupNode = new DeviceBindingNode() { Title = deviceNode.Title, IsBinding = false, ChildrenNodes = GetDeviceBindingMenu(deviceNode.Nodes, type), }; foreach (var bindingInfo in deviceNode.Bindings) { var bindingNode = new DeviceBindingNode() { Title = bindingInfo.Title, IsBinding = true, DeviceBinding = new DeviceBinding(null, null, type) { IsBound = false, KeyType = (int)bindingInfo.BindingDescriptor.Type, KeyValue = bindingInfo.BindingDescriptor.Index, KeySubValue = bindingInfo.BindingDescriptor.SubIndex, DeviceBindingCategory = DeviceBinding.MapCategory(bindingInfo.Category) // TODO Extract to class instead of using DeviceBinding? } }; if (groupNode.ChildrenNodes == null) { groupNode.ChildrenNodes = new List <DeviceBindingNode>(); } groupNode.ChildrenNodes.Add(bindingNode); } result.Add(groupNode); } return(result.Count != 0 ? result : null); }