private async Task UpdateDeviceStates() { ProgressDialogController progressController = await parentWindow.ShowProgressAsync("Enumerating devices", "Please wait...", false, dialogSettings); foreach (EmuControllerDevice dev in Devices) { WMIPnpEntity.SetDeviceStatus(dev); if (dev.ErrorCode != (uint)DeviceState.OK && dev.ErrorCode != (uint)DeviceState.DeviceDisabled) { await parentWindow.ShowMessageAsync("A problem with a device", string.Format("Device '{0}' is not working correctly. If restarting the system does not restore the functionality of the device," + "uninstall and reinstall device again.", dev.DeviceName), MessageDialogStyle.Affirmative); } } await progressController.CloseAsync(); }
private void ToggleSwitchToggled(object device) { if (device is EmuControllerDevice dev) { if (dev.IsEnabled) { DeviceConfig.DisableDevice(Path.Combine(dev.IdPrefix, dev.DeviceId)); WMIPnpEntity.SetDeviceStatus(dev); if (dev.IsEnabled) { ShowRestartRequiredMessage(); } } else { DeviceConfig.EnableDevice(Path.Combine(dev.IdPrefix, dev.DeviceId)); WMIPnpEntity.SetDeviceStatus(dev); if (!dev.IsEnabled) { ShowRestartRequiredMessage(); } } } }