コード例 #1
0
        private void ChangeInputDevice()
        {
            object comboBoxContent = ((ComboBoxItem)comboBoxDevices.SelectedValue).Content;

            if (comboBoxContent != null)
            {
                RemoveSelectedButNotPresentDevice();
                SetMappingEnabledState(true);

                String selectedDeviceName = comboBoxContent.ToString();

                for (int i = 0; i < devices.Count; i++)
                {
                    if (devices[i].DeviceName == selectedDeviceName)
                        selectedDevice = devices[i];
                }

                if (selectedDevice != null)
                {
                    CreateControlsForSelectedDevice();
                    TakeOverMapping(((ConfigurableInput)selectedDevice).Mapping);
                    isSelectedDevicePresent = true;
                    UpdateCurrentDeviceDescription();
                }
            }
        }
コード例 #2
0
        private void AddDeviceToDeviceList(ConfigurableInput inputDevice)
        {
            bool foundReplacement = false;
            for (int i = 0; i < devices.Count; i++)
            {
                if (devices[i].DeviceInstanceId == inputDevice.DeviceInstanceId)
                {
                    inputDevice.CopyMappingFrom(devices[i]);
                    devices[i] = inputDevice;

                    foundReplacement = true;
                    break;
                }
            }

            if (!foundReplacement)
            {
                devices.Add(inputDevice);

                ComboBoxItem newItem = new ComboBoxItem();
                newItem.Content = inputDevice.DeviceName;
                comboBoxDevices.Items.Add(newItem);
            }
        }
コード例 #3
0
 public void CopyMappingFrom(ConfigurableInput input)
 {
     mapping       = input.mapping.Clone();
     backupMapping = input.backupMapping.Clone();
 }
コード例 #4
0
        private void HandleNewDevice(String deviceId, ConfigurableInput inputDevice)
        {
            AddDeviceToDeviceList(inputDevice);

            if (selectedDevice != null && selectedDevice.DeviceInstanceId == inputDevice.DeviceInstanceId)
            {
                inputDevice.CopyMappingFrom(selectedDevice);

                selectedDevice = inputDevice;

                isSelectedDevicePresent = true;
                UpdateCurrentDeviceDescription();
            }
        }
コード例 #5
0
 public void CopyMappingFrom(ConfigurableInput input)
 {
     mapping = input.mapping.Clone();
     backupMapping = input.backupMapping.Clone();
 }