Exemplo n.º 1
0
 public async Task OnRecenter()
 {
     SVGControl.Xaxis    = ActiveGraph.Nodes[0].Xaxis - (SVGControl.Width / 2);
     SVGControl.Yaxis    = ActiveGraph.Nodes[0].Yaxis - (SVGControl.Height / 2);
     SVGControl.OldXaxis = SVGControl.Xaxis;
     SVGControl.OldYaxis = SVGControl.Yaxis;
     await SVGControlChanged.InvokeAsync(SVGControl);
 }
Exemplo n.º 2
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            var x = Math.Round(ZoomService.GetMaxScale() - (PercentageZoom / 100.0), 2);

            if (SVGControl.Scale != x)
            {
                SVGControl.Scale = x;
                await SVGControlChanged.InvokeAsync(SVGControl);
            }
        }
Exemplo n.º 3
0
        public async Task Fit()
        {
            SVGControl.Xaxis    = Nodes.Min(n => n.Xaxis - n.Size);
            SVGControl.Yaxis    = Nodes.Min(n => n.Yaxis - n.Size) - 105;
            SVGControl.OldXaxis = SVGControl.Xaxis;
            SVGControl.OldYaxis = SVGControl.Yaxis;
            var width  = Nodes.Max(n => n.Xaxis + n.Size) - SVGControl.Xaxis;
            var height = Nodes.Max(n => n.Yaxis + n.Size) - SVGControl.Yaxis + 30;

            SVGControl.Scale = Math.Max(width / Browser.Width, height / Browser.Height);
            await SVGControlChanged.InvokeAsync(SVGControl);
        }
Exemplo n.º 4
0
 public async Task OnScroll(WheelEventArgs e)
 {
     if (e.DeltaY > 0)
     {
         if (ZoomService.ZoomOut(SVGControl))
         {
             await SVGControlChanged.InvokeAsync(SVGControl);
         }
     }
     else if (e.DeltaY < 0)
     {
         if (ZoomService.ZoomIn(SVGControl))
         {
             await SVGControlChanged.InvokeAsync(SVGControl);
         }
     }
 }
Exemplo n.º 5
0
 public async Task SelectionZoom(double i)
 {
     SVGControl.Scale = i;
     await SVGControlChanged.InvokeAsync(SVGControl);
 }
Exemplo n.º 6
0
        public async Task Select(MenuEventArgs <MenuItem> e)
        {
            switch (e.Item.Text)
            {
            case "Copy":
                Copy();
                break;

            case "Paste":
                await Paste();

                break;

            case "Left":
            case "Center":
            case "Right":
            case "Top":
            case "Middle":
            case "Bottom":
                NodeService.Align(ActiveGraph.Nodes, e.Item.Text);
                break;

            case "Delete":
                await DeleteActive.InvokeAsync("all");

                break;

            case "Edit":
            case "Nodes":
            case "Edges":
                await ChangeMenu.InvokeAsync(NavChoice.Design);

                break;

            case "All Nodes":
                await Activate("nodes");

                break;

            case "All Edges":
                await Activate("edges");

                break;

            case "Everything":
                await Activate("all");

                break;

            case "Insert Edge":
                await InsertEdge();

                break;

            case "Insert Node":
                NodeService.AddNode(Graph.Nodes, Options.Default, origin[0] * SVGControl.Scale + SVGControl.Xaxis, origin[1] * SVGControl.Scale + SVGControl.Yaxis);
                await GraphChanged.InvokeAsync(Graph);

                break;

            case "Stop Algorithm":
                if (StartAlgorithm.Done)
                {
                    StartAlgorithm.Clear = true;
                }
                else
                {
                    await Reset();
                }
                break;

            case "Zoom In":
                if (ZoomService.ZoomIn(SVGControl))
                {
                    await SVGControlChanged.InvokeAsync(SVGControl);
                }
                break;

            case "Zoom Out":
                if (ZoomService.ZoomOut(SVGControl))
                {
                    await SVGControlChanged.InvokeAsync(SVGControl);
                }
                break;
            }
        }