/// <summary> /// Load the project file. /// </summary> /// <param name="project">Project to load.</param> public void LoadProject(Project project) { Status = string.Format("Loading project {0}...", project.GetProjectFullPath()); log.Debug(Status); _eventAggregator.PublishOnUIThreadAsync(new StatusMessageEvent(Status)); // Only load the maximum number of configurations to see // all the configurations int numEns = project.GetNumberOfEnsembles(); if (numEns > RTI.Commons.MAX_CONFIGURATIONS) { numEns = RTI.Commons.MAX_CONFIGURATIONS; } // Load all the configurations ViewSubsystemConfig prevConfig = null; for (int x = 1; x <= numEns; x++) { // Process the first 12 ensembles because there can only be up to 12 configurations ProcessEnsemble(project.GetEnsemble(x), EnsembleSource.Playback, AdcpCodec.CodecEnum.Binary); // Create subsystem config ViewSubsystemConfig config = new ViewSubsystemConfig(project.GetEnsemble(x).EnsembleData.SubsystemConfig, EnsembleSource.Playback); if (config != null) { // Check if the config exist already //if (!_dictSsConfig.ContainsKey(config)) { // Only load new configs if (config != prevConfig) { _dictSsConfig[config].LoadProject(project); } // Keep track of the previous config so we do not reload the same configuration prevConfig = config; Status = string.Format("Add configuration {0}", config.Config.DescString()); log.Debug(Status); _eventAggregator.PublishOnUIThreadAsync(new StatusMessageEvent(Status)); } } } // Select the last config add SelectedSsConfigIndex = SsConfigList.Count(); Status = string.Format("Add Project {0}", project.GetProjectFullPath()); log.Debug(string.Format(Status)); _eventAggregator.PublishOnUIThreadAsync(new StatusMessageEvent(Status)); }
/// <summary> /// Process the ensembles. Look for new subsystem configurations with each ensemble. /// </summary> /// <param name="ensemble"></param> /// <param name="source"></param> /// <param name="dataFormat"></param> /// <returns></returns> public void ProcessEnsemble(Ensemble ensemble, EnsembleSource source, AdcpCodec.CodecEnum dataFormat) { if (ensemble != null && ensemble.IsEnsembleAvail) { // Create subsystem config ViewSubsystemConfig config = new ViewSubsystemConfig(ensemble.EnsembleData.SubsystemConfig, source); // Check if the config exist already if (!_dictSsConfig.ContainsKey(config)) { // Create the viewmodel for each subsystem config/source found DashboardSubsystemConfigViewModel vm = new DashboardSubsystemConfigViewModel(config); // Add the vm to the list _dictSsConfig.Add(config, vm); // Add to the list of subsystems Application.Current.Dispatcher.Invoke((System.Action) delegate { SsConfigList.Add(vm); }); log.Debug(string.Format("Add configuration {0}", config.Config.DescString())); // Select the last config add SelectedSsConfigIndex = SsConfigList.Count(); // Pass the ensemble to the viewmodel vm.ProcessEnsemble(ensemble, source); //return config; } else { // Viewmodel already exist, so send the ensemble //DashboardSubsystemConfigViewModel vm = null; //if (_dictSsConfig.TryGetValue(config, out vm)) //{ // vm.ProcessEnsemble(ensemble, source); //} //return config; } } // Not a valid ensemble //return null; }
/// <summary> /// Remove the View model from the tab list. /// </summary> public void CloseTab() { Status = string.Format("Remove configuration {0}...", _SelectedSsConfig.Config.Config.DescString()); log.Debug(string.Format("Remove configuration {0}...", _SelectedSsConfig.Config.Config.DescString())); _eventAggregator.PublishOnUIThreadAsync(new StatusMessageEvent(Status)); // Remove it from the dictionary _dictSsConfig.Remove(_SelectedSsConfig.Config); // Shutdown the VM _SelectedSsConfig.Dispose(); // Remove it from the List SsConfigList.Remove(_SelectedSsConfig); // Select the last config add SelectedSsConfigIndex = SsConfigList.Count(); }