Esempio n. 1
0
        protected override async Task OnParametersSetAsync()
        {
            if (SaveAs == SaveAs.Full || SaveAs == SaveAs.Page)
            {
                await SaveAsSVG();
            }
            if (GraphMode == GraphMode.Default)
            {
                SvgClass = "grab";
            }
            else if (GraphMode == GraphMode.InsertNode)
            {
                SvgClass = "insert";
            }
            else if (GraphMode == GraphMode.Algorithm)
            {
                if (StartAlgorithm.Ready)
                {
                    if (!StartAlgorithm.Done)
                    {
                        AlgorithmService.RunAlgorithm(Options, StartAlgorithm, Graph, AlgoExplain, ref PlayAlgorithm);
                        await AlgoExplainChanged.InvokeAsync(AlgoExplain);

                        await StartAlgorithmChanged.InvokeAsync(StartAlgorithm);
                    }
                    else
                    {
                        UpdateAlgoGraph();
                    }
                }
            }
        }
Esempio n. 2
0
        public async Task OnNodeClick(Node node)
        {
            if (StartAlgorithm.Algorithm != Algorithm.None && StartAlgorithm.Type != AlgorithmType.NoInput)
            {
                if (StartAlgorithm.StartNode == null)
                {
                    StartAlgorithm.StartNode = node;
                    if (StartAlgorithm.Type == AlgorithmType.OneInput)
                    {
                        StartAlgorithm.Ready = true;
                    }
                    await StartAlgorithmChanged.InvokeAsync(StartAlgorithm);
                }
                else if (StartAlgorithm.EndNode == null && StartAlgorithm.Type == AlgorithmType.TwoInput)
                {
                    StartAlgorithm.EndNode = node;
                    StartAlgorithm.Ready   = true;
                    await StartAlgorithmChanged.InvokeAsync(StartAlgorithm);
                }
            }
            await JustThisNodeActive(node);

            if (NewEdge.WaitingForNode)
            {
                NewEdge.WaitingForNode = false;
                await NewEdgeChanged.InvokeAsync(NewEdge);

                NewEdge.Head       = ActiveGraph.Nodes[0];
                NewEdge.MultiEdges = EdgeService.MultiGraphEdges(Graph.Edges, NewEdge.Head, NewEdge.Tail, Graph.Directed);
                if (Graph.Weighted == true)
                {
                    NewEdge.GetEdgeWeight = true;
                }
                else if (!NewEdge.MultiEdges.Any())
                {
                    await AddNewEdge(true);
                }
            }
            else if (GraphMode == GraphMode.InsertEdge)
            {
                await InsertEdge();
            }
        }
Esempio n. 3
0
        public async Task OnAlgoChanged(Algorithm a)
        {
            await GraphModeChanged.InvokeAsync(GraphMode.Algorithm);

            await StartAlgorithmChanged.InvokeAsync(new StartAlgorithm(a));
        }