Example #1
0
 private void _deviceProvider_SelectedDevicesChanged(IDeviceProvider sender, IReadOnlyList <Device> selected)
 {
     RaisePropertyChanged("SelectedDevices");
     RaisePropertyChanged("ActiveProperties");
     SelectedDevicesChanged?.Invoke(this, selected);
 }
 private void OnSelectedDevicesChanged(object aObj, List <ButtplugDeviceInfo> aDevices)
 {
     SelectedDevicesChanged?.Invoke(aObj, aDevices);
 }
Example #3
0
        public void SelectDevices(IEnumerable <object> selected)
        {
            if (selected == null)
            {
                if (_devices == null || _devices.Count == 0)
                {
                    return;
                }
                else
                {
                    _selectedDevices    = new List <Device>(1);
                    _selectedDevices[0] = _devices.FirstOrDefault();
                    ActiveProperties    = PropertyForwarderFactory.GenerateForwardersFromDevices(_selectedDevices);
                    SelectedDevicesChanged?.Invoke(this, _selectedDevices);
                    return;
                }
            }

            bool changed  = false;
            var  newCount = selected.Count();

            if (_selectedDevices != null && newCount == _selectedDevices.Count)
            {
                int index = 0;
                foreach (var o in selected)
                {
                    if (o is Device device)
                    {
                        if (_selectedDevices[index].Id != device.Id)
                        {
                            changed = true;
                            break;
                        }
                    }
                    else
                    {
                        changed = true;
                        break;
                    }
                    index++;
                }
            }
            else
            {
                changed = true;
            }
            if (!changed)
            {
                return;
            }

            _selectedDevices = new List <Device>();
            foreach (var o in selected)
            {
                if (o is Device device)
                {
                    _selectedDevices.Add(device);
                }
            }

            _selectedDevices.Sort((a, b) => a.CompareTo(b));

            ActiveProperties = PropertyForwarderFactory.GenerateForwardersFromDevices(_selectedDevices);

            SelectedDevicesChanged?.Invoke(this, _selectedDevices);
        }