using System.IO; using System.Windows; using CommunityToolkit.Mvvm.ComponentModel; using Livia.Models; using Livia.Utility.DependencyInjection; using Livia.ViewModels; using Microsoft.Extensions.DependencyInjection; namespace SiemensCereflow.ViewModels; public class SiemensCereFlowControlViewModel : ObservableRecipient, ILiviaControlViewModel { public ImageRotationViewerControlViewModel BrainLobesImageRotationViewerControlViewModel { get; } public ImageRotationViewerControlViewModel ArterialTerritoriesImageRotationViewerControlViewModel { get; } public ImageRotationViewerControlViewModel LimbicSystemImageRotationViewerControlViewModel { get; } public PerfusionDataGridControlViewModel CerebrumCerebellumPerfusionDataGridControlViewModel { get; } public PerfusionDataGridControlViewModel BrainLobesPerfusionDataGridControlViewModel { get; } public PerfusionDataGridControlViewModel ArterialTerritoriesPerfusionDataGridControlViewModel { get; } public PerfusionDataGridControlViewModel LimbicSystemPerfusionDataGridControlViewModel { get; } public MosaicImageGroupControlViewModel MosaicImageGroupViewModel { get; } public IDataBlockLoader DataBlockLoader { get; } public SiemensCereFlowControlViewModel(IDataBlockLoader dataBlockLoader) { DataBlockLoader = dataBlockLoader; BrainLobesImageRotationViewerControlViewModel = ActivatorUtilities.CreateInstance(ServiceProviderFactory.ServiceProvider); BrainLobesImageRotationViewerControlViewModel.DisplayName = (string)Application.Current.TryFindResource("BrainLobesRotationViewerName"); BrainLobesImageRotationViewerControlViewModel.AtlasMaskLoadPath = @"atlas\AnImage_BrainLobes\mask"; BrainLobesImageRotationViewerControlViewModel.StructLoadPath = "structure"; BrainLobesImageRotationViewerControlViewModel.StructDataType = ImageRotationViewerDataType.Dicom2D; BrainLobesImageRotationViewerControlViewModel.AtlasId = "AnImage_BrainLobes"; BrainLobesImageRotationViewerControlViewModel.ImageIndexSyncKey = "structure"; dataBlockLoader.AddViewModel(BrainLobesImageRotationViewerControlViewModel); ArterialTerritoriesImageRotationViewerControlViewModel = ActivatorUtilities.CreateInstance(ServiceProviderFactory.ServiceProvider); ArterialTerritoriesImageRotationViewerControlViewModel.DisplayName = (string)Application.Current.TryFindResource("ArterialTerritoriesRotationViewerName"); ArterialTerritoriesImageRotationViewerControlViewModel.AtlasMaskLoadPath = @"atlas\AnImage_ArterialTerritories\mask"; ArterialTerritoriesImageRotationViewerControlViewModel.StructLoadPath = "structure"; ArterialTerritoriesImageRotationViewerControlViewModel.StructDataType = ImageRotationViewerDataType.Dicom2D; ArterialTerritoriesImageRotationViewerControlViewModel.AtlasId = "AnImage_ArterialTerritories"; ArterialTerritoriesImageRotationViewerControlViewModel.ImageIndexSyncKey = "structure"; dataBlockLoader.AddViewModel(ArterialTerritoriesImageRotationViewerControlViewModel); LimbicSystemImageRotationViewerControlViewModel = ActivatorUtilities.CreateInstance(ServiceProviderFactory.ServiceProvider); LimbicSystemImageRotationViewerControlViewModel.DisplayName = (string)Application.Current.TryFindResource("LimbicSystemRotationViewerName"); LimbicSystemImageRotationViewerControlViewModel.AtlasMaskLoadPath = @"atlas\LimbicSystem\mask"; LimbicSystemImageRotationViewerControlViewModel.StructLoadPath = "structure"; LimbicSystemImageRotationViewerControlViewModel.StructDataType = ImageRotationViewerDataType.Dicom2D; LimbicSystemImageRotationViewerControlViewModel.AtlasId = "LimbicSystem"; LimbicSystemImageRotationViewerControlViewModel.ImageIndexSyncKey = "structure"; dataBlockLoader.AddViewModel(LimbicSystemImageRotationViewerControlViewModel); CerebrumCerebellumPerfusionDataGridControlViewModel = ActivatorUtilities.CreateInstance(ServiceProviderFactory.ServiceProvider); CerebrumCerebellumPerfusionDataGridControlViewModel.LoadPath = Path.Combine("atlas", "AnImage_CerebrumCerebellum", "cbf.json"); dataBlockLoader.AddViewModel(CerebrumCerebellumPerfusionDataGridControlViewModel); BrainLobesPerfusionDataGridControlViewModel = ActivatorUtilities.CreateInstance(ServiceProviderFactory.ServiceProvider); BrainLobesPerfusionDataGridControlViewModel.LoadPath = Path.Combine("atlas", "AnImage_BrainLobes", "cbf.json"); dataBlockLoader.AddViewModel(BrainLobesPerfusionDataGridControlViewModel); ArterialTerritoriesPerfusionDataGridControlViewModel = ActivatorUtilities.CreateInstance(ServiceProviderFactory.ServiceProvider); ArterialTerritoriesPerfusionDataGridControlViewModel.LoadPath = Path.Combine("atlas", "AnImage_ArterialTerritories", "cbf.json"); dataBlockLoader.AddViewModel(ArterialTerritoriesPerfusionDataGridControlViewModel); LimbicSystemPerfusionDataGridControlViewModel = ActivatorUtilities.CreateInstance(ServiceProviderFactory.ServiceProvider); LimbicSystemPerfusionDataGridControlViewModel.LoadPath = Path.Combine("atlas", "LimbicSystem", "cbf.json"); dataBlockLoader.AddViewModel(LimbicSystemPerfusionDataGridControlViewModel); MosaicImageGroupViewModel = ActivatorUtilities.CreateInstance(ServiceProviderFactory.ServiceProvider); dataBlockLoader.AddDeferredLoadingModuleViewModel(MosaicImageGroupViewModel); dataBlockLoader.Init(); } public List GenerateReportModuleGroups() { List atlasItems = [ new ReportModuleItemViewModel( (string)Application.Current.TryFindResource("CerebrumCerebellumPerfusionDataGridName"), "AnImage_CerebrumCerebellum"), new ReportModuleItemViewModel((string)Application.Current.TryFindResource("BrainLobesRotationViewerName"), "AnImage_BrainLobes"), new ReportModuleItemViewModel( (string)Application.Current.TryFindResource("ArterialTerritoriesRotationViewerName"), "AnImage_ArterialTerritories"), new ReportModuleItemViewModel((string)Application.Current.TryFindResource("LimbicSystemRotationViewerName"), "LimbicSystem") ]; //TODO::maybe cache it when loading data is better. No need to check colorMap List colorImageItems = (from viewModel in MosaicImageGroupViewModel.MosaicImageCollection where viewModel.UseColorBar select new ReportModuleItemViewModel(viewModel.DisplayName, viewModel.DisplayName)).ToList(); colorImageItems.Add(new ReportModuleItemViewModel((string)Application.Current.TryFindResource("ReportModuleFocus"), "Focus")); List result = [ new ReportModuleExpanderViewModel((string)Application.Current.TryFindResource("ReportModuleAtlas"), "atlas", atlasItems), new ReportModuleExpanderViewModel((string)Application.Current.TryFindResource("ReportModuleColorImage"), "colorImage", colorImageItems) ]; return result; } }