diff --git a/AIStudio.Wpf.DiagramDesigner.Test/App.xaml b/AIStudio.Wpf.DiagramDesigner.Test/App.xaml
index 79745bd..cf8e9da 100644
--- a/AIStudio.Wpf.DiagramDesigner.Test/App.xaml
+++ b/AIStudio.Wpf.DiagramDesigner.Test/App.xaml
@@ -13,9 +13,7 @@
-
-
-
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Test/MainWindow.xaml b/AIStudio.Wpf.DiagramDesigner.Test/MainWindow.xaml
index 0efb080..83cf1a9 100644
--- a/AIStudio.Wpf.DiagramDesigner.Test/MainWindow.xaml
+++ b/AIStudio.Wpf.DiagramDesigner.Test/MainWindow.xaml
@@ -4,16 +4,15 @@
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"
- xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls;assembly=AIStudio.Wpf.DiagramHelper"
- xmlns:flowchart="clr-namespace:AIStudio.Wpf.Flowchart;assembly=AIStudio.Wpf.Flowchart"
+ xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
xmlns:options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
-
+
+
#FF0078D7
@@ -69,69 +68,77 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
-
-
+
+
-
-
+
-
+
-
-
+ ItemsSource="{Binding Path=DataContext.Roles,RelativeSource={RelativeSource AncestorType={x:Type Window}}}">
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Test/ViewModels/MainWindowViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Test/ViewModels/MainWindowViewModel.cs
index 210419a..52b510b 100644
--- a/AIStudio.Wpf.DiagramDesigner.Test/ViewModels/MainWindowViewModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner.Test/ViewModels/MainWindowViewModel.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Windows;
using AIStudio.Wpf.Flowchart;
+using AIStudio.Wpf.Flowchart.ViewModels;
namespace AIStudio.Wpf.DiagramDesigner.Test.ViewModels
{
diff --git a/AIStudio.Wpf.DiagramDesigner/Styles/DesignerItems.xaml b/AIStudio.Wpf.DiagramDesigner/Styles/DesignerItems.xaml
new file mode 100644
index 0000000..4b9a3b4
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner/Styles/DesignerItems.xaml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner/Styles/Expander.xaml b/AIStudio.Wpf.DiagramDesigner/Styles/Expander.xaml
new file mode 100644
index 0000000..5974bb0
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner/Styles/Expander.xaml
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner/Styles/GroupBox.xaml b/AIStudio.Wpf.DiagramDesigner/Styles/GroupBox.xaml
new file mode 100644
index 0000000..f418927
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner/Styles/GroupBox.xaml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner/Styles/ScrollBar.xaml b/AIStudio.Wpf.DiagramDesigner/Styles/ScrollBar.xaml
new file mode 100644
index 0000000..f81c8a5
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner/Styles/ScrollBar.xaml
@@ -0,0 +1,186 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner/Styles/ScrollViewer.xaml b/AIStudio.Wpf.DiagramDesigner/Styles/ScrollViewer.xaml
new file mode 100644
index 0000000..07fa158
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner/Styles/ScrollViewer.xaml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner/Styles/Shared.xaml b/AIStudio.Wpf.DiagramDesigner/Styles/Shared.xaml
new file mode 100644
index 0000000..fd557d4
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner/Styles/Shared.xaml
@@ -0,0 +1,118 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner/Styles/ToolTip.xaml b/AIStudio.Wpf.DiagramDesigner/Styles/ToolTip.xaml
new file mode 100644
index 0000000..bdc742c
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner/Styles/ToolTip.xaml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner/Styles/ZoomBox.xaml b/AIStudio.Wpf.DiagramDesigner/Styles/ZoomBox.xaml
new file mode 100644
index 0000000..53efc24
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner/Styles/ZoomBox.xaml
@@ -0,0 +1,245 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramHelper/Properties/AssemblyInfo.cs b/AIStudio.Wpf.DiagramHelper/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..0ff8867
--- /dev/null
+++ b/AIStudio.Wpf.DiagramHelper/Properties/AssemblyInfo.cs
@@ -0,0 +1,16 @@
+using System.Windows;
+using System.Windows.Markup;
+
+[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)
+)]
+
+[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.DiagramHelper")]
+[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.DiagramHelper.Controls")]
+
+[assembly: XmlnsPrefix("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "dd")]
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramHelper/Themes/Generic.xaml b/AIStudio.Wpf.DiagramHelper/Themes/Generic.xaml
new file mode 100644
index 0000000..01a6b5d
--- /dev/null
+++ b/AIStudio.Wpf.DiagramHelper/Themes/Generic.xaml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart.csproj b/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart.csproj
index 5e54e3e..050d2fb 100644
--- a/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart.csproj
+++ b/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart.csproj
@@ -12,4 +12,11 @@
+
+
+ $(DefaultXamlRuntime)
+ Designer
+
+
+
diff --git a/AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml b/AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml
new file mode 100644
index 0000000..d745e31
--- /dev/null
+++ b/AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml.cs b/AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml.cs
new file mode 100644
index 0000000..f4da00d
--- /dev/null
+++ b/AIStudio.Wpf.Flowchart/Controls/FlowchartEditor.xaml.cs
@@ -0,0 +1,211 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+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;
+using AIStudio.Wpf.DiagramDesigner;
+using AIStudio.Wpf.Flowchart.Models;
+using AIStudio.Wpf.Flowchart.ViewModels;
+
+namespace AIStudio.Wpf.Flowchart.Controls
+{
+ ///
+ /// FlowchartEditor.xaml 的交互逻辑
+ ///
+ [TemplatePart(Name = PART_DiagramControl, Type = typeof(DiagramControl))]
+ public partial class FlowchartEditor : UserControl
+ {
+ public const string PART_DiagramControl = "PART_DiagramControl";
+ private DiagramControl _diagramControl;
+ private IDiagramServiceProvider _service
+ {
+ get
+ {
+ return DiagramServicesProvider.Instance.Provider;
+ }
+ }
+
+ private DiagramViewModel _diagramViewModel = new DiagramViewModel()
+ {
+ ShowGrid = true,
+ GridCellSize = new Size(100, 60),
+ GridMargin = 0d,
+ CellHorizontalAlignment = CellHorizontalAlignment.Center,
+ CellVerticalAlignment = CellVerticalAlignment.Center,
+ PageSizeType = PageSizeType.Custom,
+ PageSize = new Size(double.NaN, double.NaN),
+ };
+
+ static FlowchartEditor()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(FlowchartEditor), new FrameworkPropertyMetadata(typeof(FlowchartEditor)));
+ }
+
+ public FlowchartEditor()
+ {
+ _diagramViewModel.PropertyChanged += DiagramViewModel_PropertyChanged;
+ }
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ _diagramControl = GetTemplateChild(PART_DiagramControl) as DiagramControl;
+ _diagramControl.HorizontalAlignment = HorizontalAlignment.Stretch;
+ _diagramControl.VerticalAlignment = VerticalAlignment.Stretch;
+ _diagramControl.DataContext = _diagramViewModel;
+ }
+
+ private void DiagramViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == "IsSelected")
+ {
+ SelectedObject = _diagramViewModel.SelectedItems?.FirstOrDefault();
+ }
+ }
+
+ //一点要绑定不为空的FlowchartModel才能用,即便为空的也要new一个再来绑定
+ public static readonly DependencyProperty FlowchartModelProperty =
+ DependencyProperty.Register(nameof(FlowchartModel),
+ typeof(FlowchartModel),
+ typeof(FlowchartEditor),
+ new FrameworkPropertyMetadata(null, OnFlowchartModelChanged));
+
+ public FlowchartModel FlowchartModel
+ {
+ get
+ {
+ return (FlowchartModel)GetValue(FlowchartModelProperty);
+ }
+ set
+ {
+ SetValue(FlowchartModelProperty, value);
+ }
+ }
+ private static void OnFlowchartModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var view = d as FlowchartEditor;
+ var model = e.NewValue as FlowchartModel;
+ if (model != null)
+ {
+ view.CreateFlowchartModel(model);
+ }
+ }
+
+ private void CreateFlowchartModel(FlowchartModel model)
+ {
+ _service.DrawModeViewModel.VectorLineDrawMode = DrawMode.BoundaryConnectingLine;
+ _diagramViewModel.Items.Clear();
+ if (model != null)
+ {
+ foreach (var node in model.Nodes)
+ {
+ _diagramViewModel.DirectAddItemCommand.Execute(node);
+ }
+ foreach (var link in model.Links)
+ {
+ _diagramViewModel.DirectAddItemCommand.Execute(link);
+ }
+ }
+ }
+
+ #region ToolBox
+ ///
+ /// 附加组件模板
+ ///
+ public static readonly DependencyProperty ToolBoxProperty = DependencyProperty.Register(
+ nameof(ToolBox), typeof(ControlTemplate), typeof(FlowchartEditor), new FrameworkPropertyMetadata(default(ControlTemplate)));
+
+ public ControlTemplate ToolBox
+ {
+ get
+ {
+ return (ControlTemplate)GetValue(ToolBoxProperty);
+ }
+ set
+ {
+ SetValue(ToolBoxProperty, value);
+ }
+ }
+ #endregion
+
+ #region ToolBox
+ ///
+ /// 附加组件模板
+ ///
+ public static readonly DependencyProperty PropertiesBoxProperty = DependencyProperty.Register(
+ nameof(PropertiesBox), typeof(ControlTemplate), typeof(FlowchartEditor), new FrameworkPropertyMetadata(default(ControlTemplate)));
+
+ public ControlTemplate PropertiesBox
+ {
+ get
+ {
+ return (ControlTemplate)GetValue(PropertiesBoxProperty);
+ }
+ set
+ {
+ SetValue(PropertiesBoxProperty, value);
+ }
+ }
+ #endregion
+
+ #region SelectedObject
+
+ public static readonly DependencyProperty SelectedObjectProperty = DependencyProperty.Register(nameof(SelectedObject), typeof(object), typeof(FlowchartEditor), new UIPropertyMetadata(default(object)));
+ public object SelectedObject
+ {
+ get
+ {
+ return (object)GetValue(SelectedObjectProperty);
+ }
+ set
+ {
+ SetValue(SelectedObjectProperty, value);
+ }
+ }
+
+ #endregion
+
+ #region Users
+ public static readonly DependencyProperty UsersProperty
+ = DependencyProperty.Register(nameof(Users), typeof(List), typeof(FlowchartEditor), new UIPropertyMetadata(default(List)));
+ public List Users
+ {
+ get
+ {
+ return (List)GetValue(UsersProperty);
+ }
+ set
+ {
+ SetValue(UsersProperty, value);
+ }
+ }
+ #endregion
+
+ #region Roles
+ public static readonly DependencyProperty RolesProperty
+ = DependencyProperty.Register(nameof(Roles), typeof(List), typeof(FlowchartEditor), new UIPropertyMetadata(default(List)));
+ public List Roles
+ {
+ get
+ {
+ return (List)GetValue(RolesProperty);
+ }
+ set
+ {
+ SetValue(RolesProperty, value);
+ }
+ }
+ #endregion
+
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner.Test/ToolBoxControl.xaml b/AIStudio.Wpf.Flowchart/Controls/ToolBoxControl.xaml
similarity index 89%
rename from AIStudio.Wpf.DiagramDesigner.Test/ToolBoxControl.xaml
rename to AIStudio.Wpf.Flowchart/Controls/ToolBoxControl.xaml
index 1e924d2..087d98c 100644
--- a/AIStudio.Wpf.DiagramDesigner.Test/ToolBoxControl.xaml
+++ b/AIStudio.Wpf.Flowchart/Controls/ToolBoxControl.xaml
@@ -1,4 +1,4 @@
-
-
+
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Test/ToolBoxControl.xaml.cs b/AIStudio.Wpf.Flowchart/Controls/ToolBoxControl.xaml.cs
similarity index 81%
rename from AIStudio.Wpf.DiagramDesigner.Test/ToolBoxControl.xaml.cs
rename to AIStudio.Wpf.Flowchart/Controls/ToolBoxControl.xaml.cs
index 5a46b24..f61859b 100644
--- a/AIStudio.Wpf.DiagramDesigner.Test/ToolBoxControl.xaml.cs
+++ b/AIStudio.Wpf.Flowchart/Controls/ToolBoxControl.xaml.cs
@@ -11,8 +11,9 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
+using AIStudio.Wpf.Flowchart.ViewModels;
-namespace AIStudio.Wpf.DiagramDesigner.Test
+namespace AIStudio.Wpf.Flowchart.Controls
{
///
/// Interaction logic for ToolBoxControl.xaml
@@ -22,6 +23,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Test
public ToolBoxControl()
{
InitializeComponent();
+ this.DataContext = new ToolBoxViewModel();
}
}
}
diff --git a/AIStudio.Wpf.Flowchart/Models/FlowchartModel.cs b/AIStudio.Wpf.Flowchart/Models/FlowchartModel.cs
new file mode 100644
index 0000000..4006270
--- /dev/null
+++ b/AIStudio.Wpf.Flowchart/Models/FlowchartModel.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using AIStudio.Wpf.DiagramDesigner;
+using AIStudio.Wpf.Flowchart.ViewModels;
+
+namespace AIStudio.Wpf.Flowchart.Models
+{
+ public class FlowchartModel
+ {
+ private List _nodes = new List();
+ public List Nodes
+ {
+ get
+ {
+ return _nodes;
+ }
+ }
+
+ private List _links = new List();
+ public List Links
+ {
+ get
+ {
+ return _links;
+ }
+ }
+ }
+}
diff --git a/AIStudio.Wpf.Flowchart/Properties/AssemblyInfo.cs b/AIStudio.Wpf.Flowchart/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..3a56467
--- /dev/null
+++ b/AIStudio.Wpf.Flowchart/Properties/AssemblyInfo.cs
@@ -0,0 +1,17 @@
+using System.Windows;
+using System.Windows.Markup;
+
+[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)
+)]
+
+[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.Flowchart")]
+[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.Flowchart.Controls")]
+[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.Flowchart.Controls")]
+
+[assembly: XmlnsPrefix("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "dd")]
\ No newline at end of file
diff --git a/AIStudio.Wpf.Flowchart/ViewModels/FlowNode.xaml b/AIStudio.Wpf.Flowchart/Themes/FlowNode.xaml
similarity index 100%
rename from AIStudio.Wpf.Flowchart/ViewModels/FlowNode.xaml
rename to AIStudio.Wpf.Flowchart/Themes/FlowNode.xaml
diff --git a/AIStudio.Wpf.Flowchart/Themes/Generic.xaml b/AIStudio.Wpf.Flowchart/Themes/Generic.xaml
new file mode 100644
index 0000000..4b4d7ec
--- /dev/null
+++ b/AIStudio.Wpf.Flowchart/Themes/Generic.xaml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner.Test/ViewModels/ToolBoxViewModel.cs b/AIStudio.Wpf.Flowchart/ViewModels/ToolBoxViewModel.cs
similarity index 95%
rename from AIStudio.Wpf.DiagramDesigner.Test/ViewModels/ToolBoxViewModel.cs
rename to AIStudio.Wpf.Flowchart/ViewModels/ToolBoxViewModel.cs
index 2ad525e..3d57bf6 100644
--- a/AIStudio.Wpf.DiagramDesigner.Test/ViewModels/ToolBoxViewModel.cs
+++ b/AIStudio.Wpf.Flowchart/ViewModels/ToolBoxViewModel.cs
@@ -7,7 +7,7 @@ using AIStudio.Wpf.Flowchart;
using AIStudio.Wpf.Flowchart.Models;
using AIStudio.Wpf.Flowchart.ViewModels;
-namespace AIStudio.Wpf.DiagramDesigner.Test.ViewModels
+namespace AIStudio.Wpf.Flowchart.ViewModels
{
public class ToolBoxViewModel
{