mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-13 21:16:37 +08:00
大部分完成,还有写要解决的问题
This commit is contained in:
BIN
AIStudio.Wpf.DiagramDesigner.Demo/A.ico
Normal file
BIN
AIStudio.Wpf.DiagramDesigner.Demo/A.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -6,6 +6,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="A.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AIStudio.Wpf.DiagramDesigner.Additionals\AIStudio.Wpf.DiagramDesigner.Additionals.csproj" />
|
||||
<ProjectReference Include="..\AIStudio.Wpf.DiagramDesigner\AIStudio.Wpf.DiagramDesigner.csproj" />
|
||||
<ProjectReference Include="..\AIStudio.Wpf.Flowchart\AIStudio.Wpf.Flowchart.csproj" />
|
||||
</ItemGroup>
|
||||
@@ -14,4 +19,12 @@
|
||||
<Folder Include="Views\Algorithms\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AIStudio.Wpf.Controls" Version="1.1.44" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="A.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -60,6 +60,10 @@
|
||||
<SolidColorBrush x:Key="Fluent.Ribbon.Brushes.Button.MouseOver.Background" Color="{StaticResource Fluent.Ribbon.Colors.AccentColor20}" options:Freeze="True" />
|
||||
</ResourceDictionary>
|
||||
|
||||
<!--AIStudio-->
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Controls;component/Themes/Colors.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Controls;component/Themes/MahApps.xaml"/>
|
||||
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Themes/Generic.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<Window x:Class="AIStudio.Wpf.DiagramDesigner.Demo.MainWindow"
|
||||
<ac:WindowBase x:Class="AIStudio.Wpf.DiagramDesigner.Demo.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo"
|
||||
xmlns:ac="https://gitee.com/akwkevin/AI-wpf-controls"
|
||||
mc:Ignorable="d"
|
||||
Title="AIStudio.Wpf.DiagramDesigner.Demo" Height="450" Width="800">
|
||||
Title="AIStudio.Wpf.DiagramDesigner.Demo"
|
||||
Icon="A.ico"
|
||||
Style="{StaticResource AIStudio.Styles.WindowBase}"
|
||||
Height="450" Width="800">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="100" />
|
||||
@@ -20,4 +23,4 @@
|
||||
Grid.Column="1"
|
||||
Margin="0" />
|
||||
</Grid>
|
||||
</Window>
|
||||
</ac:WindowBase>
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using AIStudio.Wpf.Controls;
|
||||
using AIStudio.Wpf.DiagramDesigner.Demo.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Demo
|
||||
@@ -19,7 +20,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
public partial class MainWindow : WindowBase
|
||||
{
|
||||
#region Identity
|
||||
private static IDictionary<string, Type> _viewDic;
|
||||
|
||||
@@ -28,5 +28,15 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public int Index
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public int ParentIndex
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
ConnectionViewModel connector2 = new ConnectionViewModel(node2.BottomConnector, node3.BottomConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
{
|
||||
class ThickLinkViewModel : BaseViewModel
|
||||
{
|
||||
public ThickLinkViewModel()
|
||||
{
|
||||
Title = "Custom link";
|
||||
Info = "Creating your own custom links is very easy!";
|
||||
|
||||
_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 = 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);
|
||||
|
||||
ConnectionViewModel connector1 = new ConnectionViewModel(node1.RightConnector, node2.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
connector1.ColorViewModel.LineWidth = 6;
|
||||
connector1.ColorViewModel.LineColor.BrushType = BrushType.LinearGradientBrush;
|
||||
connector1.ColorViewModel.LineColor.GradientStop = new ObservableCollection<GradientStop>();
|
||||
connector1.ColorViewModel.LineColor.GradientStop.Add(new GradientStop(System.Windows.Media.Colors.Red, 0));
|
||||
connector1.ColorViewModel.LineColor.GradientStop.Add(new GradientStop(System.Windows.Media.Colors.Gray, 1));
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
||||
|
||||
ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
connector2.ColorViewModel.LineWidth = 6;
|
||||
connector2.ColorViewModel.LineColor.Color = System.Windows.Media.Colors.Blue;
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
{
|
||||
class GroupingViewModel : BaseViewModel
|
||||
{
|
||||
public GroupingViewModel()
|
||||
{
|
||||
Title = "Simple";
|
||||
Info = "A simple example of AIStudio.Wpf.DiagramDesigner.";
|
||||
|
||||
_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 = 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);
|
||||
|
||||
ConnectionViewModel connector1 = new ConnectionViewModel(node1.RightConnector, node2.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
||||
|
||||
ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DiagramViewModel.GroupCommand.Execute(new List<DesignerItemViewModelBase> { node1, node2 });
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
connector1.AddLabel("(0,-20)", 50, new Point(0, -20));
|
||||
connector1.AddLabel("(0,20)", -50, new Point(0, 20));
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
connector1.AddLabel("Custom");
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
connector2.AddLabel("Smooth");
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.LeftConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
connector2.AddLabel("Orthogonal");
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
DiagramViewModel = new DiagramViewModel();
|
||||
DiagramViewModel.PageSizeType = PageSizeType.Custom;
|
||||
DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
|
||||
DiagramViewModel.EnableSnapping = true;
|
||||
DiagramViewModel.DrawModeViewModel = new DrawModeViewModel() { EnableSnapping = true };
|
||||
|
||||
DefaultDesignerItemViewModel node1 = new DefaultDesignerItemViewModel() { Left = 50, Top = 50, Text = "1" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node1);
|
||||
@@ -27,6 +27,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
|
||||
DefaultDesignerItemViewModel node3 = new DefaultDesignerItemViewModel() { Left = 300, Top = 50, Text = "3" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node3);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
{
|
||||
class VerticesViewModel : BaseViewModel
|
||||
{
|
||||
public VerticesViewModel()
|
||||
{
|
||||
Title = "Link Vertices";
|
||||
Info = "Click on a link to create a vertex. Double click on a vertex to delete it. " +
|
||||
"You can drag the vertices around.";
|
||||
|
||||
_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 = 200, 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("Content");
|
||||
connector1.AddVertex(new Point(221, 112.5));
|
||||
connector1.AddVertex(new Point(111, 291));
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
||||
|
||||
ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
connector2.AddLabel("Content");
|
||||
connector2.AddVertex(new Point(400, 324));
|
||||
connector2.AddVertex(new Point(326, 180));
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
connector2.IsReadOnly = true;
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
{
|
||||
class SvgViewModel : BaseViewModel
|
||||
{
|
||||
public SvgViewModel()
|
||||
{
|
||||
Title = "Custom node";
|
||||
Info = "Creating your own custom design is very easy!";
|
||||
|
||||
//_service.ColorViewModel.FillColor.Color = System.Windows.Media.Colors.Orange;
|
||||
|
||||
DiagramViewModel = new DiagramViewModel();
|
||||
DiagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
|
||||
DiagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
|
||||
DiagramViewModel.PageSizeType = PageSizeType.Custom;
|
||||
DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
|
||||
|
||||
DefaultDesignerItemViewModel node1 = new DefaultDesignerItemViewModel() { Left = 50, Top = 50, Text = "1" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node1);
|
||||
|
||||
PathItemViewModel node2 = new PathItemViewModel() { Left = 300, Top = 300, Icon = "M 0 -50 L 50 -50 L 50 -10 A 1 1 0 0 0 50 10 L 50 50 L 0 50 L 0 10 A 1 1 0 0 0 0 -10 Z" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node2);
|
||||
|
||||
PathItemViewModel node3 = new PathItemViewModel() { Left = 300, Top = 50, Icon = "M 0 -50 L 50 -50 L 50 -10 A 1 1 0 0 0 50 10 L 50 50 L 0 50 L 0 10 A 1 1 0 0 0 0 -10 Z" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node3);
|
||||
|
||||
ConnectionViewModel connector1 = new ConnectionViewModel(node1.RightConnector, node2.TopConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
||||
|
||||
ConnectionViewModel connector2 = new ConnectionViewModel(node2.BottomConnector, node3.BottomConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
||||
}
|
||||
}
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
ReconnectLinksCommand = new SimpleCommand(ReconnectLinks);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
|
||||
public SimpleCommand ReconnectLinksCommand
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
|
||||
ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Demo.Views.ThickLinkView"
|
||||
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>
|
||||
/// ThickLinkView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ThickLinkView : UserControl
|
||||
{
|
||||
public ThickLinkView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Demo.Views.GroupingView"
|
||||
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>
|
||||
/// GroupingView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class GroupingView : UserControl
|
||||
{
|
||||
public GroupingView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Demo.Views.VerticesView"
|
||||
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>
|
||||
/// VerticesView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class VerticesView : UserControl
|
||||
{
|
||||
public VerticesView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
AIStudio.Wpf.DiagramDesigner.Demo/Views/Nodes/SvgView.xaml
Normal file
23
AIStudio.Wpf.DiagramDesigner.Demo/Views/Nodes/SvgView.xaml
Normal file
@@ -0,0 +1,23 @@
|
||||
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Demo.Views.SvgView"
|
||||
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">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner.Additionals;component/Extensions/ViewModels/PathItemViewModel.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<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>
|
||||
/// SvgView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class SvgView : UserControl
|
||||
{
|
||||
public SvgView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_viewModel.DrawModeViewModel?.LineDrawMode != null)
|
||||
if (_viewModel.DrawModeViewModel != null)
|
||||
{
|
||||
return _viewModel.DrawModeViewModel.LineDrawMode;
|
||||
}
|
||||
@@ -55,7 +55,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_viewModel.DrawModeViewModel?.LineRouterMode != null)
|
||||
if (_viewModel.DrawModeViewModel != null)
|
||||
{
|
||||
return _viewModel.DrawModeViewModel.LineRouterMode;
|
||||
}
|
||||
@@ -70,7 +70,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get
|
||||
{
|
||||
return _viewModel.EnableSnapping;
|
||||
if (_viewModel.DrawModeViewModel != null)
|
||||
{
|
||||
return _viewModel.DrawModeViewModel.EnableSnapping;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _service.DrawModeViewModel.EnableSnapping;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +85,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get
|
||||
{
|
||||
return _viewModel.SnappingRadius;
|
||||
if (_viewModel.DrawModeViewModel != null)
|
||||
{
|
||||
return _viewModel.DrawModeViewModel.SnappingRadius;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _service.DrawModeViewModel.SnappingRadius;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
if (item is DesignerItemViewModelBase)
|
||||
{
|
||||
|
||||
return (Style)itemsControl.FindResource("designerItemStyle");
|
||||
}
|
||||
|
||||
|
||||
@@ -186,5 +186,31 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
private bool _enableSnapping;
|
||||
public bool EnableSnapping
|
||||
{
|
||||
get
|
||||
{
|
||||
return _enableSnapping;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _enableSnapping, value);
|
||||
}
|
||||
}
|
||||
|
||||
private double _snappingRadius = 50;
|
||||
public double SnappingRadius
|
||||
{
|
||||
get
|
||||
{
|
||||
return _snappingRadius;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _snappingRadius, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,5 +25,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
bool EnableSnapping
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
double SnappingRadius
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
protected virtual void Init(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo)
|
||||
{
|
||||
this.Root = sourceConnectorInfo.DataItem.Root;
|
||||
|
||||
|
||||
this.ColorViewModel.FillColor.Color = Colors.Red;
|
||||
if (sinkConnectorInfo is FullyCreatedConnectorInfo sink && sink.DataItem.ShowArrow == false)
|
||||
{
|
||||
@@ -715,10 +715,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
MouseButtonEventArgs mosueArg = ((EventToCommandArgs)parameter).EventArgs as MouseButtonEventArgs;
|
||||
var position = mosueArg.GetPosition(((EventToCommandArgs)parameter).Sender as IInputElement);
|
||||
|
||||
var vertice = new ConnectorVertexModel(this, new PointBase(position.X, position.Y));
|
||||
vertice.PropertyChanged += new WeakINPCEventHandler(ConnectorViewModel_PropertyChanged).Handler;
|
||||
Vertices.Add(vertice);
|
||||
UpdatePathGeneratorResult();
|
||||
AddVertex(position, false);
|
||||
|
||||
if (!((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control))
|
||||
{
|
||||
@@ -726,6 +723,18 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public void AddVertex(PointBase pointBase, bool absolute = true)
|
||||
{
|
||||
if (absolute)
|
||||
{
|
||||
pointBase = new PointBase(pointBase.X - Area.Left, pointBase.Y - Area.Top);
|
||||
}
|
||||
var vertice = new ConnectorVertexModel(this, pointBase);
|
||||
vertice.PropertyChanged += new WeakINPCEventHandler(ConnectorViewModel_PropertyChanged).Handler;
|
||||
Vertices.Add(vertice);
|
||||
UpdatePathGeneratorResult();
|
||||
}
|
||||
|
||||
protected override void ExecuteEditCommand(object param)
|
||||
{
|
||||
AddLabel();
|
||||
|
||||
@@ -364,33 +364,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
SetProperty(ref _cellVerticalAlignment, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _enableSnapping;
|
||||
public bool EnableSnapping
|
||||
{
|
||||
get
|
||||
{
|
||||
return _enableSnapping;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _enableSnapping, value);
|
||||
}
|
||||
}
|
||||
|
||||
private double _snappingRadius = 50;
|
||||
public double SnappingRadius
|
||||
{
|
||||
get
|
||||
{
|
||||
return _snappingRadius;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _snappingRadius, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isEditName;
|
||||
[Browsable(false)]
|
||||
@@ -786,7 +760,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
ClearSelectedItems();
|
||||
Add(ite);
|
||||
}
|
||||
else if (parameter is List<SelectableDesignerItemViewModelBase> items)
|
||||
else if (parameter is IEnumerable<SelectableDesignerItemViewModelBase> items)
|
||||
{
|
||||
if (items.Select(p => AddVerify(p)).Any() != true) return;
|
||||
|
||||
@@ -1714,9 +1688,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
#region 分组
|
||||
private void ExecuteGroupCommand(object parameter)
|
||||
{
|
||||
var items = from item in SelectedItems.OfType<DesignerItemViewModelBase>()
|
||||
where item.ParentId == Guid.Empty
|
||||
select item;
|
||||
List<DesignerItemViewModelBase> items;
|
||||
if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
||||
{
|
||||
items = para.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = SelectedItems.OfType<DesignerItemViewModelBase>().Where(p => p.ParentId == Guid.Empty).ToList();
|
||||
}
|
||||
|
||||
RectangleBase rect = GetBoundingRectangle(items);
|
||||
|
||||
|
||||
@@ -11,10 +11,21 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public GroupDesignerItemViewModel() : base()
|
||||
{
|
||||
this.ClearConnectors();
|
||||
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
this.IsHitTestVisible = false;
|
||||
}
|
||||
|
||||
protected override void InitConnector()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void ExecuteEditCommand(object param)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -228,14 +228,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
bool EnableSnapping
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
double SnappingRadius
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
Size GridMarginSize
|
||||
{
|
||||
get; set;
|
||||
|
||||
Reference in New Issue
Block a user