using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace wispro.sp.web.Pages
{
    public partial class TestGraphviz
    {
        private ElementReference _renderTo;

        [Inject]
        IJSRuntime JsRuntime { get; set; }

        protected override async Task OnInitializedAsync()
        {
            var diagramModule = await JsRuntime
                .InvokeAsync<IJSObjectReference>("import", "/diagrams.js");
            //n,ne,e,se,s,sw,w,nw
            var diagram = "digraph {label=\"案件系数申诉流程图\"  rankdir=\"TB\"  center=\"true\"\r\n" +
                "start[label=开始 shape=circle size=\"2pt,2pt\" fixedsize=true fontsize=8]\r\n" +
                "shensu[label=申诉, shape=box,fillcolor=chartreuse,style=filled href=\"http://www.baidu.com\"]\r\n" +
                "review[label=审核, shape=box,fillcolor=chartreuse,style=filled]\r\n" +
                "end[label=结束, shape=doublecircle fillcolor=gray,style=filled  fixedsize=true fontsize=8 size=\"2pt,2pt\"]\r\n" +
                "start->shensu->review->end\r\n" +
                "review:w->shensu:w}";

            await diagramModule.InvokeVoidAsync("renderDot", diagram, _renderTo,1100,800);
        }

        void ClickNode()
        {
            //Console.WriteLine("ClickNode!");
        }
    }
}
