mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-13 04:36:37 +08:00
内部连接点示例
This commit is contained in:
@@ -75,6 +75,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo
|
||||
Children=new List<MenuItemViewModel>
|
||||
{
|
||||
new MenuItemViewModel(){Title = "ColoredPort"},
|
||||
new MenuItemViewModel(){Title = "InnerPort"}
|
||||
}
|
||||
},
|
||||
new MenuItemViewModel(){Title = "Groups",
|
||||
|
||||
@@ -73,8 +73,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node2);
|
||||
|
||||
connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector);
|
||||
connector1.ShapeViewModel.SourceMarker = new LinkMarker("M 0 -8 L 3 -8 3 8 0 8 z M 4 -8 7 -8 7 8 4 8 z M 8 -8 16 0 8 8 z", 16, ArrowPathStyle.Arrow, ArrowSizeStyle.ExtraLarge);
|
||||
connector1.ShapeViewModel.SinkMarker = new LinkMarker("M 0 -8 L 8 -8 4 0 8 8 0 8 4 0 z", 8, ArrowPathStyle.Arrow, ArrowSizeStyle.Small);
|
||||
connector1.ShapeViewModel.SourceMarker = new LinkMarker("M 0 -8 L 3 -8 3 8 0 8 z M 4 -8 7 -8 7 8 4 8 z M 8 -8 16 0 8 8 z", 16, 16, ArrowPathStyle.Arrow, ArrowSizeStyle.ExtraLarge);
|
||||
connector1.ShapeViewModel.SinkMarker = new LinkMarker("M 0 -8 L 8 -8 4 0 8 8 0 8 4 0 z", 8, 8, ArrowPathStyle.Arrow, ArrowSizeStyle.Small);
|
||||
connector1.AddLabel("Custom");
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
||||
|
||||
|
||||
@@ -36,6 +36,23 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
connector2.AddLabel("Smooth");
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DefaultDesignerItemViewModel node11 = new DefaultDesignerItemViewModel(DiagramViewModel) { Left = 50, Top = 450, Text = "11" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node11);
|
||||
|
||||
DefaultDesignerItemViewModel node12 = new DefaultDesignerItemViewModel(DiagramViewModel) { Left = 250, Top = 648, Text = "12" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node12);
|
||||
|
||||
DefaultDesignerItemViewModel node13 = new DefaultDesignerItemViewModel(DiagramViewModel) { Left = 400, Top = 450, Text = "13" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node13);
|
||||
|
||||
ConnectionViewModel connector11 = new ConnectionViewModel(DiagramViewModel, node11.RightConnector, node12.LeftConnector, DrawMode.ConnectingLineBoundary, RouterMode.RouterNormal);
|
||||
connector11.AddLabel("Boundary");
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector11);
|
||||
|
||||
ConnectionViewModel connector12 = new ConnectionViewModel(DiagramViewModel, node12.RightConnector, node13.LeftConnector, DrawMode.ConnectingLineCorner, RouterMode.RouterNormal);
|
||||
connector12.AddLabel("Corner");
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector12);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
{
|
||||
class InnerPortViewModel : BaseViewModel
|
||||
{
|
||||
public InnerPortViewModel()
|
||||
{
|
||||
Title = "InnerPort";
|
||||
Info = "You can add connection points inside a node";
|
||||
|
||||
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" };
|
||||
node1.ClearConnectors();
|
||||
var port1 = new FullyCreatedConnectorInfo(DiagramViewModel, node1, ConnectorOrientation.Right, true) { XRatio = 0.5, YRatio = 0.5 };
|
||||
node1.AddConnector(port1);
|
||||
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node1);
|
||||
|
||||
DefaultDesignerItemViewModel node2 = new DefaultDesignerItemViewModel(DiagramViewModel) { Left = 300, Top = 300, Text = "2" };
|
||||
node2.ClearConnectors();
|
||||
var port2_1 = new FullyCreatedConnectorInfo(DiagramViewModel, node2, ConnectorOrientation.Top, true) { XRatio = 0.2, YRatio = 0.8 };
|
||||
var port2_2 = new FullyCreatedConnectorInfo(DiagramViewModel, node2, ConnectorOrientation.Top, true) { XRatio = 0.8, YRatio = 0.2 };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node2);
|
||||
|
||||
DefaultDesignerItemViewModel node3 = new DefaultDesignerItemViewModel(DiagramViewModel) { Left = 300, Top = 50, Text = "3" };
|
||||
node3.ClearConnectors();
|
||||
var port3 = new FullyCreatedConnectorInfo(DiagramViewModel, node3, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 0.5 };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node3);
|
||||
|
||||
ConnectionViewModel connector1 = new ConnectionViewModel(DiagramViewModel, port1, port2_1, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
||||
|
||||
ConnectionViewModel connector2 = new ConnectionViewModel(DiagramViewModel, port2_2, port3, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Demo.Views.InnerPortView"
|
||||
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>
|
||||
/// InnerPortView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class InnerPortView : UserControl
|
||||
{
|
||||
public InnerPortView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user