mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-14 13:16:38 +08:00
EnableSnapping完成
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Demo.Views.PathGeneratorsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<!-- Diagram Control -->
|
||||
<dd:DiagramControl x:Name="diagram" DataContext="{Binding DiagramViewModel}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||
|
||||
<controls:TitleControl/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Demo.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// PathGeneratorsView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class PathGeneratorsView : UserControl
|
||||
{
|
||||
public PathGeneratorsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Demo.Views.RoutersView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<!-- Diagram Control -->
|
||||
<dd:DiagramControl x:Name="diagram" DataContext="{Binding DiagramViewModel}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||
|
||||
<controls:TitleControl/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Demo.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// RoutersView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class RoutersView : UserControl
|
||||
{
|
||||
public RoutersView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Demo.Views.SnappingView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<!-- Diagram Control -->
|
||||
<dd:DiagramControl x:Name="diagram" DataContext="{Binding DiagramViewModel}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||
|
||||
<controls:TitleControl/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Demo.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// SnappingView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class SnappingView : UserControl
|
||||
{
|
||||
public SnappingView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user