/// <summary> /// Clear all the configurations. /// This is done when a new project is selected. /// </summary> private void ClearConfig() { _SelectedGraphicalVM = null; foreach (var vm in _graphicalVMDict.Values) { vm.Dispose(); } _graphicalVMDict.Clear(); this.NotifyOfPropertyChange(() => this.GraphicalVMList); }
/// <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) { if (!_graphicalVMDict.ContainsKey(config)) { if (_graphicalVMDict.TryAdd(config, new ViewDataGraphicalViewModel(config))) { this.NotifyOfPropertyChange(() => this.GraphicalVMList); // Select a tab is nothing is selected if (_SelectedGraphicalVM == null) { if (GraphicalVMList.Count > 0) { SelectedGraphicalVM = GraphicalVMList[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 (_graphicalVMDict.ContainsKey(closeVmEvent.SubsysDataConfig)) { // Dispose the display then remove the display _graphicalVMDict[closeVmEvent.SubsysDataConfig].Dispose(); ViewDataGraphicalViewModel vm = null; if (_graphicalVMDict.TryRemove(closeVmEvent.SubsysDataConfig, out vm)) { this.NotifyOfPropertyChange(() => this.GraphicalVMList); // Select a tab is nothing is selected if (_SelectedGraphicalVM == null) { if (GraphicalVMList.Count > 0) { SelectedGraphicalVM = GraphicalVMList[0]; } } } } }