IsPortless 画线

This commit is contained in:
艾竹
2023-01-27 20:10:17 +08:00
parent 72e3efb052
commit e8bd6faa21
15 changed files with 197 additions and 49 deletions

View File

@@ -56,7 +56,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo
Children=new List<MenuItemViewModel>
{
new MenuItemViewModel(){Title = "Svg"},
new MenuItemViewModel(){Title = "Portless"},
new MenuItemViewModel(){Title = "PortlessLinks"},
}
},
new MenuItemViewModel(){Title = "Links",
@@ -87,13 +87,13 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo
},
new MenuItemViewModel(){Title = "Algorithms",
Children=new List<MenuItemViewModel>
{
{
new MenuItemViewModel(){Title = "ReconnectLinksToClosestPorts"},
}
},
new MenuItemViewModel(){Title = "Animations",
Children=new List<MenuItemViewModel>
{
{
new MenuItemViewModel(){Title = "PathAnimation"},
new MenuItemViewModel(){Title = "LineAnimation"},
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
{
class PortlessLinksViewModel : BaseViewModel
{
public PortlessLinksViewModel()
{
Title = "Portless Links";
Info = "Starting from 2.0, you can create links between nodes directly! " +
"All you need to specify is the shape of your nodes in order to calculate the connection points.";
DiagramViewModel = new DiagramViewModel();
DiagramViewModel.PageSizeType = PageSizeType.Custom;
DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
DiagramViewModel.ColorViewModel = new ColorViewModel();
DiagramViewModel.ColorViewModel.FillColor.Color = System.Windows.Media.Colors.Orange;
DefaultDesignerItemViewModel node1 = new DefaultDesignerItemViewModel(DiagramViewModel) { Left = 50, Top = 50, Text = "1" };
DiagramViewModel.DirectAddItemCommand.Execute(node1);
DefaultDesignerItemViewModel node2 = new DefaultDesignerItemViewModel(DiagramViewModel) { Left = 300, Top = 50, Text = "2" };
DiagramViewModel.DirectAddItemCommand.Execute(node2);
DefaultDesignerItemViewModel node3 = new DefaultDesignerItemViewModel(DiagramViewModel) { Left = 300, Top = 300, Text = "3" };
DiagramViewModel.DirectAddItemCommand.Execute(node3);
DefaultDesignerItemViewModel node4 = new DefaultDesignerItemViewModel(DiagramViewModel) { Left = 50, Top = 300, Text = "4" };
DiagramViewModel.DirectAddItemCommand.Execute(node4);
ConnectionViewModel connector1 = new ConnectionViewModel(DiagramViewModel, node1.PortlessConnector, node2.PortlessConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
ConnectionViewModel connector2 = new ConnectionViewModel(DiagramViewModel, node2.PortlessConnector, node3.RightConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
ConnectionViewModel connector3 = new ConnectionViewModel(DiagramViewModel, node3.LeftConnector, node4.PortlessConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
DiagramViewModel.DirectAddItemCommand.Execute(connector3);
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
}
}
}

View File

@@ -7,9 +7,18 @@
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<DataTemplate DataType="{x:Type dd:GroupDesignerItemViewModel}">
<Grid IsHitTestVisible="{Binding IsHitTestVisible}">
<TextBlock Text="Group"/>
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid>
<!-- Diagram Control -->
<dd:DiagramControl x:Name="diagram" DataContext="{Binding DiagramViewModel}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<dd:DiagramControl x:Name="diagram" DataContext="{Binding DiagramViewModel}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
</dd:DiagramControl>
<controls:TitleControl/>
</Grid>

View File

@@ -0,0 +1,16 @@
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Demo.Views.PortlessLinksView"
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>

View File

@@ -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>
/// PortlessLinksView.xaml 的交互逻辑
/// </summary>
public partial class PortlessLinksView : UserControl
{
public PortlessLinksView()
{
InitializeComponent();
}
}
}

View File

@@ -21,7 +21,7 @@
SmallChange="0.1"
LargeChange="0.1"
Width="200"
HorizontalAlignment="Right"
HorizontalAlignment="Left"
VerticalAlignment="Top"/>
<controls:TitleControl/>