diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/AIStudio.Wpf.DiagramDesigner.Demo.csproj b/AIStudio.Wpf.DiagramDesigner.Demo/AIStudio.Wpf.DiagramDesigner.Demo.csproj
index 61cbd25..d8d8023 100644
--- a/AIStudio.Wpf.DiagramDesigner.Demo/AIStudio.Wpf.DiagramDesigner.Demo.csproj
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/AIStudio.Wpf.DiagramDesigner.Demo.csproj
@@ -13,6 +13,7 @@
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/MainWindow.xaml.cs b/AIStudio.Wpf.DiagramDesigner.Demo/MainWindow.xaml.cs
index f85da41..69803c2 100644
--- a/AIStudio.Wpf.DiagramDesigner.Demo/MainWindow.xaml.cs
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/MainWindow.xaml.cs
@@ -124,6 +124,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo
Children=new List
{
new MenuItemViewModel(){Title = "FlowchartEditor"},
+ new MenuItemViewModel(){Title = "MindEditor"},
}
},
};
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/MindEditorViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/MindEditorViewModel.cs
new file mode 100644
index 0000000..9bc8c86
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/MindEditorViewModel.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using AIStudio.Wpf.Flowchart;
+
+namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
+{
+ class MindEditorViewModel : BaseViewModel
+ {
+ public MindEditorViewModel()
+ {
+ Title = "MindEditor";
+ Info = "Encapsulated mind controls";
+
+ GetDataCommand = new SimpleCommand(GetDataExcute);
+ SetDataCommand = new SimpleCommand(SetDataExcute);
+ }
+
+ private Func _getDataFunc;
+ public Func GetDataFunc
+ {
+ get
+ {
+ return _getDataFunc;
+ }
+ set
+ {
+ SetProperty(ref _getDataFunc, value);
+ }
+ }
+
+ private string _inputData;
+ public string InputData
+ {
+ get
+ {
+ return _inputData;
+ }
+ set
+ {
+ SetProperty(ref _inputData, value);
+ }
+ }
+
+ private string _outputData;
+ public string OutputData
+ {
+ get
+ {
+ return _outputData;
+ }
+ set
+ {
+ SetProperty(ref _outputData, value);
+ }
+ }
+
+ private string _data = "{}";
+ public string Data
+ {
+ get
+ {
+ return _data;
+ }
+ set
+ {
+ SetProperty(ref _data, value);
+ }
+ }
+
+
+ public SimpleCommand GetDataCommand
+ {
+ get; private set;
+ }
+
+ public SimpleCommand SetDataCommand
+ {
+ get; private set;
+ }
+
+ private void GetDataExcute(object obj)
+ {
+ OutputData = GetDataFunc();
+ }
+
+ private void SetDataExcute(object obj)
+ {
+ Data = "{}";
+ Data = InputData;
+ }
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/MindEditorView.xaml b/AIStudio.Wpf.DiagramDesigner.Demo/Views/MindEditorView.xaml
new file mode 100644
index 0000000..a103e68
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/MindEditorView.xaml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/MindEditorView.xaml.cs b/AIStudio.Wpf.DiagramDesigner.Demo/Views/MindEditorView.xaml.cs
new file mode 100644
index 0000000..edc8d3c
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/MindEditorView.xaml.cs
@@ -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
+{
+ ///
+ /// MindEditorView.xaml 的交互逻辑
+ ///
+ public partial class MindEditorView : UserControl
+ {
+ public MindEditorView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner/Models/Serializables/DesignerItemBase.cs b/AIStudio.Wpf.DiagramDesigner/Models/Serializables/DesignerItemBase.cs
index b7b46ec..42f5f59 100644
--- a/AIStudio.Wpf.DiagramDesigner/Models/Serializables/DesignerItemBase.cs
+++ b/AIStudio.Wpf.DiagramDesigner/Models/Serializables/DesignerItemBase.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
using System.Windows.Media;
using System.Xml.Serialization;
@@ -32,6 +33,8 @@ namespace AIStudio.Wpf.DiagramDesigner
this.ItemTypeName = viewmodel.GetType().FullName;
this.Margin = viewmodel.Margin;
this.Reserve = reserve;
+ this.CornerRadius = viewmodel.CornerRadius;
+ this.BorderThickness = viewmodel.BorderThickness;
}
[XmlAttribute("Left")]
@@ -102,6 +105,18 @@ namespace AIStudio.Wpf.DiagramDesigner
get; set;
}
+ [XmlAttribute]
+ public CornerRadius CornerRadius
+ {
+ get; set;
+ }
+
+ [XmlAttribute]
+ public Thickness BorderThickness
+ {
+ get; set;
+ }
+
}
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs
index 85ff160..f6db73e 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs
@@ -59,6 +59,8 @@ namespace AIStudio.Wpf.DiagramDesigner
this.PhysicalItemWidth = designer.PhysicalItemWidth;
this.PhysicalItemHeight = designer.PhysicalItemHeight;
this.Icon = designer.Icon;
+ this.CornerRadius = designer.CornerRadius;
+ this.BorderThickness = designer.BorderThickness;
}
}
@@ -473,6 +475,32 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
+ private CornerRadius _cornerRadius = new CornerRadius(3);
+ public CornerRadius CornerRadius
+ {
+ get
+ {
+ return _cornerRadius;
+ }
+ set
+ {
+ SetProperty(ref _cornerRadius, value);
+ }
+ }
+
+ private Thickness _borderThickness = new Thickness(1);
+ public Thickness BorderThickness
+ {
+ get
+ {
+ return _borderThickness;
+ }
+ set
+ {
+ SetProperty(ref _borderThickness, value);
+ }
+ }
+
///
/// 连接点是否可以按偏移自定义
///
diff --git a/AIStudio.Wpf.Mind/AIStudio.Wpf.Mind.csproj b/AIStudio.Wpf.Mind/AIStudio.Wpf.Mind.csproj
index 208a974..857d1c0 100644
--- a/AIStudio.Wpf.Mind/AIStudio.Wpf.Mind.csproj
+++ b/AIStudio.Wpf.Mind/AIStudio.Wpf.Mind.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/AIStudio.Wpf.Mind/Controls/MindEditor.xaml b/AIStudio.Wpf.Mind/Controls/MindEditor.xaml
new file mode 100644
index 0000000..411c984
--- /dev/null
+++ b/AIStudio.Wpf.Mind/Controls/MindEditor.xaml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.Mind/Controls/MindEditor.cs b/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs
similarity index 91%
rename from AIStudio.Wpf.Mind/Controls/MindEditor.cs
rename to AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs
index 560fb55..2bf246d 100644
--- a/AIStudio.Wpf.Mind/Controls/MindEditor.cs
+++ b/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs
@@ -159,6 +159,26 @@ namespace AIStudio.Wpf.Mind.Controls
}
}
+ #region ToolBox
+ ///
+ /// 附加组件模板
+ ///
+ public static readonly DependencyProperty ToolBoxProperty = DependencyProperty.Register(
+ nameof(ToolBox), typeof(ControlTemplate), typeof(MindEditor), new FrameworkPropertyMetadata(default(ControlTemplate)));
+
+ public ControlTemplate ToolBox
+ {
+ get
+ {
+ return (ControlTemplate)GetValue(ToolBoxProperty);
+ }
+ set
+ {
+ SetValue(ToolBoxProperty, value);
+ }
+ }
+ #endregion
+
#region SelectedObject
public static readonly DependencyProperty SelectedObjectProperty = DependencyProperty.Register(nameof(SelectedObject), typeof(object), typeof(MindEditor), new UIPropertyMetadata(default(object)));
diff --git a/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml b/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml
new file mode 100644
index 0000000..1ea180e
--- /dev/null
+++ b/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml.cs b/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml.cs
new file mode 100644
index 0000000..135fc67
--- /dev/null
+++ b/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml.cs
@@ -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.Mind.Controls
+{
+ ///
+ /// ToolBoxControl.xaml 的交互逻辑
+ ///
+ public partial class ToolBoxControl : UserControl
+ {
+ public ToolBoxControl()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/AIStudio.Wpf.Mind/Models/MindNodeDesignerItem.cs b/AIStudio.Wpf.Mind/Models/MindNodeDesignerItem.cs
new file mode 100644
index 0000000..bf5f273
--- /dev/null
+++ b/AIStudio.Wpf.Mind/Models/MindNodeDesignerItem.cs
@@ -0,0 +1,84 @@
+using System.Windows;
+using System.Xml.Serialization;
+using AIStudio.Wpf.DiagramDesigner;
+using AIStudio.Wpf.Mind.ViewModels;
+using Newtonsoft.Json;
+
+namespace AIStudio.Wpf.Mind.Models
+{
+ public class MindNodeDesignerItem : DesignerItemBase
+ {
+ public MindNodeDesignerItem()
+ {
+
+ }
+ public MindNodeDesignerItem(MindNode item) : base(item)
+ {
+ NodeLevel = item.NodeLevel;
+ MindType = item.MindType;
+ Spacing = item.Spacing;
+ Offset = item.Offset;
+ IsExpanded = item.IsExpanded;
+ }
+
+
+ [XmlAttribute]
+ public NodeLevel NodeLevel
+ {
+ get; set;
+ }
+
+ [XmlAttribute]
+ public MindType MindType
+ {
+ get; set;
+ }
+
+ [XmlIgnore]
+ public Size Spacing
+ {
+ get; set;
+ }
+
+ [JsonIgnore]
+ [XmlAttribute("Spacing")]
+ public string XmlSpacing
+ {
+ get
+ {
+ return SerializeHelper.SerializeSize(Spacing);
+ }
+ set
+ {
+ Spacing = SerializeHelper.DeserializeSize(value);
+ }
+ }
+
+
+ [XmlIgnore]
+ public Point Offset
+ {
+ get; set;
+ }
+
+ [JsonIgnore]
+ [XmlAttribute("Offset")]
+ public string XmlOffset
+ {
+ get
+ {
+ return SerializeHelper.SerializePoint(Offset);
+ }
+ set
+ {
+ Offset = SerializeHelper.DeserializePoint(value);
+ }
+ }
+
+ [XmlAttribute]
+ public bool IsExpanded
+ {
+ get; set;
+ }
+ }
+}
diff --git a/AIStudio.Wpf.Mind/Models/MindNodeModel.cs b/AIStudio.Wpf.Mind/Models/MindNodeModel.cs
new file mode 100644
index 0000000..2f44ff7
--- /dev/null
+++ b/AIStudio.Wpf.Mind/Models/MindNodeModel.cs
@@ -0,0 +1,51 @@
+using System.Windows;
+using AIStudio.Wpf.DiagramModels;
+using AIStudio.Wpf.DiagramModels.ViewModels;
+using AIStudio.Wpf.Mind;
+using AIStudio.Wpf.Mind.ViewModels;
+
+namespace AIStudio.Wpf.Flowchart.Models
+{
+
+ public class MindNodeModel : DiagramNode
+ {
+ public NodeLevel NodeLevel
+ {
+ get; set;
+ }
+
+ public MindType MindType
+ {
+ get; set;
+ }
+
+ public Size Spacing
+ {
+ get; set;
+ }
+
+
+ public Point Offset
+ {
+ get; set;
+ }
+
+ public bool IsExpanded
+ {
+ get; set;
+ }
+
+ public override DiagramItemViewModel ToNodel()
+ {
+ MindNode mindNode = new MindNode(NodeLevel, MindType);
+
+ mindNode.Spacing = Spacing;
+ mindNode.Offset = Offset;
+ mindNode.IsExpanded = IsExpanded;
+
+ return mindNode;
+ }
+
+
+ }
+}
diff --git a/AIStudio.Wpf.Mind/Properties/AssemblyInfo.cs b/AIStudio.Wpf.Mind/Properties/AssemblyInfo.cs
index 8b5504e..c26bed4 100644
--- a/AIStudio.Wpf.Mind/Properties/AssemblyInfo.cs
+++ b/AIStudio.Wpf.Mind/Properties/AssemblyInfo.cs
@@ -1,4 +1,5 @@
using System.Windows;
+using System.Windows.Markup;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
@@ -8,3 +9,9 @@ using System.Windows;
//(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.Mind")]
+[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.Mind.Controls")]
+[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.Mind.Controls")]
+
+[assembly: XmlnsPrefix("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "dd")]
diff --git a/AIStudio.Wpf.Mind/Themes/Generic.xaml b/AIStudio.Wpf.Mind/Themes/Generic.xaml
index 1e2dd45..0255b79 100644
--- a/AIStudio.Wpf.Mind/Themes/Generic.xaml
+++ b/AIStudio.Wpf.Mind/Themes/Generic.xaml
@@ -2,7 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
-
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.Mind/ViewModels/MindNode.cs b/AIStudio.Wpf.Mind/ViewModels/MindNode.cs
index bdffda8..037c707 100644
--- a/AIStudio.Wpf.Mind/ViewModels/MindNode.cs
+++ b/AIStudio.Wpf.Mind/ViewModels/MindNode.cs
@@ -8,16 +8,21 @@ using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
+using System.Xml.Linq;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.DiagramDesigner.Algorithms;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
using AIStudio.Wpf.DiagramDesigner.Helpers;
using AIStudio.Wpf.DiagramDesigner.Models;
+using AIStudio.Wpf.DiagramModels;
+using AIStudio.Wpf.DiagramModels.ViewModels;
+using AIStudio.Wpf.Flowchart.Models;
using AIStudio.Wpf.Mind.Helpers;
+using AIStudio.Wpf.Mind.Models;
namespace AIStudio.Wpf.Mind.ViewModels
{
- public class MindNode : DesignerItemViewModelBase
+ public class MindNode : DiagramItemViewModel
{
public MindNode(NodeLevel nodeLevel, MindType mindType = MindType.Mind) : this(null, nodeLevel, mindType)
{
@@ -42,6 +47,11 @@ namespace AIStudio.Wpf.Mind.ViewModels
InitLayout();
}
+ public override SelectableItemBase GetSerializableObject()
+ {
+ return new MindNodeDesignerItem(this);
+ }
+
protected override void Init(IDiagramViewModel root)
{
base.Init(root);
@@ -65,6 +75,35 @@ namespace AIStudio.Wpf.Mind.ViewModels
MindLayout = layout != null ? (System.Activator.CreateInstance(layout) as IMindLayout) : new MindLayout();
}
+ protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
+ {
+ base.LoadDesignerItemViewModel(designerbase);
+
+ if (designerbase is MindNodeDesignerItem designer)
+ {
+ NodeLevel = designer.NodeLevel;
+ MindType = designer.MindType;
+ Spacing = designer.Spacing;
+ Offset = designer.Offset;
+ IsExpanded = designer.IsExpanded;
+ }
+ }
+
+ public override DiagramNode ToDiagram()
+ {
+ var mindNodeModel = new MindNodeModel();
+
+ mindNodeModel.NodeLevel = NodeLevel;
+ mindNodeModel.MindType = MindType;
+ mindNodeModel.Spacing = Spacing;
+ mindNodeModel.Offset = Offset;
+ mindNodeModel.IsExpanded = IsExpanded;
+
+ return mindNodeModel;
+ }
+
+
+
private bool Level_Enable(object obj)
{
@@ -103,33 +142,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
SetProperty(ref _mindType, value);
}
- }
-
- private CornerRadius _cornerRadius = new CornerRadius(3);
- public CornerRadius CornerRadius
- {
- get
- {
- return _cornerRadius;
- }
- set
- {
- SetProperty(ref _cornerRadius, value);
- }
- }
-
- private Thickness _borderThickness = new Thickness(1);
- public Thickness BorderThickness
- {
- get
- {
- return _borderThickness;
- }
- set
- {
- SetProperty(ref _borderThickness, value);
- }
- }
+ }
private bool _isExpanded = true;
public bool IsExpanded