public void Initialize() { IsNowPlaying = false; Sounds = new SortableObservableCollection<SoundViewModel>(); var stateClasses = new List<Tuple<XStateClass, SoundType>>(); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Fire1, SoundType.Fire1)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Fire2, SoundType.Fire2)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Attention, SoundType.Attention)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Fire1, SoundType.Alarm)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Failure, SoundType.Failure)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Off, SoundType.Off)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.TurningOn, SoundType.TurningOn)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.TurningOff, SoundType.StopStart)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.AutoOff, SoundType.AutoOff)); foreach (var stateClass in stateClasses) { var newSound = new Sound() { StateClass = stateClass.Item1, Type = stateClass.Item2 }; var sound = ClientManager.SystemConfiguration.Sounds.FirstOrDefault(x => x.Type == stateClass.Item2); if (sound == null) ClientManager.SystemConfiguration.Sounds.Add(newSound); else newSound = sound; Sounds.Add(new SoundViewModel(newSound)); } Sounds.Sort(x => EnumHelper.GetEnumDescription(x.SoundType)); SelectedSound = Sounds.FirstOrDefault(); if (ClientManager.SystemConfiguration.Sounds.RemoveAll(x => !Sounds.Any(y => y.SoundType == x.Type)) > 0) ServiceFactory.SaveService.SoundsChanged = true; }
public SoundViewModel(Sound sound) { Sound = sound; }