EnableSnapping完成

This commit is contained in:
艾竹
2023-01-26 20:05:21 +08:00
parent b5867c148e
commit 04db0ef13b
14 changed files with 392 additions and 32 deletions

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
{
class PathGeneratorsViewModel : BaseViewModel
{
public PathGeneratorsViewModel()
{
Title = "Link Path Generators";
Info = "Path generators are functions that take as input the calculated route and output SVG paths, " +
"alongside the markers positions and their angles. There are currently two generators: Straight and Smooth.";
_service.ColorViewModel.FillColor.Color = System.Windows.Media.Colors.Orange;
DiagramViewModel = new DiagramViewModel();
DiagramViewModel.PageSizeType = PageSizeType.Custom;
DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
DefaultDesignerItemViewModel node1 = new DefaultDesignerItemViewModel() { Left = 50, Top = 80, Text = "1" };
DiagramViewModel.DirectAddItemCommand.Execute(node1);
DefaultDesignerItemViewModel node2 = new DefaultDesignerItemViewModel() { Left = 300, Top = 350, Text = "2" };
DiagramViewModel.DirectAddItemCommand.Execute(node2);
DefaultDesignerItemViewModel node3 = new DefaultDesignerItemViewModel() { Left = 400, Top = 100, Text = "3" };
DiagramViewModel.DirectAddItemCommand.Execute(node3);
ConnectionViewModel connector1 = new ConnectionViewModel(node1.RightConnector, node2.LeftConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterNormal);
connector1.AddLabel("Straight");
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
connector2.AddLabel("Smooth");
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
}
}
}

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
{
class RoutersViewModel : BaseViewModel
{
public RoutersViewModel()
{
Title = "Link Routers";
Info = "Routers are functions that take as input the link's vertices and can add points in between. " +
"There are currently two routers: Normal and Orthogonal.";
_service.ColorViewModel.FillColor.Color = System.Windows.Media.Colors.Orange;
DiagramViewModel = new DiagramViewModel();
DiagramViewModel.PageSizeType = PageSizeType.Custom;
DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
DefaultDesignerItemViewModel node1 = new DefaultDesignerItemViewModel() { Left = 50, Top = 80, Text = "1" };
DiagramViewModel.DirectAddItemCommand.Execute(node1);
DefaultDesignerItemViewModel node2 = new DefaultDesignerItemViewModel() { Left = 300, Top = 350, Text = "2" };
DiagramViewModel.DirectAddItemCommand.Execute(node2);
DefaultDesignerItemViewModel node3 = new DefaultDesignerItemViewModel() { Left = 350, Top = 100, Text = "3" };
DiagramViewModel.DirectAddItemCommand.Execute(node3);
ConnectionViewModel connector1 = new ConnectionViewModel(node1.RightConnector, node2.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
connector1.AddLabel("Normal");
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.LeftConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
connector2.AddLabel("Orthogonal");
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
{
class SnappingViewModel : BaseViewModel
{
public SnappingViewModel()
{
Title = "Link Snapping";
Info = "While dragging a new link, it will try to find (and link) to the closest target within a radius.";
_service.ColorViewModel.FillColor.Color = System.Windows.Media.Colors.Orange;
DiagramViewModel = new DiagramViewModel();
DiagramViewModel.PageSizeType = PageSizeType.Custom;
DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
DiagramViewModel.EnableSnapping = true;
DefaultDesignerItemViewModel node1 = new DefaultDesignerItemViewModel() { Left = 50, Top = 50, Text = "1" };
DiagramViewModel.DirectAddItemCommand.Execute(node1);
DefaultDesignerItemViewModel node2 = new DefaultDesignerItemViewModel() { Left = 300, Top = 300, Text = "2" };
DiagramViewModel.DirectAddItemCommand.Execute(node2);
DefaultDesignerItemViewModel node3 = new DefaultDesignerItemViewModel() { Left = 300, Top = 50, Text = "3" };
DiagramViewModel.DirectAddItemCommand.Execute(node3);
}
}
}