diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/FlowchartViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/FlowchartViewModel.cs
index adaca4f..7e69a8d 100644
--- a/AIStudio.Wpf.DiagramApp/ViewModels/FlowchartViewModel.cs
+++ b/AIStudio.Wpf.DiagramApp/ViewModels/FlowchartViewModel.cs
@@ -17,7 +17,7 @@ namespace AIStudio.Wpf.Flowchart
{
public FlowchartViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
-
+ Init();
}
public FlowchartViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/LogicalViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/LogicalViewModel.cs
index bc2df8d..1d644de 100644
--- a/AIStudio.Wpf.DiagramApp/ViewModels/LogicalViewModel.cs
+++ b/AIStudio.Wpf.DiagramApp/ViewModels/LogicalViewModel.cs
@@ -13,7 +13,7 @@ namespace AIStudio.Wpf.Logical
{
public LogicalViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
-
+ Init();
}
public LogicalViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/MindViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/MindViewModel.cs
index 48ec2f7..59ca897 100644
--- a/AIStudio.Wpf.DiagramApp/ViewModels/MindViewModel.cs
+++ b/AIStudio.Wpf.DiagramApp/ViewModels/MindViewModel.cs
@@ -23,6 +23,7 @@ namespace AIStudio.Wpf.Flowchart
public MindViewModel(string title, string status, DiagramType diagramType, MindType mindType) : base(title, status, diagramType)
{
MindType = mindType;
+ Init();
}
public MindViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/PageViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/PageViewModel.cs
index 7070705..9a493ea 100644
--- a/AIStudio.Wpf.DiagramApp/ViewModels/PageViewModel.cs
+++ b/AIStudio.Wpf.DiagramApp/ViewModels/PageViewModel.cs
@@ -32,8 +32,6 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
Title = title;
Status = status;
DiagramType = diagramType;
-
- Init();
}
public PageViewModel(string filename)
{
diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/SFCViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/SFCViewModel.cs
index ca15767..1ada18a 100644
--- a/AIStudio.Wpf.DiagramApp/ViewModels/SFCViewModel.cs
+++ b/AIStudio.Wpf.DiagramApp/ViewModels/SFCViewModel.cs
@@ -20,8 +20,9 @@ namespace AIStudio.Wpf.Flowchart
{
public SFCViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
-
+ Init();
}
+
public SFCViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
if (DiagramViewModel != null)
diff --git a/AIStudio.Wpf.DiagramDesigner.Additionals/AIStudio.Wpf.DiagramDesigner.Additionals_parkdvui_wpftmp.csproj b/AIStudio.Wpf.DiagramDesigner.Additionals/AIStudio.Wpf.DiagramDesigner.Additionals_parkdvui_wpftmp.csproj
new file mode 100644
index 0000000..4af40a4
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Additionals/AIStudio.Wpf.DiagramDesigner.Additionals_parkdvui_wpftmp.csproj
@@ -0,0 +1,228 @@
+
+
+ AIStudio.Wpf.DiagramDesigner.Additionals
+ obj\Debug\
+ obj\
+ F:\aistudio.-wpf.-diagram\AIStudio.Wpf.DiagramDesigner.Additionals\obj\
+ <_TargetAssemblyProjectName>AIStudio.Wpf.DiagramDesigner.Additionals
+
+
+
+ true
+ true
+ AIStudio.Wpf.Controls
+ akwkevin
+ https://gitee.com/akwkevin
+ A.png
+
+
+ 1.0.1
+ 一个Wpf的Diagram控件帮助库
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner/Controls/ZoomBox.cs b/AIStudio.Wpf.DiagramDesigner/Controls/ZoomBox.cs
index f26f80c..958c9af 100644
--- a/AIStudio.Wpf.DiagramDesigner/Controls/ZoomBox.cs
+++ b/AIStudio.Wpf.DiagramDesigner/Controls/ZoomBox.cs
@@ -162,7 +162,7 @@ namespace AIStudio.Wpf.DiagramDesigner
if (fitviewmodel != null)
{
target.OnFitViewModelChanged(fitviewmodel);
- }
+ }
}
private void OnFitViewModelChanged(FitViewModel fitViewModel)
@@ -171,7 +171,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
if (fitViewModel.FitMode == FitMode.None)
{
-
+
}
else if (fitViewModel.FitMode == FitMode.FitWidth)
{
@@ -187,12 +187,17 @@ namespace AIStudio.Wpf.DiagramDesigner
(this.ScrollViewer.ViewportWidth * fitViewModel.PaddingRate) / fitViewModel.BoundingRect.Width,
(this.ScrollViewer.ViewportHeight * fitViewModel.PaddingRate) / fitViewModel.BoundingRect.Height
);
- }
-
+ }
+
double xOffset, yOffset;
xOffset = fitViewModel.BoundingRect.Left * ZoomValue - (this.ScrollViewer.ViewportWidth - fitViewModel.BoundingRect.Width * ZoomValue) / 2;
yOffset = fitViewModel.BoundingRect.Top * ZoomValue - (this.ScrollViewer.ViewportHeight - fitViewModel.BoundingRect.Height * ZoomValue) / 2;
- this.ScrollViewer.ScrollToHorizontalOffset(xOffset);
+ if (OffSet)
+ {
+ Vector vector = System.Windows.Media.VisualTreeHelper.GetOffset(DesignerCanvas);
+ xOffset += vector.X;
+ yOffset += vector.Y;
+ }
this.ScrollViewer.ScrollToVerticalOffset(yOffset);
}
}
@@ -200,7 +205,7 @@ namespace AIStudio.Wpf.DiagramDesigner
public ZoomBox()
{
- this.Loaded += ZoomBox_Loaded;
+ this.Loaded += ZoomBox_Loaded;
}
private void ZoomBox_Loaded(object sender, RoutedEventArgs e)
@@ -231,7 +236,7 @@ namespace AIStudio.Wpf.DiagramDesigner
this.zoomThumb.DragDelta += new DragDeltaEventHandler(this.Thumb_DragDelta);
this.zoomSlider.ValueChanged += new RoutedPropertyChangedEventHandler(this.ZoomSlider_ValueChanged);
-
+
}
private void ZoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
@@ -340,12 +345,12 @@ namespace AIStudio.Wpf.DiagramDesigner
{
public Rect BoundingRect
{
- get;set;
+ get; set;
}
public FitMode FitMode
{
- get;set;
+ get; set;
}
public double PaddingRate
diff --git a/AIStudio.Wpf.Mind/Controls/NodeDTSWindow.xaml b/AIStudio.Wpf.Mind/Controls/NodeDTSWindow.xaml
new file mode 100644
index 0000000..b50cf0c
--- /dev/null
+++ b/AIStudio.Wpf.Mind/Controls/NodeDTSWindow.xaml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.Mind/Controls/NodeDTSWindow.xaml.cs b/AIStudio.Wpf.Mind/Controls/NodeDTSWindow.xaml.cs
new file mode 100644
index 0000000..c83b944
--- /dev/null
+++ b/AIStudio.Wpf.Mind/Controls/NodeDTSWindow.xaml.cs
@@ -0,0 +1,71 @@
+using System.Windows;
+using AIStudio.Wpf.DiagramDesigner;
+
+namespace AIStudio.Wpf.Mind.Controls
+{
+ ///
+ /// NodeDTSWindow.xaml 的交互逻辑
+ ///
+ public partial class NodeDTSWindow : Window
+ {
+ public NodeDTSWindow(string title, string content)
+ {
+ InitializeComponent();
+
+ var viewmodel = new NodeDTSWindowViewModel();
+ viewmodel.Title = title;
+ viewmodel.Content = content;
+
+ this.DataContext = viewmodel;
+ }
+
+ public string ContentString
+ {
+ get
+ {
+ return (this.DataContext as NodeDTSWindowViewModel).Content;
+ }
+ }
+
+ private void btnOK_Click(object sender, RoutedEventArgs e)
+ {
+ this.DialogResult = true;
+ this.Close();
+ }
+
+ private void btnCancel_Click(object sender, RoutedEventArgs e)
+ {
+ this.DialogResult = false;
+ this.Close();
+ }
+ }
+
+ public class NodeDTSWindowViewModel : BindableBase
+ {
+ private string _title;
+ public string Title
+ {
+ get
+ {
+ return _title;
+ }
+ set
+ {
+ SetProperty(ref _title, value);
+ }
+ }
+
+ private string _content;
+ public string Content
+ {
+ get
+ {
+ return _content;
+ }
+ set
+ {
+ SetProperty(ref _content, value);
+ }
+ }
+ }
+}
diff --git a/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs b/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs
index 14d98e5..51c8a18 100644
--- a/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs
+++ b/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs
@@ -99,7 +99,7 @@ namespace AIStudio.Wpf.Mind.Helpers
return connector;
}
- public void LayoutUpdated(MindNode mindNode)
+ public void UpdatedLayout(MindNode mindNode)
{
if (mindNode == null) return;
@@ -112,7 +112,6 @@ namespace AIStudio.Wpf.Mind.Helpers
mindNode.GetLevel0Node().LayoutUpdating = false;
}
-
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
{
var sizewithSpacing = mindNode.SizeWithSpacing;
diff --git a/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs b/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs
index 51e3d70..16d114a 100644
--- a/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs
+++ b/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs
@@ -126,7 +126,7 @@ namespace AIStudio.Wpf.Mind.Helpers
return connector;
}
- public void LayoutUpdated(MindNode mindNode)
+ public void UpdatedLayout(MindNode mindNode)
{
if (mindNode == null) return;
diff --git a/AIStudio.Wpf.Mind/Helpers/IMindLayout.cs b/AIStudio.Wpf.Mind/Helpers/IMindLayout.cs
index f7f3527..6b4b30c 100644
--- a/AIStudio.Wpf.Mind/Helpers/IMindLayout.cs
+++ b/AIStudio.Wpf.Mind/Helpers/IMindLayout.cs
@@ -13,7 +13,7 @@ namespace AIStudio.Wpf.Mind.Helpers
void Appearance(MindNode mindNode);
void Appearance(MindNode mindNode, MindTheme mindTheme, bool initAppearance);
ConnectionViewModel GetOrSetConnectionViewModel(MindNode source, MindNode sink, ConnectionViewModel connector = null);
- void LayoutUpdated(MindNode mindNode);
+ void UpdatedLayout(MindNode mindNode);
}
}
diff --git a/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs b/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs
index 00e5acc..77e7fe3 100644
--- a/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs
+++ b/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs
@@ -98,7 +98,7 @@ namespace AIStudio.Wpf.Mind.Helpers
return connector;
}
- public void LayoutUpdated(MindNode mindNode)
+ public void UpdatedLayout(MindNode mindNode)
{
if (mindNode == null) return;
diff --git a/AIStudio.Wpf.Mind/Helpers/MindLayout.cs b/AIStudio.Wpf.Mind/Helpers/MindLayout.cs
index 330f998..5e09bc2 100644
--- a/AIStudio.Wpf.Mind/Helpers/MindLayout.cs
+++ b/AIStudio.Wpf.Mind/Helpers/MindLayout.cs
@@ -100,7 +100,7 @@ namespace AIStudio.Wpf.Mind.Helpers
return connector;
}
- public void LayoutUpdated(MindNode mindNode)
+ public void UpdatedLayout(MindNode mindNode)
{
if (mindNode == null) return;
diff --git a/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs b/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs
index 5e0b701..c1a810c 100644
--- a/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs
+++ b/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs
@@ -100,7 +100,7 @@ namespace AIStudio.Wpf.Mind.Helpers
return connector;
}
- public void LayoutUpdated(MindNode mindNode)
+ public void UpdatedLayout(MindNode mindNode)
{
if (mindNode == null) return;
diff --git a/AIStudio.Wpf.Mind/Models/TreeNode.cs b/AIStudio.Wpf.Mind/Models/TreeNode.cs
new file mode 100644
index 0000000..98c40dc
--- /dev/null
+++ b/AIStudio.Wpf.Mind/Models/TreeNode.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AIStudio.Wpf.Mind.Models
+{
+ public class TreeNode
+ {
+ public string Text
+ {
+ get; set;
+ }
+
+ public List Children
+ {
+ get; set;
+ }
+ }
+}
diff --git a/AIStudio.Wpf.Mind/ViewModels/IMindDiagramViewModel.cs b/AIStudio.Wpf.Mind/ViewModels/IMindDiagramViewModel.cs
index 5b2c295..36eacbd 100644
--- a/AIStudio.Wpf.Mind/ViewModels/IMindDiagramViewModel.cs
+++ b/AIStudio.Wpf.Mind/ViewModels/IMindDiagramViewModel.cs
@@ -45,6 +45,14 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
get;
}
+ ICommand ExportCommand
+ {
+ get;
+ }
+ ICommand ImportCommand
+ {
+ get;
+ }
ICommand SelectBrotherCommand
{
get;
diff --git a/AIStudio.Wpf.Mind/ViewModels/MindDiagramViewModel.cs b/AIStudio.Wpf.Mind/ViewModels/MindDiagramViewModel.cs
index b6f7fb2..5794b85 100644
--- a/AIStudio.Wpf.Mind/ViewModels/MindDiagramViewModel.cs
+++ b/AIStudio.Wpf.Mind/ViewModels/MindDiagramViewModel.cs
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
using System.Linq;
-using System.Reflection;
+using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
+using AIStudio.Wpf.Mind.Controls;
using AIStudio.Wpf.Mind.Helpers;
using AIStudio.Wpf.Mind.Models;
@@ -160,6 +160,24 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
+ private ICommand _exportCommand;
+ public ICommand ExportCommand
+ {
+ get
+ {
+ return this._exportCommand ?? (this._exportCommand = new SimpleCommand(MindExecuteEnable, ExecuteExportCommand));
+ }
+ }
+
+ private ICommand _importCommand;
+ public ICommand ImportCommand
+ {
+ get
+ {
+ return this._importCommand ?? (this._importCommand = new SimpleCommand(MindExecuteEnable, ExecuteImportCommand));
+ }
+ }
+
private ICommand _selectBrotherCommand;
public ICommand SelectBrotherCommand
{
@@ -354,7 +372,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
AddRootItem();
}
ResetChildren(RootItems);
- RootItems?.ForEach(p => p.LayoutUpdated());
+ RootItems?.ForEach(p => p.UpdatedLayout());
base.Init();
}
@@ -378,7 +396,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
item.Offset = new DiagramDesigner.Geometrys.PointBase();
}
- RootItems?.ForEach(p => p.LayoutUpdated());
+ RootItems?.ForEach(p => p.UpdatedLayout());
}
private void ResetChildren(IEnumerable parents)
@@ -393,7 +411,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
item.Parent = parent;
item.InitLayout(false);
- item.InitConnectLayout();
+ item.InitConnectionLayout();
}
ResetChildren(parent.Children);
}
@@ -483,7 +501,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
newitems.Add(newitem);
}
- items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.LayoutUpdated());
+ items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.UpdatedLayout());
},
() => {
foreach (var item in newitems)
@@ -491,7 +509,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
item.RemoveFrom();
}
- items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.LayoutUpdated());
+ items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.UpdatedLayout());
});
}
@@ -529,7 +547,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
newitems.Add(newitem);
}
- items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.LayoutUpdated());
+ items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.UpdatedLayout());
},
() => {
foreach (var item in items)
@@ -545,7 +563,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
item.AddTo(parent.ParentNode, index);
}
- items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.LayoutUpdated());
+ items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.UpdatedLayout());
});
}
@@ -580,16 +598,16 @@ namespace AIStudio.Wpf.Mind.ViewModels
newitems.Add(newitem);
}
- items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.LayoutUpdated());
+ items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.UpdatedLayout());
},
() => {
foreach (var item in newitems)
{
item.RemoveFrom();
- item.LayoutUpdated();
+ item.UpdatedLayout();
}
- items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.LayoutUpdated());
+ items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.UpdatedLayout());
});
}
@@ -644,6 +662,78 @@ namespace AIStudio.Wpf.Mind.ViewModels
});
}
+ private void ExecuteExportCommand(object parameter)
+ {
+ if (parameter is MindNode node)
+ {
+
+ }
+ else
+ {
+ node = SelectedItem as MindNode;
+ }
+
+ if (node != null)
+ {
+ var output = node.GetChildrenText(true);
+ var window = new NodeDTSWindow("导出节点", output);
+ window.ShowDialog();
+ }
+ }
+
+ private void ExecuteImportCommand(object parameter)
+ {
+ if (parameter is MindNode node)
+ {
+
+ }
+ else
+ {
+ node = SelectedItem as MindNode;
+ }
+
+ if (node != null)
+ {
+ var window = new NodeDTSWindow("导入节点", "");
+ if (window.ShowDialog() == true)
+ {
+ List newitems = new List();
+ DoCommandManager.DoNewCommand(this.ToString(),
+ () =>
+ {
+ var content = window.ContentString;
+ var lines = content.Split(new string[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries);
+ MindNode lastnode = node;
+ foreach (var line in lines)
+ {
+ int level = Regex.Matches(line, "\t").Count + node.NodeLevel + 1;
+ string text = line.Replace("\t", "");
+ var newitem = new MindNode(this) { Text = text };
+ while (lastnode.NodeLevel != level - 1)
+ {
+ lastnode = lastnode.ParentNode;
+ }
+ if (lastnode == null)
+ {
+ continue;
+ }
+ newitem.AddTo(lastnode, isSelected: false);
+ lastnode = newitem;
+ newitems.Add(newitem);
+ }
+ node.UpdatedLayout();
+ },
+ () => {
+ foreach (var item in newitems)
+ {
+ item.RemoveFrom();
+ }
+ node.UpdatedLayout();
+ });
+ }
+ }
+ }
+
private void MoveBack(List items)
{
foreach (var item in items)
@@ -660,7 +750,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
item.AddTo(parent, index + 1);
}
}
- items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.LayoutUpdated());
+ items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.UpdatedLayout());
}
private void MoveForward(List items)
@@ -679,7 +769,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
item.AddTo(parent, index - 1);
}
}
- items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.LayoutUpdated());
+ items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.UpdatedLayout());
}
protected override bool Delete(object parameter)
@@ -731,7 +821,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
base.Delete(others);
}
- items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.LayoutUpdated());
+ items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.UpdatedLayout());
},
() => {
if (others.Any())
@@ -748,7 +838,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
- items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.LayoutUpdated());
+ items.Select(p => p.RootNode).Distinct().ToList().ForEach(p => p.UpdatedLayout());
});
return true;
}
@@ -776,7 +866,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
ResetChildren(parents);
- parents.ForEach(p => p.LayoutUpdated());
+ parents.ForEach(p => p.UpdatedLayout());
}
#endregion
@@ -997,14 +1087,14 @@ namespace AIStudio.Wpf.Mind.ViewModels
() => {
roots.ForEach(p => p.MindType = mindType);
Items.OfType().ToList().ForEach(item => { item.InitLayout(true); });
- Items.OfType().ToList().ForEach(item => { item.InitConnectLayout(); });
- roots.ForEach(p => p.LayoutUpdated());
+ Items.OfType().ToList().ForEach(item => { item.InitConnectionLayout(); });
+ roots.ForEach(p => p.UpdatedLayout());
},
() => {
roots.ForEach(p => p.MindType = oldMindType);
Items.OfType().ToList().ForEach(item => { item.InitLayout(true); });
- Items.OfType().ToList().ForEach(item => { item.InitConnectLayout(); });
- roots.ForEach(p => p.LayoutUpdated());
+ Items.OfType().ToList().ForEach(item => { item.InitConnectionLayout(); });
+ roots.ForEach(p => p.UpdatedLayout());
});
}
}
@@ -1033,7 +1123,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
MindTheme = mindTheme;
roots.ForEach(p => p.MindTheme = MindTheme);
roots.SelectMany(p => p.GetChildren(true)).ToList().ForEach(item => { item.ThemeChange(); });
- roots.ForEach(p => p.LayoutUpdated());
+ roots.ForEach(p => p.UpdatedLayout());
},
() => {
var mindThemeModel = MindThemeHelper.GetTheme(oldmindTheme);
@@ -1048,7 +1138,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
MindTheme = oldmindTheme;
roots.ForEach(p => p.MindTheme = MindTheme);
roots.SelectMany(p => p.GetChildren(true)).ToList().ForEach(item => { item.ThemeChange(); });
- roots.ForEach(p => p.LayoutUpdated());
+ roots.ForEach(p => p.UpdatedLayout());
});
}
}
@@ -1177,7 +1267,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
rootitem.Left = left.Value;
rootitem.Top = top.Value;
rootitem.Offset = offset;
- rootitem?.LayoutUpdated();
+ rootitem?.UpdatedLayout();
FitViewModel = new FitViewModel() { BoundingRect = rootitem.GetBounds() };
}
diff --git a/AIStudio.Wpf.Mind/ViewModels/MindNode.cs b/AIStudio.Wpf.Mind/ViewModels/MindNode.cs
index 2c440fe..f60f64e 100644
--- a/AIStudio.Wpf.Mind/ViewModels/MindNode.cs
+++ b/AIStudio.Wpf.Mind/ViewModels/MindNode.cs
@@ -2,27 +2,22 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
-using System.IO;
using System.Linq;
using System.Security.Policy;
using System.Text;
-using System.Windows;
-using System.Windows.Controls;
+using System.Text.RegularExpressions;
using System.Windows.Input;
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.Mind.Models;
+using AIStudio.Wpf.Mind.Controls;
using AIStudio.Wpf.Mind.Helpers;
using AIStudio.Wpf.Mind.Models;
-
namespace AIStudio.Wpf.Mind.ViewModels
{
public class MindNode : DiagramItemViewModel
@@ -85,6 +80,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
DeleteCommand = (Root as IMindDiagramViewModel)?.DeleteCommand;
MoveForwardCommand = (Root as IMindDiagramViewModel)?.MoveForwardCommand;
MoveBackCommand = (Root as IMindDiagramViewModel)?.MoveBackCommand;
+ ExportCommand = (Root as IMindDiagramViewModel)?.ExportCommand;
+ ImportCommand = (Root as IMindDiagramViewModel)?.ImportCommand;
BuildMenuOptions();
Tags = new ObservableCollection();
}
@@ -105,6 +102,27 @@ namespace AIStudio.Wpf.Mind.ViewModels
this.PropertyChanged += this.Item_PropertyChanged;
}
+ public void InitConnectionLayout()
+ {
+ var connector = Root?.Items.OfType().Where(p => p.IsFullConnection).FirstOrDefault(p => p.SinkConnectorInfoFully.DataItem == this);
+ if (connector != null)
+ {
+ MindLayout?.GetOrSetConnectionViewModel(connector.SourceConnectorInfo.DataItem as MindNode, connector.SinkConnectorInfoFully.DataItem as MindNode, connector);
+ }
+ else if (ParentNode != null)
+ {
+ connector = MindLayout?.GetOrSetConnectionViewModel(ParentNode, this, null);
+ Root?.Add(new SelectableDesignerItemViewModelBase[] { connector });
+ connector.ZIndex = -1;
+ connector.IsSelected = false;
+ }
+ }
+
+ public void UpdatedLayout()
+ {
+ MindLayout?.UpdatedLayout(GetLevel0Node());
+ }
+
public void ThemeChange()
{
MindThemeHelper.ThemeChange(this, MindTheme);
@@ -144,6 +162,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
}
+
#region 属性
private MindType _mindType = MindType.Mind;
public MindType MindType
@@ -428,6 +447,16 @@ namespace AIStudio.Wpf.Mind.ViewModels
{
get; private set;
}
+
+ public ICommand ExportCommand
+ {
+ get; private set;
+ }
+
+ public ICommand ImportCommand
+ {
+ get; private set;
+ }
#endregion
#region 菜单
@@ -464,6 +493,16 @@ namespace AIStudio.Wpf.Mind.ViewModels
menuItem.Command = DeleteCommand;
menuItem.CommandParameter = this;
menuOptions.Add(menuItem);
+ menuItem = new CinchMenuItem();
+ menuItem.Text = "导出节点";
+ menuItem.Command = ExportCommand;
+ menuItem.CommandParameter = this;
+ menuOptions.Add(menuItem);
+ menuItem = new CinchMenuItem();
+ menuItem.Text = "导入节点";
+ menuItem.Command = ImportCommand;
+ menuItem.CommandParameter = this;
+ menuOptions.Add(menuItem);
}
#endregion
@@ -483,7 +522,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
this.ParentId = parent?.Id ?? Guid.Empty;
this.Offset = parent?.Offset ?? new PointBase();
this.InitLayout(true);//因为节点的层级不同的样式,所以需要Parent确定后才能初始化
- this.InitConnectLayout();
+ this.InitConnectionLayout();
Root?.Add(this);
@@ -508,35 +547,10 @@ namespace AIStudio.Wpf.Mind.ViewModels
Root?.Remove(this);
Root?.Remove(connectors);
-
- //if (removeall)
- //{
- // if (this.Children?.Count > 0)
- // {
- // foreach (var child in this.Children.ToList())
- // {
- // child.RemoveFrom(removeall);
- // }
- // }
- //}
- }
-
- public void InitConnectLayout()
- {
- var connector = Root?.Items.OfType().Where(p => p.IsFullConnection).FirstOrDefault(p => p.SinkConnectorInfoFully.DataItem == this);
- if (connector != null)
- {
- MindLayout?.GetOrSetConnectionViewModel(connector.SourceConnectorInfo.DataItem as MindNode, connector.SinkConnectorInfoFully.DataItem as MindNode, connector);
- }
- else if (ParentNode != null)
- {
- connector = MindLayout?.GetOrSetConnectionViewModel(ParentNode, this, null);
- Root?.Add(new SelectableDesignerItemViewModelBase[] { connector });
- connector.ZIndex = -1;
- connector.IsSelected = false;
- }
- }
+ }
#endregion
+
+ #region 属性改变
private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (GetLevel0Node()?.LayoutUpdating == true) return;
@@ -564,7 +578,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
case nameof(ItemWidth):
case nameof(ItemHeight):
{
- LayoutUpdated();
+ UpdatedLayout();
break;
}
case nameof(NodeLevel):
@@ -583,33 +597,6 @@ namespace AIStudio.Wpf.Mind.ViewModels
}
}
- private void SetItemWidthHeight()
- {
- double width = 0;
- double height = 0;
- width += GetTextDisplayWidthHelper.GetTextDisplayWidth(Text, new FontFamily(FontViewModel.FontFamily), FontViewModel.FontStyle, FontViewModel.FontWeight, FontViewModel.FontStretch, FontViewModel.FontSize) + 30;
- width += Rate == null ? 0 : 24;
- width += Priority == null ? 0 : 24;
- width += Remark == null ? 0 : 24;
- width += LinkInfo == null ? 0 : 24;
-
- var defaultTheme = MindThemeHelper.GetNodeDefaultTheme(this);
- if (ImageInfo != null)
- {
- width = Math.Max(width, 160);
- height = defaultTheme.ItemHeight / defaultTheme.FontSize * FontViewModel.FontSize + 135;
- }
- else
- {
- height = defaultTheme.ItemHeight / defaultTheme.FontSize * FontViewModel.FontSize;
- }
-
- ItemWidth = width;
- ItemHeight = height;
-
- }
-
-
protected override void FontViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(FontViewModel.FontSize))
@@ -617,15 +604,8 @@ namespace AIStudio.Wpf.Mind.ViewModels
SetItemWidthHeight();
}
}
+ #endregion
- public override void AddToSelection(bool selected)
- {
- foreach (SelectableDesignerItemViewModelBase item in Root.SelectedItems.ToList())
- item.IsSelected = false;
-
- Root.SelectedItems.Clear();
- IsSelected = selected;
- }
#region 布局相关
public MindNode GetLevel0Node()
{
@@ -682,6 +662,26 @@ namespace AIStudio.Wpf.Mind.ViewModels
return mindnode;
}
+ public string GetChildrenText(bool self = false)
+ {
+ StringBuilder sb = new StringBuilder();
+ List mindnode = new List();
+ if (self)
+ {
+ sb.AppendLine(this.Text);
+ }
+
+ if (this.Children != null)
+ {
+ foreach (var child in this.Children)
+ {
+ sb.AppendLine($"{new String('\t', child.NodeLevel)}{child.Text}");
+ sb.Append(child.GetChildrenText());
+ }
+ }
+ return sb.ToString();
+ }
+
protected void UpdateOffsetX(double oldvalue, double newvalue)
{
Offset += new VectorBase(newvalue - oldvalue, 0);
@@ -692,11 +692,42 @@ namespace AIStudio.Wpf.Mind.ViewModels
Offset += new VectorBase(0, newvalue - oldvalue);
}
- public void LayoutUpdated()
+ private void SetItemWidthHeight()
{
- MindLayout?.LayoutUpdated(GetLevel0Node());
+ double width = 0;
+ double height = 0;
+ width += GetTextDisplayWidthHelper.GetTextDisplayWidth(Text, new FontFamily(FontViewModel.FontFamily), FontViewModel.FontStyle, FontViewModel.FontWeight, FontViewModel.FontStretch, FontViewModel.FontSize) + 30;
+ width += Rate == null ? 0 : 24;
+ width += Priority == null ? 0 : 24;
+ width += Remark == null ? 0 : 24;
+ width += LinkInfo == null ? 0 : 24;
+
+ var defaultTheme = MindThemeHelper.GetNodeDefaultTheme(this);
+ if (ImageInfo != null)
+ {
+ width = Math.Max(width, 160);
+ height = defaultTheme.ItemHeight / defaultTheme.FontSize * FontViewModel.FontSize + 135;
+ }
+ else
+ {
+ height = defaultTheme.ItemHeight / defaultTheme.FontSize * FontViewModel.FontSize;
+ }
+
+ ItemWidth = width;
+ ItemHeight = height;
+
}
+ public override void AddToSelection(bool selected)
+ {
+ foreach (SelectableDesignerItemViewModelBase item in Root.SelectedItems.ToList())
+ item.IsSelected = false;
+
+ Root.SelectedItems.Clear();
+ IsSelected = selected;
+ }
+
+
#endregion
}
diff --git a/AIStudio.Wpf.SFC/AIStudio.Wpf.SFC_yp1baqtv_wpftmp.csproj b/AIStudio.Wpf.SFC/AIStudio.Wpf.SFC_yp1baqtv_wpftmp.csproj
new file mode 100644
index 0000000..aa45949
--- /dev/null
+++ b/AIStudio.Wpf.SFC/AIStudio.Wpf.SFC_yp1baqtv_wpftmp.csproj
@@ -0,0 +1,166 @@
+
+
+ AIStudio.Wpf.SFC
+ obj\Debug\
+ obj\
+ F:\aistudio.-wpf.-diagram\AIStudio.Wpf.SFC\obj\
+ <_TargetAssemblyProjectName>AIStudio.Wpf.SFC
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file