Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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();
        }
Пример #4
0
        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;
        }