mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-05-04 15:01:29 +08:00
分离出一个小demo
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 17.3.32922.545
|
VisualStudioVersion = 16.0.31727.386
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.Flowchart", "AIStudio.Wpf.Flowchart\AIStudio.Wpf.Flowchart.csproj", "{86ED5B40-D185-4AFA-B5BD-BC8E78DB8758}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.Flowchart", "AIStudio.Wpf.Flowchart\AIStudio.Wpf.Flowchart.csproj", "{86ED5B40-D185-4AFA-B5BD-BC8E78DB8758}"
|
||||||
EndProject
|
EndProject
|
||||||
@@ -23,6 +23,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决
|
|||||||
Directory.Build.Props = Directory.Build.Props
|
Directory.Build.Props = Directory.Build.Props
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AIStudio.Wpf.DiagramDesigner.Test", "AIStudio.Wpf.DiagramDesigner.Test\AIStudio.Wpf.DiagramDesigner.Test.csproj", "{559BBB2C-03DE-4C95-B38F-538F0A275793}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -53,6 +55,10 @@ Global
|
|||||||
{1E77B64D-B457-4467-A5DB-BB7BA01806D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1E77B64D-B457-4467-A5DB-BB7BA01806D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1E77B64D-B457-4467-A5DB-BB7BA01806D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1E77B64D-B457-4467-A5DB-BB7BA01806D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1E77B64D-B457-4467-A5DB-BB7BA01806D9}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1E77B64D-B457-4467-A5DB-BB7BA01806D9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{559BBB2C-03DE-4C95-B38F-538F0A275793}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{559BBB2C-03DE-4C95-B38F-538F0A275793}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{559BBB2C-03DE-4C95-B38F-538F0A275793}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{559BBB2C-03DE-4C95-B38F-538F0A275793}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -42,29 +42,6 @@ namespace AIStudio.Wpf.DiagramApp.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FlowchartToolBoxData : ToolBoxData
|
|
||||||
{
|
|
||||||
public NodeKinds Kind { get; set; }
|
|
||||||
public FlowchartToolBoxData(NodeKinds kind, Type type, double width = 32, double height = 32) : base(kind.GetDescription(), null, type, width, height)
|
|
||||||
{
|
|
||||||
Kind = kind;
|
|
||||||
ColorViewModel.LineColor.Color = Colors.Black;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SFCToolBoxData : ToolBoxData
|
|
||||||
{
|
|
||||||
public SFCNodeKinds Kind { get; set; }
|
|
||||||
public SFCToolBoxData(SFCNodeKinds kind, Type type, double width = 32, double height = 32) : base(null, null, type, width, height)
|
|
||||||
{
|
|
||||||
Kind = kind;
|
|
||||||
ColorViewModel.LineColor.Color = Colors.Gray;
|
|
||||||
ColorViewModel.FillColor.Color = Colors.Blue;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DesignerItemToolBoxData : ToolBoxData
|
public class DesignerItemToolBoxData : ToolBoxData
|
||||||
{
|
{
|
||||||
public string FileName { get; set; }
|
public string FileName { get; set; }
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ using AIStudio.Wpf.DiagramDesigner.Helpers;
|
|||||||
using AIStudio.Wpf.SFC;
|
using AIStudio.Wpf.SFC;
|
||||||
using AIStudio.Wpf.SFC.ViewModels;
|
using AIStudio.Wpf.SFC.ViewModels;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using AIStudio.Wpf.Flowchart.Models;
|
||||||
|
using AIStudio.Wpf.SFC.Models;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramApp.ViewModels
|
namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz"
|
xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz"
|
||||||
xmlns:helper="clr-namespace:AIStudio.Wpf.DiagramHelper.Helpers;assembly=AIStudio.Wpf.DiagramHelper"
|
xmlns:helper="clr-namespace:AIStudio.Wpf.DiagramHelper.Helpers;assembly=AIStudio.Wpf.DiagramHelper"
|
||||||
xmlns:model="clr-namespace:AIStudio.Wpf.DiagramApp.Models"
|
xmlns:model="clr-namespace:AIStudio.Wpf.DiagramApp.Models"
|
||||||
xmlns:dd="https://astudio.github.io/diagram"
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||||
xmlns:drop="urn:gong-wpf-dragdrop"
|
xmlns:drop="urn:gong-wpf-dragdrop"
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters;assembly=AIStudio.Wpf.DiagramHelper"
|
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters;assembly=AIStudio.Wpf.DiagramHelper"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
xmlns:views="clr-namespace:AIStudio.Wpf.DiagramApp.Views"
|
xmlns:views="clr-namespace:AIStudio.Wpf.DiagramApp.Views"
|
||||||
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters;assembly=AIStudio.Wpf.DiagramHelper"
|
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters;assembly=AIStudio.Wpf.DiagramHelper"
|
||||||
xmlns:helper="clr-namespace:AIStudio.Wpf.DiagramHelper.Helpers;assembly=AIStudio.Wpf.DiagramHelper"
|
xmlns:helper="clr-namespace:AIStudio.Wpf.DiagramHelper.Helpers;assembly=AIStudio.Wpf.DiagramHelper"
|
||||||
xmlns:dd="https://astudio.github.io/diagram"
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||||
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
||||||
xmlns:flowchart="clr-namespace:AIStudio.Wpf.Flowchart;assembly=AIStudio.Wpf.Flowchart"
|
xmlns:flowchart="clr-namespace:AIStudio.Wpf.Flowchart;assembly=AIStudio.Wpf.Flowchart"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
|
|||||||
@@ -6,7 +6,9 @@
|
|||||||
xmlns:views="clr-namespace:AIStudio.Wpf.DiagramApp.Views"
|
xmlns:views="clr-namespace:AIStudio.Wpf.DiagramApp.Views"
|
||||||
xmlns:viewmodels="clr-namespace:AIStudio.Wpf.DiagramApp.ViewModels"
|
xmlns:viewmodels="clr-namespace:AIStudio.Wpf.DiagramApp.ViewModels"
|
||||||
xmlns:model="clr-namespace:AIStudio.Wpf.DiagramApp.Models"
|
xmlns:model="clr-namespace:AIStudio.Wpf.DiagramApp.Models"
|
||||||
xmlns:dd="https://astudio.github.io/diagram"
|
xmlns:flowchartmodel="clr-namespace:AIStudio.Wpf.Flowchart.Models;assembly=AIStudio.Wpf.Flowchart"
|
||||||
|
xmlns:sfcmodel="clr-namespace:AIStudio.Wpf.SFC.Models;assembly=AIStudio.Wpf.SFC"
|
||||||
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||||
xmlns:conventer="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters;assembly=AIStudio.Wpf.DiagramHelper"
|
xmlns:conventer="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters;assembly=AIStudio.Wpf.DiagramHelper"
|
||||||
xmlns:command="clr-namespace:AIStudio.Wpf.DiagramHelper.Commands;assembly=AIStudio.Wpf.DiagramHelper"
|
xmlns:command="clr-namespace:AIStudio.Wpf.DiagramHelper.Commands;assembly=AIStudio.Wpf.DiagramHelper"
|
||||||
xmlns:svg="clr-namespace:Svg2XamlTestExtension;assembly=Svg2XamlTestExtension"
|
xmlns:svg="clr-namespace:Svg2XamlTestExtension;assembly=Svg2XamlTestExtension"
|
||||||
@@ -19,7 +21,7 @@
|
|||||||
<dd:EnumDescriptionConverter x:Key="EnumDescriptionConverter"/>
|
<dd:EnumDescriptionConverter x:Key="EnumDescriptionConverter"/>
|
||||||
<command:CommandReference x:Key="DeleteItemCommandReference" Command="{Binding DeleteItemCommand}"/>
|
<command:CommandReference x:Key="DeleteItemCommandReference" Command="{Binding DeleteItemCommand}"/>
|
||||||
|
|
||||||
|
|
||||||
<DataTemplate DataType="{x:Type model:ImageToolBoxData}">
|
<DataTemplate DataType="{x:Type model:ImageToolBoxData}">
|
||||||
<Grid Width="{Binding Width}" Height="{Binding Height}">
|
<Grid Width="{Binding Width}" Height="{Binding Height}">
|
||||||
<Rectangle Name="Border"
|
<Rectangle Name="Border"
|
||||||
@@ -159,19 +161,17 @@
|
|||||||
</Trigger>
|
</Trigger>
|
||||||
</DataTemplate.Triggers>
|
</DataTemplate.Triggers>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<DataTemplate DataType="{x:Type model:FlowchartToolBoxData}">
|
<DataTemplate DataType="{x:Type flowchartmodel:FlowchartToolBoxData}">
|
||||||
<Grid Width="{Binding Width}" Height="{Binding Height}">
|
<Grid Width="{Binding Width}" Height="{Binding Height}">
|
||||||
<Rectangle Name="Border"
|
<Rectangle Name="Border"
|
||||||
StrokeThickness="1"
|
StrokeThickness="1"
|
||||||
StrokeDashArray="2"
|
StrokeDashArray="2"
|
||||||
Fill="Transparent"
|
Fill="Transparent"
|
||||||
SnapsToDevicePixels="true"/>
|
SnapsToDevicePixels="true"/>
|
||||||
<Viewbox Stretch="Fill">
|
<Grid IsHitTestVisible="False">
|
||||||
<Grid IsHitTestVisible="False">
|
<ContentControl Style="{StaticResource CustomFlowNodeStyle}" Margin="2"/>
|
||||||
<ContentControl Style="{StaticResource CustomFlowNodeStyle}" Margin="2"/>
|
<TextBlock Text="{Binding Text}" Margin="5" TextWrapping="WrapWithOverflow" FontSize="9" Foreground="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
<TextBlock Text="{Binding Text}" Margin="5" Foreground="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" HorizontalAlignment="Left" />
|
</Grid>
|
||||||
</Grid>
|
|
||||||
</Viewbox>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
<DataTemplate.Triggers>
|
<DataTemplate.Triggers>
|
||||||
<Trigger Property="IsMouseOver" Value="true">
|
<Trigger Property="IsMouseOver" Value="true">
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
</Trigger>
|
</Trigger>
|
||||||
</DataTemplate.Triggers>
|
</DataTemplate.Triggers>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<DataTemplate DataType="{x:Type model:SFCToolBoxData}">
|
<DataTemplate DataType="{x:Type sfcmodel:SFCToolBoxData}">
|
||||||
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Kind,Converter={StaticResource EnumDescriptionConverter}}">
|
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Kind,Converter={StaticResource EnumDescriptionConverter}}">
|
||||||
<Rectangle Name="Border"
|
<Rectangle Name="Border"
|
||||||
StrokeThickness="1"
|
StrokeThickness="1"
|
||||||
@@ -187,7 +187,7 @@
|
|||||||
Fill="Transparent"
|
Fill="Transparent"
|
||||||
SnapsToDevicePixels="true"/>
|
SnapsToDevicePixels="true"/>
|
||||||
<Grid IsHitTestVisible="False">
|
<Grid IsHitTestVisible="False">
|
||||||
<ContentControl Style="{StaticResource CustomSFCNodeStyle}" Margin="2" />
|
<ContentControl Style="{StaticResource CustomSFCNodeStyle}" Margin="2" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<DataTemplate.Triggers>
|
<DataTemplate.Triggers>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\AIStudio.Wpf.DiagramDesigner\AIStudio.Wpf.DiagramDesigner.csproj" />
|
||||||
|
<ProjectReference Include="..\AIStudio.Wpf.DiagramHelper\AIStudio.Wpf.DiagramHelper.csproj" />
|
||||||
|
<ProjectReference Include="..\AIStudio.Wpf.Flowchart\AIStudio.Wpf.Flowchart.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
21
AIStudio.Wpf.DiagramDesigner.Test/App.xaml
Normal file
21
AIStudio.Wpf.DiagramDesigner.Test/App.xaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<Application x:Class="AIStudio.Wpf.DiagramDesigner.Test.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:AIStudio.Wpf.DiagramDesigner.Test"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Resources/Styles/ScrollBar.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Resources/Styles/Expander.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Resources/Styles/GroupBox.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Resources/Styles/ToolTip.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Resources/Styles/ScrollViewer.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Resources/Styles/ZoomBox.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Resources/Styles/DesignerItems.xaml" />
|
||||||
|
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/ViewModels/FlowNode.xaml"/>
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
||||||
17
AIStudio.Wpf.DiagramDesigner.Test/App.xaml.cs
Normal file
17
AIStudio.Wpf.DiagramDesigner.Test/App.xaml.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.DiagramDesigner.Test
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
10
AIStudio.Wpf.DiagramDesigner.Test/AssemblyInfo.cs
Normal file
10
AIStudio.Wpf.DiagramDesigner.Test/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
||||||
36
AIStudio.Wpf.DiagramDesigner.Test/MainWindow.xaml
Normal file
36
AIStudio.Wpf.DiagramDesigner.Test/MainWindow.xaml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<Window x:Class="AIStudio.Wpf.DiagramDesigner.Test.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.Test"
|
||||||
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="MainWindow" Height="450" Width="800">
|
||||||
|
<Window.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/ViewModels/FlowNode.xaml"/>
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</Window.Resources>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<!-- ToolBox Control -->
|
||||||
|
<local:ToolBoxControl Grid.Column="0" DataContext="{Binding ToolBoxViewModel}" />
|
||||||
|
|
||||||
|
<GridSplitter Grid.Column="1"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Background="Transparent"
|
||||||
|
Width="3" />
|
||||||
|
|
||||||
|
<!-- Diagram Control -->
|
||||||
|
<dd:DiagramControl Grid.Column="1" x:Name="diagram" DataContext="{Binding DiagramViewModel}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
30
AIStudio.Wpf.DiagramDesigner.Test/MainWindow.xaml.cs
Normal file
30
AIStudio.Wpf.DiagramDesigner.Test/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
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;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner.Test.ViewModels;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.DiagramDesigner.Test
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.DataContext = new MainWindowViewModel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
66
AIStudio.Wpf.DiagramDesigner.Test/ToolBoxControl.xaml
Normal file
66
AIStudio.Wpf.DiagramDesigner.Test/ToolBoxControl.xaml
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Test.ToolBoxControl"
|
||||||
|
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"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="300" d:DesignWidth="300">
|
||||||
|
|
||||||
|
<Border BorderBrush="LightGray" BorderThickness="1">
|
||||||
|
<ItemsControl ItemsSource="{Binding ToolBoxItems}">
|
||||||
|
<ItemsControl.Template>
|
||||||
|
<ControlTemplate TargetType="{x:Type ItemsControl}">
|
||||||
|
<Border BorderThickness="{TemplateBinding Border.BorderThickness}"
|
||||||
|
Padding="{TemplateBinding Control.Padding}"
|
||||||
|
BorderBrush="{TemplateBinding Border.BorderBrush}"
|
||||||
|
Background="{TemplateBinding Panel.Background}"
|
||||||
|
SnapsToDevicePixels="True">
|
||||||
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||||
|
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</ItemsControl.Template>
|
||||||
|
<ItemsControl.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<StackPanel/>
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ItemsControl.ItemsPanel>
|
||||||
|
<ItemsControl.ItemContainerStyle>
|
||||||
|
<Style TargetType="{x:Type ContentPresenter}">
|
||||||
|
<Setter Property="Control.Padding"
|
||||||
|
Value="10" />
|
||||||
|
<Setter Property="ContentControl.HorizontalContentAlignment"
|
||||||
|
Value="Stretch" />
|
||||||
|
<Setter Property="ContentControl.VerticalContentAlignment"
|
||||||
|
Value="Stretch" />
|
||||||
|
<Setter Property="ToolTip"
|
||||||
|
Value="{Binding ToolTip}" />
|
||||||
|
<Setter Property="dd:DragAndDropProps.EnabledForDrag"
|
||||||
|
Value="True" />
|
||||||
|
</Style>
|
||||||
|
</ItemsControl.ItemContainerStyle>
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Grid Margin="10" Width="{Binding Width}" Height="{Binding Height}">
|
||||||
|
<Rectangle Name="Border"
|
||||||
|
StrokeThickness="1"
|
||||||
|
StrokeDashArray="2"
|
||||||
|
Fill="Transparent"
|
||||||
|
SnapsToDevicePixels="true"/>
|
||||||
|
<Grid IsHitTestVisible="False">
|
||||||
|
<ContentControl Style="{StaticResource CustomFlowNodeStyle}" Margin="2"/>
|
||||||
|
<TextBlock Text="{Binding Text}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
<DataTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="true">
|
||||||
|
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
|
||||||
|
</Trigger>
|
||||||
|
</DataTemplate.Triggers>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</Border>
|
||||||
|
</UserControl>
|
||||||
27
AIStudio.Wpf.DiagramDesigner.Test/ToolBoxControl.xaml.cs
Normal file
27
AIStudio.Wpf.DiagramDesigner.Test/ToolBoxControl.xaml.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
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.Test
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for ToolBoxControl.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class ToolBoxControl : UserControl
|
||||||
|
{
|
||||||
|
public ToolBoxControl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.DiagramDesigner.Test.ViewModels
|
||||||
|
{
|
||||||
|
class MainWindowViewModel : BindableBase
|
||||||
|
{
|
||||||
|
public ToolBoxViewModel ToolBoxViewModel
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DiagramViewModel DiagramViewModel
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IDiagramServiceProvider _service
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return DiagramServicesProvider.Instance.Provider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MainWindowViewModel()
|
||||||
|
{
|
||||||
|
ToolBoxViewModel = new ToolBoxViewModel();
|
||||||
|
DiagramViewModel = new DiagramViewModel();
|
||||||
|
DiagramViewModel.ShowGrid = true;
|
||||||
|
DiagramViewModel.GridCellSize = new Size(100, 60);
|
||||||
|
DiagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
|
||||||
|
DiagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
|
||||||
|
DiagramViewModel.PageSizeType = PageSizeType.Custom;
|
||||||
|
DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
|
||||||
|
|
||||||
|
ConnectorViewModel.PathFinder = new OrthogonalPathFinder();
|
||||||
|
_service.DrawModeViewModel.VectorLineDrawMode = DrawMode.BoundaryConnectingLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
||||||
|
using AIStudio.Wpf.Flowchart;
|
||||||
|
using AIStudio.Wpf.Flowchart.Models;
|
||||||
|
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.DiagramDesigner.Test.ViewModels
|
||||||
|
{
|
||||||
|
public class ToolBoxViewModel
|
||||||
|
{
|
||||||
|
private List<ToolBoxData> toolBoxItems = new List<ToolBoxData>();
|
||||||
|
|
||||||
|
public ToolBoxViewModel()
|
||||||
|
{
|
||||||
|
toolBoxItems.Add(new FlowchartToolBoxData(NodeKinds.Start, typeof(StartFlowNode), 80, 48));
|
||||||
|
toolBoxItems.Add(new FlowchartToolBoxData(NodeKinds.End, typeof(EndFlowNode), 80, 48));
|
||||||
|
toolBoxItems.Add(new FlowchartToolBoxData(NodeKinds.Middle, typeof(MiddleFlowNode), 80, 48));
|
||||||
|
toolBoxItems.Add(new FlowchartToolBoxData(NodeKinds.Decide, typeof(DecideFlowNode), 80, 48));
|
||||||
|
toolBoxItems.Add(new FlowchartToolBoxData(NodeKinds.COBegin, typeof(COBeginFlowNode), 48, 48));
|
||||||
|
toolBoxItems.Add(new FlowchartToolBoxData(NodeKinds.COEnd, typeof(COEndFlowNode), 80, 48));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ToolBoxData> ToolBoxItems
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return toolBoxItems;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ using System.Windows.Markup;
|
|||||||
// app, or any theme specific resource dictionaries)
|
// app, or any theme specific resource dictionaries)
|
||||||
)]
|
)]
|
||||||
|
|
||||||
[assembly: XmlnsDefinition("https://astudio.github.io/diagram", "AIStudio.Wpf.DiagramDesigner")]
|
[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.DiagramDesigner")]
|
||||||
[assembly: XmlnsDefinition("https://astudio.github.io/diagram", "AIStudio.Wpf.DiagramDesigner.Controls")]
|
[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.DiagramDesigner.Controls")]
|
||||||
|
|
||||||
[assembly: XmlnsPrefix("https://astudio.github.io/diagram", "dd")]
|
[assembly: XmlnsPrefix("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "dd")]
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
xmlns:Fluent="urn:fluent-ribbon"
|
xmlns:Fluent="urn:fluent-ribbon"
|
||||||
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters"
|
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters"
|
||||||
xmlns:helper="clr-namespace:AIStudio.Wpf.DiagramHelper.Helpers"
|
xmlns:helper="clr-namespace:AIStudio.Wpf.DiagramHelper.Helpers"
|
||||||
xmlns:dd="https://astudio.github.io/diagram"
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||||
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||||
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters"
|
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters"
|
||||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls"
|
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls"
|
||||||
xmlns:dd="https://astudio.github.io/diagram"
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||||
xmlns:Fluent="urn:fluent-ribbon"
|
xmlns:Fluent="urn:fluent-ribbon"
|
||||||
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner;assembly=AIStudio.Wpf.DiagramDesigner"
|
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner;assembly=AIStudio.Wpf.DiagramDesigner"
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||||
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters"
|
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters"
|
||||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls"
|
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls"
|
||||||
xmlns:dd="https://astudio.github.io/diagram"
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||||
xmlns:Fluent="urn:fluent-ribbon"
|
xmlns:Fluent="urn:fluent-ribbon"
|
||||||
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner;assembly=AIStudio.Wpf.DiagramDesigner"
|
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner;assembly=AIStudio.Wpf.DiagramDesigner"
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||||
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters"
|
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters"
|
||||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls"
|
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls"
|
||||||
xmlns:dd="https://astudio.github.io/diagram"
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||||
xmlns:Fluent="urn:fluent-ribbon"
|
xmlns:Fluent="urn:fluent-ribbon"
|
||||||
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner;assembly=AIStudio.Wpf.DiagramDesigner"
|
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner;assembly=AIStudio.Wpf.DiagramDesigner"
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||||
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters"
|
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters"
|
||||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls"
|
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls"
|
||||||
xmlns:dd="https://astudio.github.io/diagram"
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||||
xmlns:Fluent="urn:fluent-ribbon"
|
xmlns:Fluent="urn:fluent-ribbon"
|
||||||
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner;assembly=AIStudio.Wpf.DiagramDesigner"
|
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner;assembly=AIStudio.Wpf.DiagramDesigner"
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
||||||
|
|||||||
24
AIStudio.Wpf.Flowchart/Models/FlowchartToolBoxData.cs
Normal file
24
AIStudio.Wpf.Flowchart/Models/FlowchartToolBoxData.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.Flowchart.Models
|
||||||
|
{
|
||||||
|
public class FlowchartToolBoxData : ToolBoxData
|
||||||
|
{
|
||||||
|
public NodeKinds Kind
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlowchartToolBoxData(NodeKinds kind, Type type, double width = 32, double height = 32) : base(kind.GetDescription(), null, type, width, height)
|
||||||
|
{
|
||||||
|
Kind = kind;
|
||||||
|
ColorViewModel.LineColor.Color = Colors.Black;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||||
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters;assembly=AIStudio.Wpf.DiagramHelper"
|
xmlns:converter="clr-namespace:AIStudio.Wpf.DiagramHelper.Converters;assembly=AIStudio.Wpf.DiagramHelper"
|
||||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls;assembly=AIStudio.Wpf.DiagramHelper"
|
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls;assembly=AIStudio.Wpf.DiagramHelper"
|
||||||
xmlns:dd="https://astudio.github.io/diagram"
|
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||||
xmlns:Fluent="urn:fluent-ribbon"
|
xmlns:Fluent="urn:fluent-ribbon"
|
||||||
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner;assembly=AIStudio.Wpf.DiagramDesigner"
|
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner;assembly=AIStudio.Wpf.DiagramDesigner"
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors">
|
||||||
|
|||||||
21
AIStudio.Wpf.SFC/Models/SFCToolBoxData.cs
Normal file
21
AIStudio.Wpf.SFC/Models/SFCToolBoxData.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.SFC.Models
|
||||||
|
{
|
||||||
|
public class SFCToolBoxData : ToolBoxData
|
||||||
|
{
|
||||||
|
public SFCNodeKinds Kind
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
public SFCToolBoxData(SFCNodeKinds kind, Type type, double width = 32, double height = 32) : base(null, null, type, width, height)
|
||||||
|
{
|
||||||
|
Kind = kind;
|
||||||
|
ColorViewModel.LineColor.Color = Colors.Gray;
|
||||||
|
ColorViewModel.FillColor.Color = Colors.Blue;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user