private void _restoreMediaVolumes() { var volumes = Properties.Settings.Default.MediaVolumes.Split(';') .Select(vol => vol.Split('=')).ToDictionary(vol => vol[0], vol => Convert.ToDouble(vol.ElementAtOrDefault(1))); MediaViewModels.ForEach(mvm => { if (volumes.ContainsKey(mvm.Media.Name)) { mvm.Volume = volumes[mvm.Media.Name]; } }); }
public CurrentSoundViewModel() { MediaViewModels = _allMedia.Select(m => new MediaViewModel(m)).ToList(); MediaViewModels.ForEach(mvm => mvm.PropertyChanged += (s, e) => { if (e.PropertyName == "Volume") { _updateVolume((MediaViewModel)s); _saveMediaVolumes(); } }); Properties.Settings.Default.PropertyChanged += (s, e) => { if (e.PropertyName == "GlobalVolume") { _updateGlobalVolume(); } }; _restoreMediaVolumes(); _updateGlobalVolume(); IsPlaying = Properties.Settings.Default.PlayOnLaunch; }
private void _updateGlobalVolume() { _volume = Properties.Settings.Default.GlobalVolume; MediaViewModels.ForEach(_updateVolume); }