public void Initialize() { IsNowPlaying = false; Sounds = new ObservableCollection<SoundViewModel>(); var stateClasses = new List<XStateClass>(); stateClasses.Add(XStateClass.Attention); stateClasses.Add(XStateClass.Fire1); stateClasses.Add(XStateClass.Fire2); stateClasses.Add(XStateClass.AutoOff); stateClasses.Add(XStateClass.ConnectionLost); stateClasses.Add(XStateClass.Failure); stateClasses.Add(XStateClass.Ignore); stateClasses.Add(XStateClass.Off); stateClasses.Add(XStateClass.On); stateClasses.Add(XStateClass.TurningOff); stateClasses.Add(XStateClass.TurningOn); foreach (var stateClass in stateClasses) { var newSound = new Sound() { StateClass = stateClass }; var sound = FiresecClient.FiresecManager.SystemConfiguration.Sounds.FirstOrDefault(x => x.StateClass == stateClass); if (sound == null) FiresecClient.FiresecManager.SystemConfiguration.Sounds.Add(newSound); else newSound = sound; Sounds.Add(new SoundViewModel(newSound)); } SelectedSound = Sounds.FirstOrDefault(); if (FiresecClient.FiresecManager.SystemConfiguration.Sounds.RemoveAll(x => !Sounds.Any(y => y.StateClass == x.StateClass)) > 0) ServiceFactory.SaveService.SoundsChanged = true; }
public SoundViewModel(Sound sound) { Sound = sound; }
public void Initialize() { IsNowPlaying = false; Sounds = new ObservableCollection<SoundViewModel>(); foreach (StateType stateType in Enum.GetValues(typeof(StateType))) { if (stateType == StateType.No) { continue; } var newSound = new Sound() { StateType = stateType }; if (FiresecClient.FiresecManager.SystemConfiguration.Sounds.IsNotNullOrEmpty()) { var sound = FiresecClient.FiresecManager.SystemConfiguration.Sounds.FirstOrDefault(x => x.StateType == stateType); if (sound == null) FiresecClient.FiresecManager.SystemConfiguration.Sounds.Add(newSound); else newSound = sound; } else { FiresecClient.FiresecManager.SystemConfiguration.Sounds.Add(newSound); } Sounds.Add(new SoundViewModel(newSound)); } if (Sounds.IsNotNullOrEmpty()) SelectedSound = Sounds[0]; }