/// <summary> /// Initializes a new instance of the ProgramDescriptionViewModel class. /// </summary> /// <param name="programDescription">The ProgramDescription model to model a view for.</param> public ProgramDescriptionViewModel(ProgramDescription programDescription) { _description = programDescription; _description.PropertyChanged += OnPropertyChanged; if (Properties.Settings.Default.RomListValidateAtStartup) { #if REPORT_PERFORMANCE var stopwatch = System.Diagnostics.Stopwatch.StartNew(); try { #endif // REPORT_PERFORMANCE ProgramDescription.Validate(programDescription, SingleInstanceApplication.Instance.GetAttachedDevices(), SingleInstanceApplication.Instance.GetConnectedDevicesHistory(), reportMessagesChanged: false); #if REPORT_PERFORMANCE } finally { stopwatch.Stop(); var romPath = Rom == null ? "<invalid ROM>" : Rom.RomPath; romPath = romPath ?? "<invalid ROM path>"; Logger.Log("ProgramDescriptionViewModel().Validate() for: " + romPath + " took: + " + stopwatch.Elapsed.ToString()); } #endif // REPORT_PERFORMANCE } var state = programDescription.Files.GetSupportFileState(ProgramFileKind.Rom); RomFileStatus = GetRomFileStatus(state); RomFileStatusIcon = StatusIcons[state]; Features = new ComparableObservableCollection <ProgramFeatureImageViewModel>(_description.Features.ToFeatureViewModels()); Initialize(); }
private void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "Features") { Features = new ComparableObservableCollection <ProgramFeatureImageViewModel>(_description.Features.ToFeatureViewModels()); } this.RaisePropertyChanged(PropertyChanged, e.PropertyName); }