/// <summary> /// Clear all the configurations. /// This is done when a new project is selected. /// </summary> private void ClearConfig() { _SelectedScreenDataVM = null; foreach (var vm in _screenDataVMDict.Values) { vm.Dispose(); } _screenDataVMDict.Clear(); this.NotifyOfPropertyChange(() => this.ScreenDataVMList); }
/// <summary> /// Add a configuration. This will create the ViewModel based /// off the configuration given. /// </summary> /// <param name="config">Configuration to use to create the ViewModel.</param> private void AddConfig(SubsystemDataConfig config) { // Do not screen the averaged data, it has already been averaged if (!_screenDataVMDict.ContainsKey(config) && config.Source != EnsembleSource.STA && config.Source != EnsembleSource.LTA) { if (_screenDataVMDict.TryAdd(config, new ScreenDataViewModel(config))) { this.NotifyOfPropertyChange(() => this.ScreenDataVMList); // Select a tab is nothing is selected if (_SelectedScreenDataVM == null) { if (ScreenDataVMList.Count > 0) { SelectedScreenDataVM = ScreenDataVMList[0]; } } } } }
/// <summary> /// Remove the display based off the SubsystemDataConfig /// given in the event. /// </summary> /// <param name="closeVmEvent">Contains the SubsystemDataConfig to remove the display.</param> public void Handle(CloseVmEvent closeVmEvent) { // Check if the display exist if (_screenDataVMDict.ContainsKey(closeVmEvent.SubsysDataConfig)) { // Dispose the display then remove the display _screenDataVMDict[closeVmEvent.SubsysDataConfig].Dispose(); ScreenDataViewModel vm = null; if (_screenDataVMDict.TryRemove(closeVmEvent.SubsysDataConfig, out vm)) { this.NotifyOfPropertyChange(() => this.ScreenDataVMList); // Select a tab is nothing is selected if (SelectedScreenDataVM == null) { if (ScreenDataVMList.Count > 0) { SelectedScreenDataVM = ScreenDataVMList[0]; } } } } }