diff --git a/AIStudio.Wpf.DiagramApp/Models/PathToolBoxData.cs b/AIStudio.Wpf.DiagramApp/Models/PathToolBoxData.cs
index 53d5cf2..71cf72d 100644
--- a/AIStudio.Wpf.DiagramApp/Models/PathToolBoxData.cs
+++ b/AIStudio.Wpf.DiagramApp/Models/PathToolBoxData.cs
@@ -4,12 +4,13 @@ using System;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.DiagramDesigner.Helpers;
+using System.Windows;
namespace AIStudio.Wpf.DiagramApp.Models
{
public class PathToolBoxData : ToolBoxData
{
- public PathToolBoxData(string icon, Type type, double width = 32, double height = 32) : base(null, icon, type, width, height)
+ public PathToolBoxData(string icon, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(null, icon, type, width, height, desiredSize, description)
{
ColorViewModel.FillColor.Color = Colors.Orange;
}
@@ -18,7 +19,7 @@ namespace AIStudio.Wpf.DiagramApp.Models
public class TextToolBoxData : ToolBoxData
{
- public TextToolBoxData(string text, Type type, double width = 32, double height = 32) : base(text, null, type, width, height)
+ public TextToolBoxData(string text, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(text, null, type, width, height, desiredSize, description)
{
ColorViewModel.FillColor.Color = Colors.Orange;
}
@@ -27,7 +28,7 @@ namespace AIStudio.Wpf.DiagramApp.Models
public class EllipseTextToolBoxData : ToolBoxData
{
- public EllipseTextToolBoxData(string text, Type type, double width = 32, double height = 32) : base(text, null, type, width, height)
+ public EllipseTextToolBoxData(string text, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(text, null, type, width, height, desiredSize, description)
{
ColorViewModel.FillColor.Color = Colors.Orange;
}
@@ -36,7 +37,7 @@ namespace AIStudio.Wpf.DiagramApp.Models
public class ImageToolBoxData : ToolBoxData
{
- public ImageToolBoxData(string icon, Type type, double width = 32, double height = 32) : base(null, icon, type, width, height)
+ public ImageToolBoxData(string icon, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(null, icon, type, width, height, desiredSize, description)
{
}
@@ -46,7 +47,7 @@ namespace AIStudio.Wpf.DiagramApp.Models
{
public string FileName { get; set; }
public DesignerItemViewModelBase DesignerItemViewModel { get; set; }
- public DesignerItemToolBoxData(DesignerItemBase designerItemBase, string filename, Type type, double width = 32, double height = 32) : base(null, null, type, width, height)
+ public DesignerItemToolBoxData(DesignerItemBase designerItemBase, string filename, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(null, null, type, width, height, desiredSize, description)
{
Addition = designerItemBase;
DesignerItemViewModel = Activator.CreateInstance(type, null, designerItemBase) as DesignerItemViewModelBase;
@@ -57,7 +58,7 @@ namespace AIStudio.Wpf.DiagramApp.Models
public class SvgToolBoxData : ToolBoxData
{
- public SvgToolBoxData(string filename, Type type, double width = 32, double height = 32) : base(null, filename, type, width, height)
+ public SvgToolBoxData(string filename, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(null, filename, type, width, height, desiredSize, description)
{
ColorViewModel.FillColor.Color = Colors.Blue;
}
@@ -65,7 +66,7 @@ namespace AIStudio.Wpf.DiagramApp.Models
public class MediaToolBoxData : ToolBoxData
{
- public MediaToolBoxData(string icon, Type type, double width = 32, double height = 32) : base(icon, null, type, width, height)
+ public MediaToolBoxData(string icon, Type type, double width = 32, double height = 32, Size? desiredSize = null, string description = null) : base(icon, null, type, width, height, desiredSize, description)
{
}
diff --git a/AIStudio.Wpf.DiagramApp/Themes/Generic.xaml b/AIStudio.Wpf.DiagramApp/Themes/Generic.xaml
index aba1a65..e2a8922 100644
--- a/AIStudio.Wpf.DiagramApp/Themes/Generic.xaml
+++ b/AIStudio.Wpf.DiagramApp/Themes/Generic.xaml
@@ -3,13 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
-
-
-
-
-
-
-
+
+
diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/ToolBoxViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/ToolBoxViewModel.cs
index e518f7c..961390d 100644
--- a/AIStudio.Wpf.DiagramApp/ViewModels/ToolBoxViewModel.cs
+++ b/AIStudio.Wpf.DiagramApp/ViewModels/ToolBoxViewModel.cs
@@ -25,7 +25,13 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
public class ToolBoxViewModel : BindableBase
{
- private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
+ private IDiagramServiceProvider _service
+ {
+ get
+ {
+ return DiagramServicesProvider.Instance.Provider;
+ }
+ }
public ToolBoxViewModel()
{
Init();
@@ -44,11 +50,26 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
- public ObservableCollection TotalToolBoxCategory { get; set; }
+ public ObservableCollection TotalToolBoxCategory
+ {
+ get; set;
+ }
- public ToolBoxCategory MyToolBoxCategory { get { return ToolBoxCategory[0]; } }
+ public ToolBoxCategory MyToolBoxCategory
+ {
+ get
+ {
+ return ToolBoxCategory?.FirstOrDefault();
+ }
+ }
- public ToolBoxCategory SvgToolBoxCategory { get { return ToolBoxCategory[2]; } }
+ public ToolBoxCategory SvgToolBoxCategory
+ {
+ get
+ {
+ return ToolBoxCategory?.FirstOrDefault(p => p.Header == "Svg");
+ }
+ }
private ICommand _deleteCommand;
public ICommand DeleteCommand
@@ -91,11 +112,17 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
ToolBoxCategory.Add(new MineToolBoxCategory() { Header = "我的形状", ToolBoxItems = new ObservableCollection(), IsExpanded = true });
List toolBoxItems = new List();
- toolBoxItems.Add(new ImageToolBoxData("../Images/Setting.png", typeof(SettingsDesignerItemViewModel)));
- toolBoxItems.Add(new ImageToolBoxData("../Images/Persist.png", typeof(PersistDesignerItemViewModel)));
+ toolBoxItems.Add(new ImageToolBoxData("../Images/Setting.png", typeof(SettingsDesignerItemViewModel), description: "致谢WPF-Diagram-Designer的开源作者,保留开源作品中的两个设计"));
+ toolBoxItems.Add(new ImageToolBoxData("../Images/Persist.png", typeof(PersistDesignerItemViewModel), description: "致谢WPF-Diagram-Designer的开源作者,保留开源作品中的两个设计"));
ToolBoxCategory.Add(new ToolBoxCategory() { Header = "WPF-Diagram-Designer", ToolBoxItems = new ObservableCollection(toolBoxItems), IsExpanded = true });
+
+ List defaultToolBoxItems = new List();
+ defaultToolBoxItems.Add(new TextToolBoxData("", typeof(DefaultDesignerItemViewModel)));
+
+ ToolBoxCategory.Add(new ToolBoxCategory() { Header = "Default", ToolBoxItems = new ObservableCollection(defaultToolBoxItems), IsExpanded = true });
+
ToolBoxCategory.Add(new ToolBoxCategory() { Header = "Svg", ToolBoxItems = new ObservableCollection() });
List pathToolBoxItems = new List();
@@ -240,7 +267,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
try
{
- var xmlobject = JsonConvert.DeserializeObject(File.ReadAllText(filename));
+ var xmlobject = JsonConvert.DeserializeObject(File.ReadAllText(filename));
Type type = TypeHelper.GetType(xmlobject.DiagramItems[0].DesignerItems[0].SerializableTypeName);
@@ -294,7 +321,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
public class ToolBoxCategory : BindableBase
{
- public string Header { get; set; }
+ public string Header
+ {
+ get; set;
+ }
private bool _isExpanded;
public bool IsExpanded
diff --git a/AIStudio.Wpf.DiagramApp/Views/ToolBoxControl.xaml b/AIStudio.Wpf.DiagramApp/Views/ToolBoxControl.xaml
index 1a8b9bd..1559468 100644
--- a/AIStudio.Wpf.DiagramApp/Views/ToolBoxControl.xaml
+++ b/AIStudio.Wpf.DiagramApp/Views/ToolBoxControl.xaml
@@ -23,7 +23,7 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -162,7 +162,7 @@
-
+
+
+ AIStudio.Wpf.DiagramDesigner.Demo
+ obj\Debug\
+ obj\
+ F:\aistudio.-wpf.-diagram\AIStudio.Wpf.DiagramDesigner.Demo\obj\
+ <_TargetAssemblyProjectName>AIStudio.Wpf.DiagramDesigner.Demo
+
+
+
+ WinExe
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/App.xaml b/AIStudio.Wpf.DiagramDesigner.Demo/App.xaml
index 5bc383c..53a6e84 100644
--- a/AIStudio.Wpf.DiagramDesigner.Demo/App.xaml
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/App.xaml
@@ -59,14 +59,8 @@
-
-
-
-
-
-
-
-
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Controls/TitleControl.xaml b/AIStudio.Wpf.DiagramDesigner.Demo/Controls/TitleControl.xaml
new file mode 100644
index 0000000..8f9862c
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Controls/TitleControl.xaml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Controls/TitleControl.xaml.cs b/AIStudio.Wpf.DiagramDesigner.Demo/Controls/TitleControl.xaml.cs
new file mode 100644
index 0000000..38cbce0
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Controls/TitleControl.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.Controls
+{
+ ///
+ /// TitleControl.xaml 的交互逻辑
+ ///
+ public partial class TitleControl : UserControl
+ {
+ public TitleControl()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/MainWindow.xaml b/AIStudio.Wpf.DiagramDesigner.Demo/MainWindow.xaml
index 0ecccc6..7423cc4 100644
--- a/AIStudio.Wpf.DiagramDesigner.Demo/MainWindow.xaml
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/MainWindow.xaml
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo"
mc:Ignorable="d"
- Title="MainWindow" Height="450" Width="800">
+ Title="AIStudio.Wpf.DiagramDesigner.Demo" Height="450" Width="800">
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/Base/BaseViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/Base/BaseViewModel.cs
new file mode 100644
index 0000000..4299d1c
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/Base/BaseViewModel.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
+{
+ class BaseViewModel : BindableBase
+ {
+ protected IDiagramServiceProvider _service
+ {
+ get
+ {
+ return DiagramServicesProvider.Instance.Provider;
+ }
+ }
+
+ public DiagramViewModel DiagramViewModel
+ {
+ get; set;
+ }
+
+ public string Title
+ {
+ get;set;
+ }
+
+ public string Info
+ {
+ get; set;
+ }
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/CustomDesignerItemViewModel.xaml b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/CustomDesignerItemViewModel.xaml
new file mode 100644
index 0000000..42191cd
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/CustomDesignerItemViewModel.xaml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/CustomNodeViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/CustomNodeViewModel.cs
new file mode 100644
index 0000000..4922dc9
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/CustomNodeViewModel.cs
@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows;
+using AIStudio.Wpf.DiagramDesigner.Models;
+
+namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
+{
+ class CustomNodeViewModel : BaseViewModel
+ {
+ public CustomNodeViewModel()
+ {
+ Title = "Custom node";
+ Info = "Creating your own custom design is very easy!";
+
+ //_service.ColorViewModel.FillColor.Color = System.Windows.Media.Colors.Orange;
+
+ DiagramViewModel = new DiagramViewModel();
+ DiagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
+ DiagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
+ DiagramViewModel.PageSizeType = PageSizeType.Custom;
+ DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
+
+ DefaultDesignerItemViewModel node1 = new DefaultDesignerItemViewModel() { Left = 50, Top = 50, Text = "1" };
+ DiagramViewModel.DirectAddItemCommand.Execute(node1);
+
+ CustomDesignerItemViewModel node2 = new CustomDesignerItemViewModel() { Left = 300, Top = 300 };
+ DiagramViewModel.DirectAddItemCommand.Execute(node2);
+
+ CustomDesignerItemViewModel node3 = new CustomDesignerItemViewModel() { Left = 300, Top = 50 };
+ DiagramViewModel.DirectAddItemCommand.Execute(node3);
+
+ ConnectionViewModel connector1 = new ConnectionViewModel(node1.RightConnector, node2.TopConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
+ DiagramViewModel.DirectAddItemCommand.Execute(connector1);
+
+ ConnectionViewModel connector2 = new ConnectionViewModel(node2.BottomConnector, node3.BottomConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
+ DiagramViewModel.DirectAddItemCommand.Execute(connector2);
+
+ }
+ }
+
+ public class CustomDesignerItemViewModel : DesignerItemViewModelBase
+ {
+ public CustomDesignerItemViewModel() : base()
+ {
+
+ }
+
+ public CustomDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
+ {
+
+ }
+
+ public CustomDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
+ {
+
+ }
+
+ public override SelectableItemBase GetSerializableObject()
+ {
+ return new DesignerItemBase(this, Answer);
+ }
+
+ protected override void Init()
+ {
+ base.Init();
+
+ this.ItemWidth = 150;
+ this.ItemHeight = 80;
+ InitConnector();
+ }
+
+ protected override void InitConnector()
+ {
+ connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top));
+ connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Bottom));
+ }
+
+ protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
+ {
+ base.LoadDesignerItemViewModel(root, designerbase);
+
+ if (designerbase is DesignerItemBase designer)
+ {
+ this.Answer = designer.Reserve;
+ }
+ }
+
+ private string _answer;
+ public string Answer
+ {
+ get
+ {
+ return _answer;
+ }
+ set
+ {
+ SetProperty(ref _answer, value);
+ }
+ }
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/DragAndDropViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/DragAndDropViewModel.cs
index 3fe9de4..d4ffa07 100644
--- a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/DragAndDropViewModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/DragAndDropViewModel.cs
@@ -8,19 +8,31 @@ using AIStudio.Wpf.Flowchart.ViewModels;
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
{
- public class DragAndDropViewModel: BindableBase
+ class DragAndDropViewModel: BaseViewModel
{
+ public DragAndDropViewModel()
+ {
+ Title = "Drag & Drop";
+ Info = "A very simple drag & drop of flowchart demo.";
+
+ ToolBoxViewModel = new ToolBoxViewModel();
+ DiagramViewModel = new DiagramViewModel();
+ DiagramViewModel.ShowGrid = true;
+ DiagramViewModel.GridCellSize = new Size(100, 100);
+ DiagramViewModel.GridMarginSize = new Size(0, 0);
+ DiagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
+ DiagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
+ DiagramViewModel.PageSizeType = PageSizeType.Custom;
+ DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
+
+ DiagramViewModel.PropertyChanged += DiagramViewModel_PropertyChanged;
+ }
+
public ToolBoxViewModel ToolBoxViewModel
{
get; private set;
}
- public DiagramViewModel DiagramViewModel
- {
- get; private set;
- }
-
-
public SelectableDesignerItemViewModelBase SelectedItem
{
get
@@ -62,22 +74,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
{
_roles = value;
}
- }
-
- public DragAndDropViewModel()
- {
- ToolBoxViewModel = new ToolBoxViewModel();
- DiagramViewModel = new DiagramViewModel();
- DiagramViewModel.ShowGrid = true;
- DiagramViewModel.GridCellSize = new Size(100, 100);
- DiagramViewModel.GridMarginSize = new Size(0, 0);
- DiagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
- DiagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
- DiagramViewModel.PageSizeType = PageSizeType.Custom;
- DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
-
- DiagramViewModel.PropertyChanged += DiagramViewModel_PropertyChanged;
- }
+ }
private void DiagramViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/FlowchartEditorViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/FlowchartEditorViewModel.cs
index ba39107..08042db 100644
--- a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/FlowchartEditorViewModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/FlowchartEditorViewModel.cs
@@ -5,8 +5,17 @@ using AIStudio.Wpf.Flowchart;
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
{
- public class FlowchartEditorViewModel : BindableBase
+ class FlowchartEditorViewModel : BaseViewModel
{
+ public FlowchartEditorViewModel()
+ {
+ Title = "FlowchartEditor";
+ Info = "Encapsulated flowchart controls";
+
+ GetDataCommand = new SimpleCommand(GetDataExcute);
+ SetDataCommand = new SimpleCommand(SetDataExcute);
+ }
+
private List _users = new List()
{
new SelectOption(){ value = "操作员1",text = "操作员1" },
@@ -108,12 +117,6 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
get; private set;
}
- public FlowchartEditorViewModel()
- {
- GetDataCommand = new SimpleCommand(GetDataExcute);
- SetDataCommand = new SimpleCommand(SetDataExcute);
- }
-
private void GetDataExcute(object obj)
{
OutputData = GetDataFunc();
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/LockedViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/LockedViewModel.cs
new file mode 100644
index 0000000..39dc56f
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/LockedViewModel.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+
+namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
+{
+ class LockedViewModel : BaseViewModel
+ {
+ public LockedViewModel()
+ {
+ Title = "Locked models";
+ Info = "All the nodes and links in this example are locked, they cannot be moved nor deleted." +
+ //"All the TOP ports are locked as well, so you can't create links from/to them, but you can from/to the others." +
+ "Newly created links aren't locked, so they can be deleted.";
+
+ _service.ColorViewModel.FillColor.Color = System.Windows.Media.Colors.Orange;
+
+ DiagramViewModel = new DiagramViewModel();
+ DiagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
+ DiagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
+ DiagramViewModel.PageSizeType = PageSizeType.Custom;
+ DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
+
+ DefaultDesignerItemViewModel node1 = new DefaultDesignerItemViewModel() { Left = 50, Top = 50, Text = "1" };
+ //node1.LockObjectViewModel.LockObject.FirstOrDefault(p => p.LockFlag == LockFlag.All).IsChecked = true;//这个也可以
+ node1.IsReadOnly = true;
+ DiagramViewModel.DirectAddItemCommand.Execute(node1);
+
+ DefaultDesignerItemViewModel node2 = new DefaultDesignerItemViewModel() { Left = 300, Top = 300, Text = "2" };
+ //node2.LockObjectViewModel.LockObject.FirstOrDefault(p => p.LockFlag == LockFlag.All).IsChecked = true;//这个也可以
+ node2.IsReadOnly = true;
+ DiagramViewModel.DirectAddItemCommand.Execute(node2);
+
+ DefaultDesignerItemViewModel node3 = new DefaultDesignerItemViewModel() { Left = 300, Top = 50, Text = "3" };
+ //node3.LockObjectViewModel.LockObject.FirstOrDefault(p => p.LockFlag == LockFlag.All).IsChecked = true;//这个也可以
+ node3.IsReadOnly = true;
+ DiagramViewModel.DirectAddItemCommand.Execute(node3);
+
+ ConnectionViewModel connector1 = new ConnectionViewModel(node1.RightConnector, node2.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
+ //connector1.LockObjectViewModel.LockObject.FirstOrDefault(p => p.LockFlag == LockFlag.All).IsChecked = true;//这个也可以
+ connector1.IsReadOnly = true;
+ DiagramViewModel.DirectAddItemCommand.Execute(connector1);
+
+ ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
+ // connector2.LockObjectViewModel.LockObject.FirstOrDefault(p => p.LockFlag == LockFlag.All).IsChecked = true;//这个也可以
+ connector2.IsReadOnly = true;
+ DiagramViewModel.DirectAddItemCommand.Execute(connector2);
+
+ }
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/PerformanceViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/PerformanceViewModel.cs
new file mode 100644
index 0000000..0a0d827
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/PerformanceViewModel.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows;
+
+namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
+{
+ class PerformanceViewModel : BaseViewModel
+ {
+ public PerformanceViewModel()
+ {
+ Title = "Performance";
+ Info = "This diagram contains 100 nodes and 50 links";
+
+ _service.ColorViewModel.FillColor.Color = System.Windows.Media.Colors.Orange;
+
+ DiagramViewModel = new DiagramViewModel();
+ DiagramViewModel.PageSizeType = PageSizeType.Custom;
+ DiagramViewModel.PageSize = new Size(1000, 1000);
+
+ for (int r = 0; r < 10; r++)
+ {
+ for (int c = 0; c < 10; c += 2)
+ {
+ var node1 = new DefaultDesignerItemViewModel() { Left = 10 + c * 10 + c * 120, Top = 10 + r * 100, Text = $"{r * 10 + c}" };
+ var node2 = new DefaultDesignerItemViewModel { Left = 10 + (c + 1) * 130, Top = 10 + r * 100, Text = $"{r * 10 + c + 1}" };
+
+ DiagramViewModel.DirectAddItemCommand.Execute(new List { node1, node2 });
+
+ ConnectionViewModel connector1 = new ConnectionViewModel(node1.RightConnector, node2.LeftConnector);
+ DiagramViewModel.DirectAddItemCommand.Execute(connector1);
+ }
+ }
+ }
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/SimpleViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/SimpleViewModel.cs
index aa838f5..87d9e83 100644
--- a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/SimpleViewModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/SimpleViewModel.cs
@@ -1,20 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;
+using System.Windows;
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
{
- class SimpleViewModel : BindableBase
+ class SimpleViewModel : BaseViewModel
{
- public DiagramViewModel DiagramViewModel
- {
- get; private set;
- }
-
public SimpleViewModel()
{
- //DesignerItemViewModelBase timer = new TimerDesignerItemViewModel() { Left = 0, Top = 10 };
- //DiagramViewModel.DirectAddItemCommand.Execute(timer);
+ Title = "Simple";
+ Info = "A simple example of AIStudio.Wpf.DiagramDesigner.";
+
+ _service.ColorViewModel.FillColor.Color = System.Windows.Media.Colors.Orange;
+
+ DiagramViewModel = new DiagramViewModel();
+ DiagramViewModel.PageSizeType = PageSizeType.Custom;
+ DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
+
+ DefaultDesignerItemViewModel node1 = new DefaultDesignerItemViewModel() { Left = 50, Top = 50, Text = "1" };
+ DiagramViewModel.DirectAddItemCommand.Execute(node1);
+
+ DefaultDesignerItemViewModel node2 = new DefaultDesignerItemViewModel() { Left = 300, Top = 300, Text = "2" };
+ DiagramViewModel.DirectAddItemCommand.Execute(node2);
+
+ DefaultDesignerItemViewModel node3 = new DefaultDesignerItemViewModel() { Left = 300, Top = 50, Text = "3" };
+ DiagramViewModel.DirectAddItemCommand.Execute(node3);
+
+ ConnectionViewModel connector1 = new ConnectionViewModel(node1.RightConnector, node2.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
+ DiagramViewModel.DirectAddItemCommand.Execute(connector1);
+
+ ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
+ DiagramViewModel.DirectAddItemCommand.Execute(connector2);
}
}
}
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/SnapToGridViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/SnapToGridViewModel.cs
new file mode 100644
index 0000000..6ddbcc7
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/SnapToGridViewModel.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows;
+
+namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
+{
+ class SnapToGridViewModel : BaseViewModel
+ {
+ public SnapToGridViewModel()
+ {
+ Title = "Snap to Grid";
+ Info = "This diagram has a grid size of 100, moving nodes will make them automatically snap.";
+
+ _service.ColorViewModel.FillColor.Color = System.Windows.Media.Colors.Orange;
+
+ DiagramViewModel = new DiagramViewModel();
+ DiagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
+ DiagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
+ DiagramViewModel.PageSizeType = PageSizeType.Custom;
+ DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
+
+ DefaultDesignerItemViewModel node1 = new DefaultDesignerItemViewModel() { Left = 50, Top = 50, Text = "1" };
+ DiagramViewModel.DirectAddItemCommand.Execute(node1);
+
+ DefaultDesignerItemViewModel node2 = new DefaultDesignerItemViewModel() { Left = 300, Top = 300, Text = "2" };
+ DiagramViewModel.DirectAddItemCommand.Execute(node2);
+
+ DefaultDesignerItemViewModel node3 = new DefaultDesignerItemViewModel() { Left = 300, Top = 50, Text = "3" };
+ DiagramViewModel.DirectAddItemCommand.Execute(node3);
+
+ ConnectionViewModel connector1 = new ConnectionViewModel(node1.RightConnector, node2.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
+ DiagramViewModel.DirectAddItemCommand.Execute(connector1);
+
+ ConnectionViewModel connector2 = new ConnectionViewModel(node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
+ DiagramViewModel.DirectAddItemCommand.Execute(connector2);
+
+ }
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/CustomNodeView.xaml b/AIStudio.Wpf.DiagramDesigner.Demo/Views/CustomNodeView.xaml
new file mode 100644
index 0000000..494fa5e
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/CustomNodeView.xaml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/CustomNodeView.xaml.cs b/AIStudio.Wpf.DiagramDesigner.Demo/Views/CustomNodeView.xaml.cs
new file mode 100644
index 0000000..d98a832
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/CustomNodeView.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
+{
+ ///
+ /// CustomNodeView.xaml 的交互逻辑
+ ///
+ public partial class CustomNodeView : UserControl
+ {
+ public CustomNodeView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/DragAndDropView.xaml b/AIStudio.Wpf.DiagramDesigner.Demo/Views/DragAndDropView.xaml
index 08217c7..95744d1 100644
--- a/AIStudio.Wpf.DiagramDesigner.Demo/Views/DragAndDropView.xaml
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/DragAndDropView.xaml
@@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
- xmlns:local="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo.Views"
+ xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
@@ -25,6 +25,8 @@
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/FlowchartEditorView.xaml b/AIStudio.Wpf.DiagramDesigner.Demo/Views/FlowchartEditorView.xaml
index 1e29b3e..424ada0 100644
--- a/AIStudio.Wpf.DiagramDesigner.Demo/Views/FlowchartEditorView.xaml
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/FlowchartEditorView.xaml
@@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
- xmlns:local="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo.Views"
+ xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
@@ -45,5 +45,7 @@
Users="{Binding Users}"
Roles="{Binding Roles}">
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/LockedView.xaml b/AIStudio.Wpf.DiagramDesigner.Demo/Views/LockedView.xaml
new file mode 100644
index 0000000..797dff6
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/LockedView.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/LockedView.xaml.cs b/AIStudio.Wpf.DiagramDesigner.Demo/Views/LockedView.xaml.cs
new file mode 100644
index 0000000..8a1e7af
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/LockedView.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
+{
+ ///
+ /// LockedView.xaml 的交互逻辑
+ ///
+ public partial class LockedView : UserControl
+ {
+ public LockedView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/PerformanceView.xaml b/AIStudio.Wpf.DiagramDesigner.Demo/Views/PerformanceView.xaml
new file mode 100644
index 0000000..663c4ec
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/PerformanceView.xaml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/PerformanceView.xaml.cs b/AIStudio.Wpf.DiagramDesigner.Demo/Views/PerformanceView.xaml.cs
new file mode 100644
index 0000000..9f8e01f
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/PerformanceView.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
+{
+ ///
+ /// PerformanceView.xaml 的交互逻辑
+ ///
+ public partial class PerformanceView : UserControl
+ {
+ public PerformanceView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/SimpleView.xaml b/AIStudio.Wpf.DiagramDesigner.Demo/Views/SimpleView.xaml
index f090c77..57baa6d 100644
--- a/AIStudio.Wpf.DiagramDesigner.Demo/Views/SimpleView.xaml
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/SimpleView.xaml
@@ -4,11 +4,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
- xmlns:local="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo.Views"
+ xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
-
+
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/SnapToGridView.xaml b/AIStudio.Wpf.DiagramDesigner.Demo/Views/SnapToGridView.xaml
new file mode 100644
index 0000000..b302322
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/SnapToGridView.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/Views/SnapToGridView.xaml.cs b/AIStudio.Wpf.DiagramDesigner.Demo/Views/SnapToGridView.xaml.cs
new file mode 100644
index 0000000..fd1c57f
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Demo/Views/SnapToGridView.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
+{
+ ///
+ /// SnapToGridView.xaml 的交互逻辑
+ ///
+ public partial class SnapToGridView : UserControl
+ {
+ public SnapToGridView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner/Models/ToolBoxData.cs b/AIStudio.Wpf.DiagramDesigner/Models/ToolBoxData.cs
index b0d1190..333a6e7 100644
--- a/AIStudio.Wpf.DiagramDesigner/Models/ToolBoxData.cs
+++ b/AIStudio.Wpf.DiagramDesigner/Models/ToolBoxData.cs
@@ -8,17 +8,45 @@ namespace AIStudio.Wpf.DiagramDesigner
{
public class ToolBoxData
{
- public string Text { get; protected set; }
- public string Icon { get; protected set; }
- public Type Type { get; protected set; }
- public IColorViewModel ColorViewModel { get; set; }
- public double Width { get; set; }
- public double Height { get; set; }
- public Size? DesiredSize{ get; set; }
+ public string Text
+ {
+ get; protected set;
+ }
+ public string Icon
+ {
+ get; protected set;
+ }
+ public Type Type
+ {
+ get; protected set;
+ }
+ public IColorViewModel ColorViewModel
+ {
+ get; set;
+ }
+ public double Width
+ {
+ get; set;
+ }
+ public double Height
+ {
+ get; set;
+ }
+ public Size? DesiredSize
+ {
+ get; set;
+ }
+ public string Description
+ {
+ get; set;
+ }
- public object Addition { get; set; }
+ public object Addition
+ {
+ get; set;
+ }
- public ToolBoxData(string text, string icon, Type type, double width, double height, Size? desiredSize = null)
+ public ToolBoxData(string text, string icon, Type type, double width, double height, Size? desiredSize = null, string description = null)
{
this.Text = text;
this.Icon = icon;
@@ -27,6 +55,7 @@ namespace AIStudio.Wpf.DiagramDesigner
this.Height = height;
this.DesiredSize = desiredSize;
this.ColorViewModel = new ColorViewModel();
+ this.Description = description;
}
}
}
diff --git a/AIStudio.Wpf.DiagramDesigner/Styles/TextBox.xaml b/AIStudio.Wpf.DiagramDesigner/Styles/TextBox.xaml
new file mode 100644
index 0000000..78e5a8d
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner/Styles/TextBox.xaml
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner/Themes/DesignerItem.xaml b/AIStudio.Wpf.DiagramDesigner/Themes/DesignerItem.xaml
index 3058a4b..c13e960 100644
--- a/AIStudio.Wpf.DiagramDesigner/Themes/DesignerItem.xaml
+++ b/AIStudio.Wpf.DiagramDesigner/Themes/DesignerItem.xaml
@@ -15,6 +15,12 @@
+
+
+
+
+
+
diff --git a/AIStudio.Wpf.DiagramDesigner/Themes/Generic.xaml b/AIStudio.Wpf.DiagramDesigner/Themes/Generic.xaml
index 9d0778d..acb5fa8 100644
--- a/AIStudio.Wpf.DiagramDesigner/Themes/Generic.xaml
+++ b/AIStudio.Wpf.DiagramDesigner/Themes/Generic.xaml
@@ -9,5 +9,14 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml b/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml
index 6a38c87..528864d 100644
--- a/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml
+++ b/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml
@@ -316,21 +316,41 @@
VerticalAlignment="Center"
HorizontalAlignment="Left"
Visibility="{Binding Path=ShowConnectors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}" />
+
+
+
+
@@ -523,7 +543,7 @@
-
+
diff --git a/AIStudio.Wpf.DiagramDesigner/UserControls/TextControl.xaml b/AIStudio.Wpf.DiagramDesigner/UserControls/TextControl.xaml
index e403856..4f548d6 100644
--- a/AIStudio.Wpf.DiagramDesigner/UserControls/TextControl.xaml
+++ b/AIStudio.Wpf.DiagramDesigner/UserControls/TextControl.xaml
@@ -7,59 +7,15 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
-
-
-
-
+
+
+
+
+
+
+
+
+
+ Style="{StaticResource WaterTextBoxWithEffect}" IsReadOnly="True">
+ Style="{StaticResource WaterTextBoxWithEffect}" Visibility="Collapsed">
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/ConnectionViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/ConnectionViewModel.cs
index a776eff..e7e4342 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/ConnectionViewModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/ConnectionViewModel.cs
@@ -23,6 +23,11 @@ namespace AIStudio.Wpf.DiagramDesigner
Init(sourceConnectorInfo, sinkConnectorInfo);
}
+ public ConnectionViewModel(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode drawMode = DrawMode.ConnectingLineSmooth, RouterMode routerMode = AIStudio.Wpf.DiagramDesigner.RouterMode.RouterNormal) : this(null, sourceConnectorInfo, sinkConnectorInfo, drawMode, routerMode)
+ {
+
+ }
+
public ConnectionViewModel(IDiagramViewModel root, FullyCreatedConnectorInfo sourceConnectorInfo, FullyCreatedConnectorInfo sinkConnectorInfo, ConnectionItem designer) : base(root, designer)
{
PathMode = designer.PathMode;
@@ -31,11 +36,6 @@ namespace AIStudio.Wpf.DiagramDesigner
Init(sourceConnectorInfo, sinkConnectorInfo);
}
- public ConnectionViewModel(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode drawMode, RouterMode routerMode) : this(null, sourceConnectorInfo, sinkConnectorInfo, drawMode, routerMode)
- {
-
- }
-
public override SelectableItemBase GetSerializableObject()
{
if (IsFullConnection)
@@ -56,7 +56,7 @@ namespace AIStudio.Wpf.DiagramDesigner
if (Root != null && Root.ColorViewModel != null)
{
- this.ColorViewModel = CopyHelper.Mapper(Root.ColorViewModel);
+ this.ColorViewModel = CopyHelper.Mapper(Root.ColorViewModel);
}
this.ColorViewModel.FillColor.Color = Colors.Red;
if (sinkConnectorInfo is FullyCreatedConnectorInfo sink && sink.DataItem.ShowArrow == false)
@@ -74,9 +74,9 @@ namespace AIStudio.Wpf.DiagramDesigner
this.SourceConnectorInfo = sourceConnectorInfo;
this.SinkConnectorInfo = sinkConnectorInfo;
- DeleteConnectionCommand = new SimpleCommand(DeleteConnection);
- AddVertexCommand = new SimpleCommand(AddVertex);
- AddLabelCommand = new SimpleCommand(AddLabel);
+ DeleteConnectionCommand = new SimpleCommand(Command_Enable, DeleteConnection);
+ AddVertexCommand = new SimpleCommand(Command_Enable, AddVertex);
+ AddLabelCommand = new SimpleCommand(Command_Enable, AddLabel);
}
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
@@ -88,7 +88,7 @@ namespace AIStudio.Wpf.DiagramDesigner
Vertices = new ObservableCollection(designer.Vertices.Select(p => new ConnectorVertexModel(this.Root, this, designer)));
Labels = new ObservableCollection(designer.Labels.Select(p => new ConnectorLabelModel(this.Root, this, designer)));
}
- }
+ }
#region 属性
private string _text;
@@ -300,7 +300,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
-
+
private LineAnimation _lineAnimation = LineAnimation.None;
[Browsable(true)]
[CanDo]
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorLabelModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorLabelModel.cs
index b5370f6..281c3ea 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorLabelModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorLabelModel.cs
@@ -35,7 +35,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
base.Init();
- DeleteLabelCommand = new SimpleCommand(DeleteLabel);
+ DeleteLabelCommand = new SimpleCommand(Command_Enable, DeleteLabel);
}
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorVertexModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorVertexModel.cs
index 252e69d..2ecb7d8 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorVertexModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorVertexModel.cs
@@ -32,7 +32,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
base.Init();
- DeleteVertexCommand = new SimpleCommand(DeleteVertex);
+ DeleteVertexCommand = new SimpleCommand(Command_Enable, DeleteVertex);
}
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/FullyCreatedConnectorInfo.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/FullyCreatedConnectorInfo.cs
index fdfa952..2db23f5 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/FullyCreatedConnectorInfo.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/FullyCreatedConnectorInfo.cs
@@ -50,8 +50,8 @@ namespace AIStudio.Wpf.DiagramDesigner
base.Init();
menuOptions = new List();
- MenuItemCommand = new SimpleCommand(ExecuteMenuItemCommand);
- DeleteCommand = new SimpleCommand(ExecuteDeleteCommand);
+ MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand);
+ DeleteCommand = new SimpleCommand(Command_Enable, ExecuteDeleteCommand);
}
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs
index 9756073..8e841df 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs
@@ -68,22 +68,66 @@ namespace AIStudio.Wpf.DiagramDesigner
#region 属性
public FullyCreatedConnectorInfo TopConnector
{
- get { return (connectors != null && connectors.Count >= 1) ? connectors[0] : null; }
+ get
+ {
+ return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.Top);
+ }
}
public FullyCreatedConnectorInfo BottomConnector
{
- get { return (connectors != null && connectors.Count >= 2) ? connectors[1] : null; }
+ get
+ {
+ return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.Bottom);
+ }
}
public FullyCreatedConnectorInfo LeftConnector
{
- get { return (connectors != null && connectors.Count >= 3) ? connectors[2] : null; }
+ get
+ {
+ return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.Left);
+ }
}
public FullyCreatedConnectorInfo RightConnector
{
- get { return (connectors != null && connectors.Count >= 4) ? connectors[3] : null; }
+ get
+ {
+ return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.Right);
+ }
+ }
+
+ public FullyCreatedConnectorInfo TopLeftConnector
+ {
+ get
+ {
+ return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.TopLeft);
+ }
+ }
+
+ public FullyCreatedConnectorInfo TopRightConnector
+ {
+ get
+ {
+ return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.TopRight);
+ }
+ }
+
+ public FullyCreatedConnectorInfo BottomLeftConnector
+ {
+ get
+ {
+ return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.BottomLeft);
+ }
+ }
+
+ public FullyCreatedConnectorInfo BottomRightConnector
+ {
+ get
+ {
+ return connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.BottomRight);
+ }
}
public Style ConnectorStyle
@@ -244,7 +288,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
- [CanDo]
+ [CanDo]
public PointBase TopLeft
{
get
@@ -317,13 +361,28 @@ namespace AIStudio.Wpf.DiagramDesigner
///
/// 连接点是否可以按偏移自定义
///
- public bool IsInnerConnector { get; set; }
+ public bool IsInnerConnector
+ {
+ get; set;
+ }
- private ObservableCollection connectors = new ObservableCollection();
- public IEnumerable Connectors { get { return connectors; } }
+ protected ObservableCollection connectors = new ObservableCollection();
+ public IEnumerable Connectors
+ {
+ get
+ {
+ return connectors;
+ }
+ }
protected ObservableCollection menuOptions;
- public IEnumerable MenuOptions { get { return menuOptions; } }
+ public IEnumerable MenuOptions
+ {
+ get
+ {
+ return menuOptions;
+ }
+ }
public bool ShowMenuOptions
{
@@ -336,7 +395,10 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
- public bool BeginDo { get; set; }
+ public bool BeginDo
+ {
+ get; set;
+ }
public IObservable WhenConnectorsChanged
{
@@ -415,7 +477,7 @@ namespace AIStudio.Wpf.DiagramDesigner
this.Top = (int)(this.Top / Root.GridCellSize.Height) * Root.GridCellSize.Height + Root.GridMarginSize.Height + (Root.GridCellSize.Height - this.ItemHeight);
}
}
- }
+ }
}
public void RaiseTopLeft()
@@ -443,7 +505,7 @@ namespace AIStudio.Wpf.DiagramDesigner
var rightPort = RightConnector;
var bottomPort = BottomConnector;
- var left = leftPort == null ? Position.X: Math.Min(Position.X, leftPort.Position.X);
+ var left = leftPort == null ? Position.X : Math.Min(Position.X, leftPort.Position.X);
var top = topPort == null ? Position.Y : Math.Min(Position.Y, topPort.Position.Y);
var right = rightPort == null ? Position.X + ItemWidth :
Math.Max(rightPort.Position.X + rightPort.ConnectorWidth, Position.X + ItemWidth);
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/SelectableDesignerItemViewModelBase.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/SelectableDesignerItemViewModelBase.cs
index 7b86ab7..6380556 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/SelectableDesignerItemViewModelBase.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/SelectableDesignerItemViewModelBase.cs
@@ -42,8 +42,13 @@ namespace AIStudio.Wpf.DiagramDesigner
{
base.Init();
- SelectItemCommand = new SimpleCommand(ExecuteSelectItemCommand);
- EditCommand = new SimpleCommand(ExecuteEditCommand);
+ SelectItemCommand = new SimpleCommand(Command_Enable, ExecuteSelectItemCommand);
+ EditCommand = new SimpleCommand(Command_Enable, ExecuteEditCommand);
+ }
+
+ protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
+ {
+ base.LoadDesignerItemViewModel(root, designerbase);
}
public virtual bool InitData()
@@ -62,7 +67,29 @@ namespace AIStudio.Wpf.DiagramDesigner
public ICommand EditCommand
{
get; private set;
- }
+ }
+
+ private bool _isSelected;
+ [Browsable(false)]
+ public override bool IsSelected
+ {
+ get
+ {
+ return _isSelected;
+ }
+ set
+ {
+ if (SetProperty(ref _isSelected, value))
+ {
+ //如果没有文字,失去焦点自动清除
+ if (_isSelected == false && string.IsNullOrEmpty(Text))
+ {
+ ShowText = false;
+ }
+ }
+
+ }
+ }
private string _text;
[Browsable(true)]
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/SelectableViewModelBase.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/SelectableViewModelBase.cs
index 46e6e93..d61c81f 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/SelectableViewModelBase.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/SelectableViewModelBase.cs
@@ -261,6 +261,11 @@ namespace AIStudio.Wpf.DiagramDesigner
}
+ protected bool Command_Enable(object para)
+ {
+ return IsReadOnly == false;
+ }
+
private void FontViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "FontCase")
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/DefaultDesignerItemViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/DefaultDesignerItemViewModel.cs
new file mode 100644
index 0000000..0594d4d
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/DefaultDesignerItemViewModel.cs
@@ -0,0 +1,31 @@
+using System;
+using AIStudio.Wpf.DiagramDesigner;
+using AIStudio.Wpf.DiagramDesigner.Models;
+using AIStudio.Wpf.DiagramDesigner.Services;
+
+namespace AIStudio.Wpf.DiagramDesigner
+{
+ public class DefaultDesignerItemViewModel : DesignerItemViewModelBase
+ {
+ public DefaultDesignerItemViewModel() : base()
+ {
+
+ }
+
+ public DefaultDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
+ {
+
+ }
+
+ public DefaultDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
+ {
+
+ }
+
+ public override SelectableItemBase GetSerializableObject()
+ {
+ return new DesignerItemBase(this);
+ }
+
+ }
+}
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/GifImageItemViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/GifImageItemViewModel.cs
index 0ea7e50..98263fd 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/GifImageItemViewModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/GifImageItemViewModel.cs
@@ -43,8 +43,8 @@ namespace AIStudio.Wpf.DiagramDesigner
protected override void Init()
{
- AddItemCommand = new SimpleCommand(ExecuteAddItemCommand);
- ImageSwitchCommand = new SimpleCommand(ExecuteImageSwitchCommand);
+ AddItemCommand = new SimpleCommand(Command_Enable, ExecuteAddItemCommand);
+ ImageSwitchCommand = new SimpleCommand(Command_Enable, ExecuteImageSwitchCommand);
base.Init();
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/ImageItemViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/ImageItemViewModel.cs
index 9785077..a671a34 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/ImageItemViewModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/ImageItemViewModel.cs
@@ -141,7 +141,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
get
{
- return this._menuItemCommand ?? (this._menuItemCommand = new SimpleCommand(ExecuteMenuItemCommand));
+ return this._menuItemCommand ?? (this._menuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand));
}
}
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/LogicalGateItemViewModelBase.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/LogicalGateItemViewModelBase.cs
index d7dda35..1dfd2fb 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/LogicalGateItemViewModelBase.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/LogicalGateItemViewModelBase.cs
@@ -93,8 +93,8 @@ namespace AIStudio.Wpf.DiagramDesigner
{
ShowRotate = false;
ShowArrow = false;
- AddInputCommand = new SimpleCommand(para => ExecuteAddInput(para));
- AddOutputCommand = new SimpleCommand(para => ExecuteAddOutput(para));
+ AddInputCommand = new SimpleCommand(Command_Enable, para => ExecuteAddInput(para));
+ AddOutputCommand = new SimpleCommand(Command_Enable, para => ExecuteAddOutput(para));
base.Init();
}
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/MediaItemViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/MediaItemViewModel.cs
index f447a10..b351bb4 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/MediaItemViewModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/MediaItemViewModel.cs
@@ -69,7 +69,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
get
{
- return this._menuItemCommand ?? (this._menuItemCommand = new SimpleCommand(ExecuteMenuItemCommand));
+ return this._menuItemCommand ?? (this._menuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand));
}
}
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/ShapeDesignerItemViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/ShapeDesignerItemViewModel.cs
index e534165..50d387d 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/ShapeDesignerItemViewModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/SimpleViewModel/ShapeDesignerItemViewModel.cs
@@ -87,7 +87,7 @@ namespace AIStudio.Wpf.DiagramDesigner
protected override void Init()
{
- MenuItemCommand = new SimpleCommand(ExecuteMenuItemCommand);
+ MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand);
base.Init();
this.ClearConnectors();
diff --git a/AIStudio.Wpf.Logical/ViewModels/LogicalGateItemViewModel.cs b/AIStudio.Wpf.Logical/ViewModels/LogicalGateItemViewModel.cs
index 45c9ae5..959c476 100644
--- a/AIStudio.Wpf.Logical/ViewModels/LogicalGateItemViewModel.cs
+++ b/AIStudio.Wpf.Logical/ViewModels/LogicalGateItemViewModel.cs
@@ -874,7 +874,7 @@ namespace AIStudio.Wpf.Logical.ViewModels
protected override void Init()
{
- MenuItemCommand = new SimpleCommand(ExecuteMenuItemCommand);
+ MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand);
base.Init();
readDataTimer.Elapsed += timeCycle;