public static ModuleGraph BuildGraph(ILogger logger, ModuleGraphDTO moduleGraphDto, IList <ModuleVertexViewModelBase> positions, bool smallFallbackIcons = false) { var graph = new ModuleGraph(); try { foreach (var platformModuleDto in moduleGraphDto.Vertices) { var res = (from p in positions where p.ID == platformModuleDto.Name select p).FirstOrDefault(); Point pos = res == null ? new Point(50, 50) : res.Position; var imagepath = @"Images\" + platformModuleDto.Type + ".png"; graph.AddVertex(new ModuleVertexViewModel(platformModuleDto.Name, imagepath, pos) { Capacity = platformModuleDto.MaxCapacity, Counter = platformModuleDto.PlatformItems.Count, Position = pos, DefaultVertexHeight = smallFallbackIcons ? 100 : 700 }); } foreach (var edgeDto in moduleGraphDto.Edges) { var edge = new ModuleEdgeViewModel( edgeDto.Id, FindModuleVertex(graph, edgeDto.Source), FindModuleVertex(graph, edgeDto.Target)) { OriginPortIndex = edgeDto.OriginPort, IsForcingEnabled = edgeDto.IsForcingEnabled }; DetectCyclicEdge(graph, edge); graph.AddEdge(edge); } foreach (var edge in graph.Edges) { DetectMultipleEdges(graph, edge); } } catch (Exception e) { logger.Error("Could not load and create Module PaperStreamGraph for Overview.", e); throw; } return(graph); }
public ModuleGraphDTO GraphToDto() { var graphDto = new ModuleGraphDTO { Vertices = (from v in Graph.Vertices let pm = (PlatformModule)v select pm.ToDTO()).ToList(), Edges = (from edge in Graph.Edges select new ModuleGraphEdgeDTO(edge.Id, edge.Source.Name, edge.Target.Name, edge.OriginPort, edge.TargetPort, edge.IsForcingEnabled)) .ToList() }; return(graphDto); }
protected override async void InitializeScreens() { ModuleGraphDTO moduleGraphDto = await _provideInitializationState.GetModuleGraph(); var initializer = new GuiModuleInitializer(_logger, ModuleRepository, new List <IConfigurationScreen>(), _container); initializer.CreateModules(moduleGraphDto); initializer.InitializeModules(); HomeScreenViewModel = ModuleRepository.GetModuleByType <HomeScreenViewModel>(0); _logger.Info("all screens initialized"); InitializeBreadcrumbBar(); }
public void CreateModules(ModuleGraphDTO moduleGraphDto) { foreach (var platformModuleDto in moduleGraphDto.Vertices) { var module = CreateModuleByType(platformModuleDto.Type); if (module == null) { continue; } module.ModuleKey = platformModuleDto.Name; module.ModuleTypeId = platformModuleDto.Type; module.ModuleInstance = GetNextInstancePerType(platformModuleDto.Type); ((ModuleScreenContainer)_moduleRepository).AddNewModule(module); } // create all other modules without a specific type CreateModules(); }
public MosaicNextModuleProvider(IModuleBusManager moduleBusManager, IModuleSimulatorRepository moduleRepository) { _moduleRepository = moduleRepository; _graphDto = moduleBusManager.GraphDto; }