public void RemoveDeviceFromDeviceGroup(Device device)
        {
            var deviceGroupViewModel = DeviceGroupViewModel.FindDeviceGroupViewModelWithDevice(OutputDeviceGroups, device);

            context.DeviceGroupsManager.RemoveDeviceFromDeviceGroup(device, _deviceIoType, deviceGroupViewModel.Guid);
            deviceGroupViewModel.Devices.Remove(device);
        }
        public void RemoveDeviceGroup(DeviceGroupViewModel deviceGroupViewModel)
        {
            var result = MessageBox.Show("Are you sure you want to remove '" + deviceGroupViewModel.Title + "'?", "Remove device group", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }
            context.DeviceGroupsManager.RemoveDeviceGroup(deviceGroupViewModel.Guid, _deviceIoType);
            OutputDeviceGroups.Remove(deviceGroupViewModel);
        }
Esempio n. 3
0
        public static DeviceGroupViewModel FindDeviceGroupViewModelWithDevice(Collection <DeviceGroupViewModel> deviceGroupViewModels, Device device)
        {
            DeviceGroupViewModel result = null;

            foreach (var deviceGroupViewModel in deviceGroupViewModels)
            {
                if (deviceGroupViewModel.Devices.Contains(device))
                {
                    result = deviceGroupViewModel;
                }
            }
            return(result);
        }
        private DeviceGroupViewModel PopulateDeviceList(List <DeviceGroup> deviceGroups, string title)
        {
            var result = new DeviceGroupViewModel()
            {
                Title = title
            };

            foreach (var deviceGroup in deviceGroups)
            {
                var deviceGroupViewModel = new DeviceGroupViewModel()
                {
                    Title = deviceGroup.Title
                };
                foreach (var device in deviceGroup.Devices)
                {
                    deviceGroupViewModel.Devices.Add(device);
                }
                result.Groups.Add(deviceGroupViewModel);
            }
            return(result);
        }
        private void GenerateDeviceGroupList()
        {
            List <DeviceGroup> deviceList;

            switch (_deviceIoType)
            {
            case DeviceIoType.Input:
                deviceList = context.InputGroups;
                break;

            case DeviceIoType.Output:
                deviceList = context.OutputGroups;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            foreach (var deviceGroup in deviceList)
            {
                var deviceGroupViewModel = new DeviceGroupViewModel(deviceGroup);
                OutputDeviceGroups.Add(deviceGroupViewModel);
            }
        }
 public void RenameDeviceGroup(DeviceGroupViewModel deviceGroup, string title)
 {
     OutputDeviceGroups.First(d => d.Guid == deviceGroup.Guid).Title = title;
     context.DeviceGroupsManager.RenameDeviceGroup(deviceGroup.Guid, _deviceIoType, title);
 }