private DeviceChanges switchDevice(Settings.CDevice devSettings, Device dev, ERole role) { var defaultDevice = EndPoints.GetDefaultMMDevice(dev.DataFlow, role); if (defaultDevice?.ID == null || !defaultDevice.ID.Equals(devSettings.DeviceID)) { EndPoints.SetDefaultDevice(devSettings.DeviceID, role); string deviceName = devSettings.UseCustomName && !string.IsNullOrEmpty(devSettings.CustomName) ? devSettings.CustomName : dev.MMDevice.FriendlyName; return(new DeviceChanges { deviceName = deviceName, role = role, dataflow = dev.DataFlow }); } return(null); }
private void buttonSaveDevice_Click(object sender, EventArgs e) { if (listDevices.SelectedItems.Count == 0) return; var devSettings = Program.settings.Device.Find(x => x.DeviceID == (string) listDevices.SelectedItems[0].Tag); listDevices.SelectedItems[0].Font = new Font(listDevices.SelectedItems[0].Font, checkHideDevice.Checked ? FontStyle.Italic : FontStyle.Bold); if (devSettings != null) { devSettings.Brightness = trackBrightness.Value; devSettings.Hue = trackHue.Value; devSettings.Saturation = trackSaturation.Value; devSettings.HideFromList = checkHideDevice.Checked; } else { devSettings = new Settings.CDevice { DeviceID = (string) listDevices.SelectedItems[0].Tag, HideFromList = checkHideDevice.Checked, Brightness = trackBrightness.Value, Hue = trackHue.Value, Saturation = trackSaturation.Value }; Program.settings.Device.Add(devSettings); } }