115 Commits

Author SHA1 Message Date
艾竹
a3779bd523 !4 20230424
Merge pull request !4 from 艾竹/master
2023-04-24 13:51:29 +00:00
艾竹
dea5a5341c !3 connect
Merge pull request !3 from 艾竹/dev
2023-04-24 13:49:47 +00:00
kwai
d38f11e758 connect 2023-04-24 20:10:17 +08:00
艾竹
e5d187d8c8 If 2023-04-23 22:44:15 +08:00
艾竹
1cef64c7c8 开发中的功能注释掉 2023-04-23 21:45:08 +08:00
艾竹
997ccde257 !2 自动合并
Merge pull request !2 from 艾竹/dev
2023-04-23 08:45:25 +00:00
艾竹
fe8ecdfc32 !1 C# retrieving the com class factory 80040154
Merge pull request !1 from 艾竹/master
2023-04-23 08:43:51 +00:00
艾竹
9a39d6caf8 Merge branch 'dev' of gitee.com:akwkevin/aistudio.-wpf.-diagram into master
Signed-off-by: 艾竹 <akwkevin@126.com>
2023-04-23 08:43:34 +00:00
”Jabin章志朋“
af5ac77496 test zzpaaa 2023-04-23 16:39:37 +08:00
”Jabin章志朋“
ff012a1380 test txt 2023-04-23 16:33:53 +08:00
”Jabin章志朋“
f7f05a002f Merge branch 'master' of https://gitee.com/akwkevin/aistudio.-wpf.-diagram 2023-04-23 16:29:04 +08:00
”Jabin章志朋“
3605ce9223 AIStudio.Wpf.DiagramDesigner的UserControls文件夹下的DiagramControl的201行添加基础图形上下左右按钮控件 2023-04-23 16:25:01 +08:00
艾竹
bd1741b572 update README.md.
Signed-off-by: 艾竹 <akwkevin@126.com>
2023-04-23 07:52:02 +00:00
”Jabin章志朋“
77932a4175 test git demo 2023-04-23 15:07:31 +08:00
艾竹
13cede06cf 1.1.4 2023-04-22 22:40:41 +08:00
艾竹
5963c2c29f 1.1.1 2023-04-22 21:08:01 +08:00
艾竹
21467e26f5 1.1.1 2023-04-22 21:06:52 +08:00
艾竹
dfc299689a Demos 2023-04-22 12:41:26 +08:00
艾竹
87f31fa79d Demos 2023-04-22 12:41:15 +08:00
艾竹
f8340b5885 添加逻辑节点支持字符串值 2023-04-19 22:26:04 +08:00
艾竹
451df2d5de 控件重名冲突 2023-04-18 22:38:20 +08:00
艾竹
033bebb6bc 支持到6.0 2023-04-16 23:32:55 +08:00
艾竹
81f91f3f35 项目结构调整 2023-04-16 20:11:40 +08:00
艾竹
cbfbf96033 Boundary画线算法,精度导致的问题修复 2023-04-16 14:56:53 +08:00
艾竹
4b8a03afb6 审批序列化 2023-04-16 12:21:51 +08:00
艾竹
5dee3a9907 修复一个sfc的bug 2023-04-16 10:10:12 +08:00
艾竹
f05654309b SFC报错修复 2023-04-15 23:42:36 +08:00
艾竹
488e23ea57 使用设计模式优化一下逻辑图 2023-04-15 23:32:29 +08:00
艾竹
c6bc57140f 查找与替换完成 2023-04-15 21:55:27 +08:00
艾竹
ce2e44fe49 PropertyChanged使用基类的,各个类不在自己定义 2023-04-10 23:08:14 +08:00
艾竹
429d7b1e24 截屏嵌入,查找待优化 2023-04-09 21:48:26 +08:00
艾竹
21009fc383 整理 2023-04-09 18:58:13 +08:00
艾竹
fae7826577 ReDo Undo Item ItemWidth 和 Angle 等工具栏设置完成 2023-04-09 12:38:57 +08:00
艾竹
2ef5b7a1ed 颜色,字体,支持redo undo 2023-04-08 23:38:01 +08:00
艾竹
8ad42aec49 分组,取消分组 ReDo UnDo 整理 2023-04-08 21:48:43 +08:00
艾竹
fa96573cbd 继续整理 2023-04-08 18:08:00 +08:00
艾竹
2edb4ffb14 动画bug修复 2023-04-08 17:28:38 +08:00
艾竹
5e7dd6c5e5 连接线,文本编辑 2023-04-08 14:37:07 +08:00
艾竹
a0485601c1 补充提交 2023-04-08 14:28:51 +08:00
艾竹
78da8f4852 最近精简代码,有些bug,修复 2023-04-08 14:22:12 +08:00
kwai
347488e8e9 xx 2023-04-07 19:21:27 +08:00
艾竹
afea559325 ReDo UnDo 继续 2023-04-06 23:01:18 +08:00
艾竹
e0a26a76d2 整理Redo和Undo命令 2023-04-05 23:40:22 +08:00
艾竹
c513bd0f64 Merge branch 'master' of https://gitee.com/akwkevin/aistudio.-wpf.-diagram 2023-04-05 20:36:23 +08:00
艾竹
5935a58541 mind多个根节点的时候,切换模式的修复 2023-04-05 20:35:10 +08:00
艾竹
eccf798818 update README.md.
Signed-off-by: 艾竹 <akwkevin@126.com>
2023-04-05 03:21:59 +00:00
艾竹
f9b9b0fb2d update README.md.
Signed-off-by: 艾竹 <akwkevin@126.com>
2023-04-05 02:59:51 +00:00
艾竹
b3f99f5dfd update README.md.
Signed-off-by: 艾竹 <akwkevin@126.com>
2023-04-05 01:39:15 +00:00
艾竹
0fd8c217f4 update README.md.
Signed-off-by: 艾竹 <akwkevin@126.com>
2023-04-05 01:34:15 +00:00
艾竹
3dc7b25d95 update README.md.
Signed-off-by: 艾竹 <akwkevin@126.com>
2023-04-05 01:15:37 +00:00
艾竹
b04028c893 update README.md.
Signed-off-by: 艾竹 <akwkevin@126.com>
2023-04-05 01:14:51 +00:00
艾竹
88ae871b64 update README.md.
Signed-off-by: 艾竹 <akwkevin@126.com>
2023-04-05 01:12:22 +00:00
艾竹
fccac1da23 几个小bug 2023-04-05 08:57:31 +08:00
艾竹
4c54318b9a bug修复 2023-04-04 22:42:09 +08:00
艾竹
a3fbb2d8ad 序列化bug修复,近期主要修复bug为主 2023-04-02 22:59:22 +08:00
艾竹
7835b422ff 节点导入完成 2023-04-02 21:47:55 +08:00
艾竹
0701f25519 工具栏整理 2023-04-02 12:01:46 +08:00
艾竹
02ebd056b3 xx 2023-03-29 22:55:12 +08:00
艾竹
f80a67ff10 xx 2023-03-29 06:26:16 +08:00
艾竹
ca7abe6fd5 修复一个大bug 2023-03-29 06:26:00 +08:00
艾竹
b4d7f13111 offset修复一半 2023-03-28 23:16:56 +08:00
艾竹
72da084f15 xx 2023-03-28 22:09:24 +08:00
艾竹
43b5d82fae do redo 2023-03-26 23:23:34 +08:00
艾竹
90e94a7ec0 修改内部使用方法,不需要使用页面绑定的命令 2023-03-25 22:29:02 +08:00
艾竹
5e5da021ab mind的拷贝完成 2023-03-25 22:10:49 +08:00
艾竹
b36bd4b228 XX 2023-03-25 11:59:31 +08:00
艾竹
8a2c742ec4 xx 2023-03-24 22:32:42 +08:00
艾竹
5ff4376674 附加信息序列化 2023-03-21 23:08:12 +08:00
艾竹
3c8120aa15 mind集成到diagram app中 2023-03-20 23:01:38 +08:00
kwai
2c6b3cc285 主题还得完善下 2023-03-20 20:23:20 +08:00
艾竹
07ac28965e mind基本完成,准备写文档 2023-03-19 23:26:14 +08:00
艾竹
c2f4d3c706 mind 工具栏 2023-03-19 12:38:08 +08:00
艾竹
8d87f61c07 mind 2023-03-18 22:50:00 +08:00
艾竹
9b3c2633a7 mind 2023-03-18 21:44:58 +08:00
艾竹
d97938cc2b link 2023-03-15 23:05:41 +08:00
kwai
70dac7d41c xx 2023-03-15 19:35:53 +08:00
艾竹
035a725da3 priority 2023-03-13 22:27:00 +08:00
kwai
31872222bc 附加信息准备中 2023-03-13 19:44:30 +08:00
艾竹
414eb28867 工具栏调整下 2023-03-12 23:26:22 +08:00
艾竹
f22d6dd3f1 适应窗口大小完成 2023-03-12 22:47:45 +08:00
艾竹
e2753b0bff 右键拖动画布 2023-03-12 15:26:58 +08:00
艾竹
fb7858fe74 可以切换主题 2023-03-11 22:27:23 +08:00
艾竹
84f413320f 暂存一下 2023-03-11 12:40:44 +08:00
艾竹
5cfb32bb19 mind 工具栏 2023-03-11 10:19:21 +08:00
艾竹
b3c7e1efec mind 2023-03-10 12:09:13 +08:00
艾竹
e4f6335224 mind序列化完善中 2023-03-08 23:02:50 +08:00
kwai
c80923d19c mind 2023-03-08 19:45:07 +08:00
艾竹
f48838f54a Mind 2023-03-07 22:59:27 +08:00
kwai
f042f95ee0 xx 2023-03-07 19:25:19 +08:00
kwai
152c6a8c22 xx 2023-03-06 11:54:41 +08:00
艾竹
cd20abd7fe 可以切换MindType 2023-03-05 23:22:34 +08:00
艾竹
79f4896fbd Mind Editoe 2023-03-05 21:30:53 +08:00
kwai
9061146139 tool 2023-03-03 18:59:02 +08:00
kwai
9966656269 mind 2023-03-01 19:28:06 +08:00
艾竹
84d4035e6d 分离完成 AIStudio.Wpf.DiagramModels 用于对接三分软件的模型 2023-02-28 23:04:16 +08:00
艾竹
a015f9208b Mind准备序列化,准备分离出model库 2023-02-28 22:07:40 +08:00
kwai
511636ebd7 fishbone 2023-02-28 18:53:34 +08:00
艾竹
73176a00d9 这个线有点偏差 2023-02-27 23:18:31 +08:00
kwai
6464cad46e xx 2023-02-27 20:19:08 +08:00
kwai
f8c2115f03 xx 2023-02-27 20:18:58 +08:00
艾竹
298ec29dd9 写不动了,休息。 2023-02-22 23:01:22 +08:00
kwai
3a744ecaf7 xx 2023-02-22 19:50:00 +08:00
艾竹
6d1f2a83fa 调试中 2023-02-21 23:23:03 +08:00
kwai
c227076076 结构调整 2023-02-21 19:47:46 +08:00
艾竹
71ed33f881 mind继续 2023-02-20 23:01:26 +08:00
艾竹
58c18db12f 添加附加信息 2023-02-19 23:20:02 +08:00
艾竹
c053396fa0 mind 两个布局完成 2023-02-19 22:56:47 +08:00
艾竹
ca1ac13a1f mind 有点样子了 2023-02-19 21:38:28 +08:00
艾竹
08a4fddfdc 嗯,自动获取曲线方向 2023-02-16 23:02:43 +08:00
kwai
968adb0635 mind 进行中 2023-02-16 19:21:37 +08:00
艾竹
debd7e711d 内部基础ZoomBox 2023-02-14 22:54:55 +08:00
艾竹
3ef7434f5b ZoomBox 完成 2023-02-14 22:15:19 +08:00
艾竹
38cb0fae85 暂存一下 2023-02-14 21:55:42 +08:00
kwai
d6e84d40c0 临时提交 2023-02-14 18:58:26 +08:00
艾竹
dfe76438c2 ZoomBox待完成,还需要调整 2023-02-13 22:50:50 +08:00
2414 changed files with 26027 additions and 10155 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

View File

@@ -1,15 +1,15 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31727.386
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.Flowchart", "AIStudio.Wpf.Flowchart\AIStudio.Wpf.Flowchart.csproj", "{86ED5B40-D185-4AFA-B5BD-BC8E78DB8758}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.Flowchart", "Extensions\AIStudio.Wpf.Flowchart\AIStudio.Wpf.Flowchart.csproj", "{86ED5B40-D185-4AFA-B5BD-BC8E78DB8758}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.Logical", "AIStudio.Wpf.Logical\AIStudio.Wpf.Logical.csproj", "{CC68D39D-7935-4079-9CEB-FC2FD498D511}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.Logical", "Extensions\AIStudio.Wpf.Logical\AIStudio.Wpf.Logical.csproj", "{CC68D39D-7935-4079-9CEB-FC2FD498D511}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{4959F170-02FB-4B7F-8F53-93DAF22713F9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.SFC", "AIStudio.Wpf.SFC\AIStudio.Wpf.SFC.csproj", "{2AB69067-277E-4EE0-9949-8326A145EEE4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.SFC", "Extensions\AIStudio.Wpf.SFC\AIStudio.Wpf.SFC.csproj", "{2AB69067-277E-4EE0-9949-8326A145EEE4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.DiagramApp", "AIStudio.Wpf.DiagramApp\AIStudio.Wpf.DiagramApp.csproj", "{4408F718-9C14-4404-A63B-9B785F9D4F35}"
EndProject
@@ -19,15 +19,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Directory.Build.Props = Directory.Build.Props
test-zzp.txt = test-zzp.txt
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.DiagramDesigner.Demo", "AIStudio.Wpf.DiagramDesigner.Demo\AIStudio.Wpf.DiagramDesigner.Demo.csproj", "{D0467F47-D782-4A84-9AAE-E4A014913AA6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2BE1891E-16C9-4191-998A-45AEEEEA1F0D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.DiagramDesigner.Additionals", "AIStudio.Wpf.DiagramDesigner.Additionals\AIStudio.Wpf.DiagramDesigner.Additionals.csproj", "{186F34AC-4BC5-40E1-911B-DD3E96AECE6E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AIStudio.Wpf.Mind", "AIStudio.Wpf.Mind\AIStudio.Wpf.Mind.csproj", "{85C437B9-16D2-4076-ABCD-52029AC232FC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.Mind", "Extensions\AIStudio.Wpf.Mind\AIStudio.Wpf.Mind.csproj", "{85C437B9-16D2-4076-ABCD-52029AC232FC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.DiagramDesigner.Serializable", "AIStudio.Wpf.DiagramDesigner.Serializable\AIStudio.Wpf.DiagramDesigner.Serializable.csproj", "{439D0631-D9C2-4D36-BFCE-80DFCCABE9E7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demos", "Demos", "{62DC8608-D98F-47BB-9F19-ABB0C60B72FF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.DiagramDesigner.Demo", "Demos\AIStudio.Wpf.DiagramDesigner.Demo\AIStudio.Wpf.DiagramDesigner.Demo.csproj", "{FCFC5ABF-8459-4B45-ABA0-9B820C7ED5C6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -55,10 +60,6 @@ Global
{EA1D893D-2F50-47AA-80A6-EA297F651CCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA1D893D-2F50-47AA-80A6-EA297F651CCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA1D893D-2F50-47AA-80A6-EA297F651CCC}.Release|Any CPU.Build.0 = Release|Any CPU
{D0467F47-D782-4A84-9AAE-E4A014913AA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D0467F47-D782-4A84-9AAE-E4A014913AA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0467F47-D782-4A84-9AAE-E4A014913AA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D0467F47-D782-4A84-9AAE-E4A014913AA6}.Release|Any CPU.Build.0 = Release|Any CPU
{186F34AC-4BC5-40E1-911B-DD3E96AECE6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{186F34AC-4BC5-40E1-911B-DD3E96AECE6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{186F34AC-4BC5-40E1-911B-DD3E96AECE6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -67,6 +68,14 @@ Global
{85C437B9-16D2-4076-ABCD-52029AC232FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85C437B9-16D2-4076-ABCD-52029AC232FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85C437B9-16D2-4076-ABCD-52029AC232FC}.Release|Any CPU.Build.0 = Release|Any CPU
{439D0631-D9C2-4D36-BFCE-80DFCCABE9E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{439D0631-D9C2-4D36-BFCE-80DFCCABE9E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{439D0631-D9C2-4D36-BFCE-80DFCCABE9E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{439D0631-D9C2-4D36-BFCE-80DFCCABE9E7}.Release|Any CPU.Build.0 = Release|Any CPU
{FCFC5ABF-8459-4B45-ABA0-9B820C7ED5C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCFC5ABF-8459-4B45-ABA0-9B820C7ED5C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCFC5ABF-8459-4B45-ABA0-9B820C7ED5C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCFC5ABF-8459-4B45-ABA0-9B820C7ED5C6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -76,6 +85,7 @@ Global
{CC68D39D-7935-4079-9CEB-FC2FD498D511} = {4959F170-02FB-4B7F-8F53-93DAF22713F9}
{2AB69067-277E-4EE0-9949-8326A145EEE4} = {4959F170-02FB-4B7F-8F53-93DAF22713F9}
{85C437B9-16D2-4076-ABCD-52029AC232FC} = {4959F170-02FB-4B7F-8F53-93DAF22713F9}
{FCFC5ABF-8459-4B45-ABA0-9B820C7ED5C6} = {62DC8608-D98F-47BB-9F19-ABB0C60B72FF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D30FC641-F06C-4E35-AEA5-48A9B6E59CE0}

View File

@@ -109,6 +109,11 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="AIStudio.Wpf.ComeCapture" Version="1.1.0" />
<PackageReference Include="Costura.Fody" Version="5.7.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Dragablz" Version="0.0.3.223" />
<PackageReference Include="Fluent.Ribbon" Version="8.0.3" />
<PackageReference Include="gong-wpf-dragdrop" Version="2.3.2" />
@@ -121,11 +126,12 @@
<ItemGroup>
<ProjectReference Include="..\AIStudio.Wpf.DiagramDesigner.Additionals\AIStudio.Wpf.DiagramDesigner.Additionals.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.DiagramDesigner.Serializable\AIStudio.Wpf.DiagramDesigner.Serializable.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.DiagramDesigner\AIStudio.Wpf.DiagramDesigner.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.Flowchart\AIStudio.Wpf.Flowchart.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.Logical\AIStudio.Wpf.Logical.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.Mind\AIStudio.Wpf.Mind.csproj" />
<ProjectReference Include="..\AIStudio.Wpf.SFC\AIStudio.Wpf.SFC.csproj" />
<ProjectReference Include="..\Extensions\AIStudio.Wpf.Flowchart\AIStudio.Wpf.Flowchart.csproj" />
<ProjectReference Include="..\Extensions\AIStudio.Wpf.Logical\AIStudio.Wpf.Logical.csproj" />
<ProjectReference Include="..\Extensions\AIStudio.Wpf.Mind\AIStudio.Wpf.Mind.csproj" />
<ProjectReference Include="..\Extensions\AIStudio.Wpf.SFC\AIStudio.Wpf.SFC.csproj" />
</ItemGroup>
<ItemGroup>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -13,6 +13,7 @@
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Logical;component/Themes/LogicalGateItemViewModel.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.SFC;component/Themes/SFCNode.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Themes/MindNode.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Themes/Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

View File

@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
</Weavers>

View File

@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if runtime assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseRuntimeReferencePaths" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCleanup" type="xs:boolean">
<xs:annotation>
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@@ -17,13 +17,13 @@ namespace AIStudio.Wpf.Flowchart
{
public FlowchartViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
}
public FlowchartViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
if (DiagramViewModel != null)
{
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectionViewModel>().ToList(), DiagramViewModel);
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectionViewModel>().ToList(), DiagramViewModel, false);
}
_service.DrawModeViewModel.LineDrawMode = DrawMode.ConnectingLineSmooth;
}
@@ -39,73 +39,92 @@ namespace AIStudio.Wpf.Flowchart
_service.DrawModeViewModel.LineDrawMode = DrawMode.ConnectingLineSmooth;
}
protected override void Init()
protected override void Init(bool initNew)
{
base.Init();
base.Init(initNew);
DesignerItemViewModelBase start = new StartFlowNode() { Left = 100, Top = 0, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString() };
DiagramViewModel.DirectAddItemCommand.Execute(start);
DesignerItemViewModelBase start = new StartFlowNode() { Left = 100, Top = 0, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString() };
DiagramViewModel.Add(start);
DesignerItemViewModelBase middle1 = new MiddleFlowNode() { Left = 100, Top = 100, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString(), Text = "主管审批", UserIds= new List<string> { "操作员1", "操作员2" }, ActType = "or" };
DiagramViewModel.DirectAddItemCommand.Execute(middle1);
DesignerItemViewModelBase middle1 = new MiddleFlowNode() { Left = 100, Top = 100, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "主管审批", UserIds= new List<string> { "操作员1", "操作员2" }, ActType = "or", SimulateApprove = true };
DiagramViewModel.Add(middle1);
DesignerItemViewModelBase decide = new DecideFlowNode() { Left = 100, Top = 200, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString(), Text = "5" };
DiagramViewModel.DirectAddItemCommand.Execute(decide);
DesignerItemViewModelBase decide = new DecideFlowNode() { Left = 100, Top = 200, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "5" };
DiagramViewModel.Add(decide);
DesignerItemViewModelBase middle2 = new MiddleFlowNode() { Left = 200, Top = 300, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString(), Text = "分管领导", UserIds = new List<string> { "操作员1", "操作员2" }, ActType = "and", DoubleApprove = true };
DiagramViewModel.DirectAddItemCommand.Execute(middle2);
DesignerItemViewModelBase middle2 = new MiddleFlowNode() { Left = 200, Top = 300, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "分管领导", UserIds = new List<string> { "操作员1", "操作员2" }, ActType = "and", SimulateApprove = true };
DiagramViewModel.Add(middle2);
DesignerItemViewModelBase cobegin = new COBeginFlowNode() { Left = 100, Top = 400, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString() };
DiagramViewModel.DirectAddItemCommand.Execute(cobegin);
DesignerItemViewModelBase cobegin = new COBeginFlowNode() { Left = 100, Top = 400, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString() };
DiagramViewModel.Add(cobegin);
DesignerItemViewModelBase middle3 = new MiddleFlowNode() { Left = 100, Top = 500, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString(), Text = "财务审批", UserIds = new List<string> { "Admin" }, ActType = "or", DoubleApprove = true };
DiagramViewModel.DirectAddItemCommand.Execute(middle3);
DesignerItemViewModelBase middle3 = new MiddleFlowNode() { Left = 100, Top = 500, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "财务审批", UserIds = new List<string> { "Admin" }, ActType = "or", SimulateApprove = true };
DiagramViewModel.Add(middle3);
DesignerItemViewModelBase middle4 = new MiddleFlowNode() { Left = 200, Top = 500, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString(), Text = "人力审批", RoleIds = new List<string> { "操作员", "管理员" }, ActType = "or", DoubleApprove = true };
DiagramViewModel.DirectAddItemCommand.Execute(middle4);
DesignerItemViewModelBase middle4 = new MiddleFlowNode() { Left = 200, Top = 500, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "人力审批", RoleIds = new List<string> { "操作员", "管理员" }, ActType = "or", SimulateApprove = true };
DiagramViewModel.Add(middle4);
DesignerItemViewModelBase coend = new COEndFlowNode() { Left = 100, Top = 600, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString() };
DiagramViewModel.DirectAddItemCommand.Execute(coend);
DesignerItemViewModelBase coend = new COEndFlowNode() { Left = 100, Top = 600, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString() };
DiagramViewModel.Add(coend);
DesignerItemViewModelBase end = new EndFlowNode() { Left = 100, Top = 700, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString() };
DiagramViewModel.DirectAddItemCommand.Execute(end);
DesignerItemViewModelBase end = new EndFlowNode() { Left = 100, Top = 700, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString() };
DiagramViewModel.Add(end);
ConnectionViewModel connector1 = new ConnectionViewModel(start.BottomConnector, middle1.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
DiagramViewModel.Add(connector1);
ConnectionViewModel connector2 = new ConnectionViewModel(middle1.BottomConnector, decide.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
DiagramViewModel.Add(connector2);
ConnectionViewModel connector3 = new ConnectionViewModel(decide.RightConnector, middle2.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector3);
DiagramViewModel.Add(connector3);
connector3.AddLabel(">=3");
ConnectionViewModel connector4 = new ConnectionViewModel(middle2.BottomConnector, cobegin.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector4);
DiagramViewModel.Add(connector4);
ConnectionViewModel connector5 = new ConnectionViewModel(decide.BottomConnector, cobegin.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector5);
DiagramViewModel.Add(connector5);
connector5.AddLabel("<3");
ConnectionViewModel connector6 = new ConnectionViewModel(cobegin.BottomConnector, middle3.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector6);
DiagramViewModel.Add(connector6);
ConnectionViewModel connector7 = new ConnectionViewModel(cobegin.BottomConnector, middle4.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector7);
DiagramViewModel.Add(connector7);
ConnectionViewModel connector8 = new ConnectionViewModel(middle3.BottomConnector, coend.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector8);
DiagramViewModel.Add(connector8);
ConnectionViewModel connector9 = new ConnectionViewModel(middle4.BottomConnector, coend.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector9);
DiagramViewModel.Add(connector9);
ConnectionViewModel connector10 = new ConnectionViewModel(coend.BottomConnector, end.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector10);
DiagramViewModel.Add(connector10);
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
TextDesignerItemViewModel despcription = new TextDesignerItemViewModel()
{
Name = nameof(despcription),
Left = 260,
Top = 60,
ItemWidth = 300,
ItemHeight = 150,
Text = @"
一个简易的OA审批流程
1.主管审批为or审批任意一个审批即可
2.分管领导为and审批需要审批两次
3.财务审批为or审批任意一个审批即可
4.人力审批为or审批任意一个审批即可
注意:为了模拟审批,双击节点可以进行审批;请双击主管审批、分管领导、财务审批、人力审批、进行效果查看。"
};
despcription.FontViewModel.HorizontalAlignment = HorizontalAlignment.Left;
despcription.FontViewModel.VerticalAlignment = VerticalAlignment.Top;
despcription.FontViewModel.FontColor = Colors.Blue;
DiagramViewModel.Add(despcription);
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectionViewModel>().ToList(), DiagramViewModel);
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectionViewModel>().ToList(), DiagramViewModel, true);
}
public override void Dispose()
{
@@ -113,7 +132,7 @@ namespace AIStudio.Wpf.Flowchart
foreach (var viewModel in DiagramViewModels)
{
FlowchartService.DisposeData(viewModel);
FlowchartService.Dispose(viewModel);
}
}
}

View File

@@ -34,87 +34,85 @@ namespace AIStudio.Wpf.Logical
_service.DrawModeViewModel.LineDrawMode = DrawMode.ConnectingLineSmooth;
}
protected override void Init()
protected override void Init(bool initNew)
{
base.Init();
base.Init(initNew);
TimerDesignerItemViewModel timer = new TimerDesignerItemViewModel() { Left = 28, Top = 28 };
timer.Value = 1;
DiagramViewModel.DirectAddItemCommand.Execute(timer);
DiagramViewModel.Add(timer);
InputItemViewModel in1 = new InputItemViewModel() { Left = 28, Top = 110 };
in1.LinkPoint = LogicalService.LinkPoint[0];
DiagramViewModel.DirectAddItemCommand.Execute(in1);
DiagramViewModel.Add(in1);
InputItemViewModel in2 = new InputItemViewModel() { Left = 28, Top = 300 };
in2.LinkPoint = LogicalService.LinkPoint[1];
DiagramViewModel.DirectAddItemCommand.Execute(in2);
DiagramViewModel.Add(in2);
AddGateItemViewModel item1 = new AddGateItemViewModel() { Left = 178, Top = 160 };
DiagramViewModel.DirectAddItemCommand.Execute(item1);
DiagramViewModel.Add(item1);
ConstantDesignerItemViewModel constant = new ConstantDesignerItemViewModel() { Left = 178, Top = 300, Value = 10 };
DiagramViewModel.DirectAddItemCommand.Execute(constant);
DiagramViewModel.Add(constant);
GTGateItemViewModel gTGate = new GTGateItemViewModel() { Left = 328, Top = 110 };
DiagramViewModel.DirectAddItemCommand.Execute(gTGate);
DiagramViewModel.Add(gTGate);
InputItemViewModel in3 = new InputItemViewModel() { Left = 328, Top = 210 };
in3.LinkPoint = LogicalService.LinkPoint[2];
DiagramViewModel.DirectAddItemCommand.Execute(in3);
DiagramViewModel.Add(in3);
InputItemViewModel in4 = new InputItemViewModel() { Left = 328, Top = 300 };
in4.LinkPoint = LogicalService.LinkPoint[3];
DiagramViewModel.DirectAddItemCommand.Execute(in4);
DiagramViewModel.Add(in4);
SELGateItemViewModel sELGate = new SELGateItemViewModel() { Left = 478, Top = 160 };
DiagramViewModel.DirectAddItemCommand.Execute(sELGate);
DiagramViewModel.Add(sELGate);
OutputItemViewModel out1 = new OutputItemViewModel() { Left = 628, Top = 110 };
out1.LinkPoint = LogicalService.LinkPoint[4];
DiagramViewModel.DirectAddItemCommand.Execute(out1);
DiagramViewModel.Add(out1);
ConnectionViewModel connector1 = new ConnectionViewModel(in1.Output[0], item1.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
connector1.ColorViewModel.FillColor.Color = Colors.Green;
connector1.ColorViewModel.LineAnimation = LineAnimation.PathAnimation;
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
DiagramViewModel.Add(connector1);
ConnectionViewModel connector2 = new ConnectionViewModel(in2.Output[0], item1.Input[1], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
connector2.ColorViewModel.FillColor.Color = Colors.Green;
connector2.ColorViewModel.LineAnimation = LineAnimation.PathAnimation;
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
DiagramViewModel.Add(connector2);
ConnectionViewModel connector3 = new ConnectionViewModel(item1.Output[0], gTGate.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
connector3.ColorViewModel.FillColor.Color = Colors.Green;
connector3.ColorViewModel.LineAnimation = LineAnimation.PathAnimation;
DiagramViewModel.DirectAddItemCommand.Execute(connector3);
DiagramViewModel.Add(connector3);
ConnectionViewModel connector4 = new ConnectionViewModel(constant.Output[0], gTGate.Input[1], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
connector4.ColorViewModel.FillColor.Color = Colors.Green;
connector4.ColorViewModel.LineAnimation = LineAnimation.PathAnimation;
DiagramViewModel.DirectAddItemCommand.Execute(connector4);
DiagramViewModel.Add(connector4);
ConnectionViewModel connector5 = new ConnectionViewModel(gTGate.Output[0], sELGate.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
connector5.ColorViewModel.FillColor.Color = Colors.Green;
connector5.ColorViewModel.LineAnimation = LineAnimation.PathAnimation;
DiagramViewModel.DirectAddItemCommand.Execute(connector5);
DiagramViewModel.Add(connector5);
ConnectionViewModel connector6 = new ConnectionViewModel(in3.Output[0], sELGate.Input[1], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
connector6.ColorViewModel.FillColor.Color = Colors.Green;
connector6.ColorViewModel.LineAnimation = LineAnimation.PathAnimation;
DiagramViewModel.DirectAddItemCommand.Execute(connector6);
DiagramViewModel.Add(connector6);
ConnectionViewModel connector7 = new ConnectionViewModel(in4.Output[0], sELGate.Input[2], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
connector7.ColorViewModel.FillColor.Color = Colors.Green;
connector7.ColorViewModel.LineAnimation = LineAnimation.PathAnimation;
DiagramViewModel.DirectAddItemCommand.Execute(connector7);
DiagramViewModel.Add(connector7);
ConnectionViewModel connector8 = new ConnectionViewModel(sELGate.Output[0], out1.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
connector8.ColorViewModel.FillColor.Color = Colors.Green;
connector8.ColorViewModel.LineAnimation = LineAnimation.PathAnimation;
DiagramViewModel.DirectAddItemCommand.Execute(connector8);
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
DiagramViewModel.Add(connector8);
}
private void Items_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
@@ -171,277 +169,11 @@ namespace AIStudio.Wpf.Logical
{
link.Value = rd.NextDouble() * 10;
}
foreach (var item in DiagramViewModel.Items.OfType<ConstantDesignerItemViewModel>())
{
foreach (var output in item.Output)
{
output.Value.ConnectorValue = item.Value;
output.Value.ColorViewModel.FillColor.Color = Colors.Green;
}
}
foreach (var item in DiagramViewModel.Items.OfType<InputItemViewModel>())
{
if (item.LinkPoint != null)
{
foreach (var output in item.Output)
{
output.Value.ConnectorValue = item.LinkPoint.Value;
output.Value.ColorViewModel.FillColor.Color = Colors.Green;
}
}
}
foreach (var item in DiagramViewModel.Items.OfType<LogicalGateItemViewModelBase>().OrderBy(p => p.OrderNumber))
{
if (item.LogicalType != LogicalType.None)
{
foreach (var input in item.Input)
{
var connector = GetSourceItem(input.Value);
if (connector == null)
{
continue;
}
if (connector.SourceConnectorInfo.DataItem is LogicalGateItemViewModelBase)
{
input.Value.ConnectorValue = (connector.SourceConnectorInfo as LogicalConnectorInfo).ConnectorValue;
input.Value.ColorViewModel.FillColor.Color = connector.SourceConnectorInfo.ColorViewModel.FillColor.Color;
connector.ColorViewModel.LineColor.Color = connector.SourceConnectorInfo.ColorViewModel.FillColor.Color;
connector.ColorViewModel.FillColor.Color = connector.SourceConnectorInfo.ColorViewModel.FillColor.Color;
if (item.LogicalType == LogicalType.Output)
{
input.Value.ValueTypePoint = (connector.SourceConnectorInfo as LogicalConnectorInfo).ValueTypePoint;
}
else if (item.LogicalType == LogicalType.NOT)
{
input.Value.ValueTypePoint = ((connector.SourceConnectorInfo as LogicalConnectorInfo).ValueTypePoint == ValueTypePoint.Bool) ? ValueTypePoint.Bool : ValueTypePoint.Int;
}
}
}
foreach (var output in item.Output)
{
if (item.LogicalType == LogicalType.Output)
{
var first = item.Input.Values.FirstOrDefault();
output.Value.ConnectorValue = first.ConnectorValue;
output.Value.ValueTypePoint = first.ValueTypePoint;
(item as OutputItemViewModel).Value = first.ConnectorValue;
(item as OutputItemViewModel).LinkPoint.Value = first.ConnectorValue;
}
else if (item.LogicalType == LogicalType.ADD)
{
output.Value.ConnectorValue = item.Input.Values.Select(p => p.ConnectorValue).Sum();
}
else if (item.LogicalType == LogicalType.SUB)
{
var first = item.Input.Values.Select(p => p.ConnectorValue).FirstOrDefault();
var second = item.Input.Values.Where((value, index) => index != 0).Select(p => p.ConnectorValue).Sum();
output.Value.ConnectorValue = first - second;
}
else if (item.LogicalType == LogicalType.MUL)
{
double result = 0;
foreach (var input in item.Input.Values)
{
if (result == 0)
{
result = 1;
}
result *= input.ConnectorValue;
}
output.Value.ConnectorValue = result;
}
else if (item.LogicalType == LogicalType.DIV)
{
double result = item.Input.Values.Select(p => p.ConnectorValue).FirstOrDefault();
foreach (var input in item.Input.Values.Where((value, index) => index != 0))
{
result /= input.ConnectorValue;
}
output.Value.ConnectorValue = result;
}
else if (item.LogicalType == LogicalType.AVE)
{
output.Value.ConnectorValue = item.Input.Values.Select(p => p.ConnectorValue).Average();
}
else if (item.LogicalType == LogicalType.MOD)
{
output.Value.ConnectorValue = item.Input[0].ConnectorValue % item.Input[1].ConnectorValue;
}
else if (item.LogicalType == LogicalType.AND)
{
output.Value.ConnectorValue = Convert.ToInt32(item.Input[0].ConnectorValue) & Convert.ToInt32(item.Input[1].ConnectorValue);
}
else if (item.LogicalType == LogicalType.OR)
{
output.Value.ConnectorValue = Convert.ToInt32(item.Input[0].ConnectorValue) | Convert.ToInt32(item.Input[1].ConnectorValue);
}
else if (item.LogicalType == LogicalType.XOR)
{
output.Value.ConnectorValue = Convert.ToInt32(Convert.ToInt32(item.Input[0].ConnectorValue) ^ Convert.ToInt32(item.Input[1].ConnectorValue));
}
else if (item.LogicalType == LogicalType.NOT)
{
if (item.Input[0].ValueTypePoint == ValueTypePoint.Bool)
{
output.Value.ConnectorValue = Convert.ToInt32(!Convert.ToBoolean(item.Input[0].ConnectorValue));
output.Value.ValueTypePoint = ValueTypePoint.Bool;
}
else
{
output.Value.ConnectorValue = ~Convert.ToInt32(item.Input[0].ConnectorValue);
output.Value.ValueTypePoint = ValueTypePoint.Int;
}
}
else if (item.LogicalType == LogicalType.SHL)
{
output.Value.ConnectorValue = Convert.ToInt32(item.Input[0].ConnectorValue) << Convert.ToInt32(item.Input[1].ConnectorValue);
}
else if (item.LogicalType == LogicalType.SHR)
{
output.Value.ConnectorValue = Convert.ToInt32(item.Input[0].ConnectorValue) >> Convert.ToInt32(item.Input[1].ConnectorValue);
}
else if (item.LogicalType == LogicalType.ROL)
{
output.Value.ConnectorValue = (Convert.ToInt32(item.Input[0].ConnectorValue) << Convert.ToInt32(item.Input[1].ConnectorValue)) | (Convert.ToInt32(item.Input[0].ConnectorValue) >> 32 - Convert.ToInt32(item.Input[1].ConnectorValue));
}
else if (item.LogicalType == LogicalType.ROR)
{
output.Value.ConnectorValue = (Convert.ToInt32(item.Input[0].ConnectorValue) >> Convert.ToInt32(item.Input[1].ConnectorValue)) | (Convert.ToInt32(item.Input[0].ConnectorValue) << 32 - Convert.ToInt32(item.Input[1].ConnectorValue));
}
else if (item.LogicalType == LogicalType.SEL)
{
output.Value.ConnectorValue = (item.Input[0].ConnectorValue == output.Key) ? item.Input[1].ConnectorValue : item.Input[2].ConnectorValue;
}
else if (item.LogicalType == LogicalType.MAX)
{
output.Value.ConnectorValue = item.Input.Values.Select(p => p.ConnectorValue).Max();
}
else if (item.LogicalType == LogicalType.MIN)
{
output.Value.ConnectorValue = item.Input.Values.Select(p => p.ConnectorValue).Min();
}
else if (item.LogicalType == LogicalType.LIMIT)
{
output.Value.ConnectorValue = (item.Input[0].ConnectorValue > item.Input[1].ConnectorValue) ? item.Input[1].ConnectorValue : item.Input[0].ConnectorValue;
}
else if (item.LogicalType == LogicalType.GT)
{
output.Value.ConnectorValue = (item.Input[0].ConnectorValue > item.Input[1].ConnectorValue) ? 1 : 0;
}
else if (item.LogicalType == LogicalType.LT)
{
output.Value.ConnectorValue = (item.Input[0].ConnectorValue < item.Input[1].ConnectorValue) ? 1 : 0;
}
else if (item.LogicalType == LogicalType.GE)
{
output.Value.ConnectorValue = (item.Input[0].ConnectorValue >= item.Input[1].ConnectorValue) ? 1 : 0;
}
else if (item.LogicalType == LogicalType.LE)
{
output.Value.ConnectorValue = (item.Input[0].ConnectorValue <= item.Input[1].ConnectorValue) ? 1 : 0;
}
else if (item.LogicalType == LogicalType.EQ)
{
output.Value.ConnectorValue = (item.Input[0].ConnectorValue == item.Input[1].ConnectorValue) ? 1 : 0;
}
else if (item.LogicalType == LogicalType.NE)
{
output.Value.ConnectorValue = (item.Input[0].ConnectorValue != item.Input[1].ConnectorValue) ? 1 : 0;
}
else if (item.LogicalType == LogicalType.ABS)
{
output.Value.ConnectorValue = Math.Abs(item.Input[0].ConnectorValue);
}
else if (item.LogicalType == LogicalType.SQRT)
{
output.Value.ConnectorValue = Math.Sqrt(item.Input[0].ConnectorValue);
}
else if (item.LogicalType == LogicalType.LN)
{
output.Value.ConnectorValue = Math.Log10(item.Input[0].ConnectorValue);
}
else if (item.LogicalType == LogicalType.LOG)
{
output.Value.ConnectorValue = Math.Log(item.Input[0].ConnectorValue);
}
else if (item.LogicalType == LogicalType.EXP)
{
output.Value.ConnectorValue = Math.Exp(item.Input[0].ConnectorValue);
}
else if (item.LogicalType == LogicalType.SIN)
{
output.Value.ConnectorValue = Math.Sin(item.Input[0].ConnectorValue);
}
else if (item.LogicalType == LogicalType.COS)
{
output.Value.ConnectorValue = Math.Cos(item.Input[0].ConnectorValue);
}
else if (item.LogicalType == LogicalType.TAN)
{
output.Value.ConnectorValue = Math.Tan(item.Input[0].ConnectorValue);
}
else if (item.LogicalType == LogicalType.ASIN)
{
output.Value.ConnectorValue = Math.Asin(item.Input[0].ConnectorValue);
}
else if (item.LogicalType == LogicalType.ACOS)
{
output.Value.ConnectorValue = Math.Acos(item.Input[0].ConnectorValue);
}
else if (item.LogicalType == LogicalType.ATAN)
{
output.Value.ConnectorValue = Math.Atan(item.Input[0].ConnectorValue);
}
else if (item.LogicalType == LogicalType.EXPT)
{
output.Value.ConnectorValue = Math.Exp(item.Input[0].ConnectorValue);
}
if (output.Value.ValueTypePoint == ValueTypePoint.Bool)
{
if (output.Value.ConnectorValue == 0)
{
output.Value.ColorViewModel.FillColor.Color = Colors.Red;
if (item.LogicalType == LogicalType.Output)
{
item.ColorViewModel.FillColor.Color = Colors.Red;
}
}
else
{
output.Value.ColorViewModel.FillColor.Color = Colors.Green;
if (item.LogicalType == LogicalType.Output)
{
item.ColorViewModel.FillColor.Color = Colors.Green;
}
}
}
else
{
output.Value.ColorViewModel.FillColor.Color = Colors.Green;
}
}
}
item.Execute();
}
}
private ConnectionViewModel GetSourceItem(FullyCreatedConnectorInfo sinkConnector)
{
foreach (var connector in DiagramViewModel.Items.OfType<ConnectionViewModel>())
{
if (connector.SinkConnectorInfo == sinkConnector)
{
return connector;
}
}
return null;
}
}
}

View File

@@ -17,17 +17,27 @@ using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.DiagramDesigner.Additionals;
using AIStudio.Wpf.DiagramDesigner.Additionals.Commands;
using AIStudio.Wpf.DiagramDesigner.ViewModels;
using AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel;
using AIStudio.Wpf.Mind;
using AIStudio.Wpf.Mind.Models;
namespace AIStudio.Wpf.DiagramApp.ViewModels
{
public class MainWindowViewModel : BindableBase
{
private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
private IDiagramServiceProvider _service
{
get
{
return DiagramServicesProvider.Instance.Provider;
}
}
private string _history = System.AppDomain.CurrentDomain.BaseDirectory + "history.json";
public MainWindowViewModel()
{
ToolBoxViewModel = new ToolBoxViewModel();
ToolBoxViewModel = new ToolBoxViewModel(this);
DiagramsViewModels = new ObservableCollection<PageViewModel>();
DiagramsViewModels.Add(new PageViewModel("新建-1", "*", DiagramType.Normal));
@@ -43,12 +53,14 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
HistoryList = new ObservableCollection<string>();
}
this.PropertyChanged += MainWindowViewModel_PropertyChanged;
_service.PropertyChanged += Provider_PropertyChanged;
}
#region
public ToolBoxViewModel ToolBoxViewModel { get; private set; }
public ToolBoxViewModel ToolBoxViewModel
{
get; private set;
}
private ObservableCollection<PageViewModel> _diagramsViewModels;
public ObservableCollection<PageViewModel> DiagramsViewModels
@@ -63,16 +75,19 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
private PageViewModel _diagramsViewModel;
private PageViewModel _pageViewModel;
public PageViewModel PageViewModel
{
get
{
return _diagramsViewModel;
return _pageViewModel;
}
set
{
SetProperty(ref _diagramsViewModel, value);
if (SetProperty(ref _pageViewModel, value))
{
}
}
}
@@ -116,7 +131,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
public Color[] StandardColor { get; set; }
public Color[] StandardColor
{
get; set;
}
public IDrawModeViewModel DrawModeViewModel
{
@@ -162,11 +180,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
public SelectableDesignerItemViewModelBase SelectedItem
public SelectableDesignerItemViewModelBase SelectedItemViewModel
{
get
{
return _service.SelectedItem;
return _service.SelectedItemViewModel;
}
}
@@ -220,8 +238,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
get
{
return
() =>
{
() => {
return new PageViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", DiagramType.Normal);
};
}
@@ -237,6 +254,15 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
private ICommand _newMindCommand;
public ICommand NewMindCommand
{
get
{
return this._newMindCommand ?? (this._newMindCommand = new DelegateCommand<string>(para => this.NewMind_Executed(para)));
}
}
private ICommand _openCommand;
public ICommand OpenCommand
{
@@ -316,187 +342,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
return this._deleteCommand ?? (this._deleteCommand = new CanExecuteDelegateCommand(() => this.DeleteExecuted(), () => Delete_Enabled()));
}
}
private ICommand _alignTopCommand;
public ICommand AlignTopCommand
{
get
{
return this._alignTopCommand ?? (this._alignTopCommand = new DelegateCommand<object>(para => this.AlignTopExecuted(para)));
}
}
private ICommand _alignVerticalCentersCommand;
public ICommand AlignVerticalCentersCommand
{
get
{
return this._alignVerticalCentersCommand ?? (this._alignVerticalCentersCommand = new DelegateCommand<object>(para => this.AlignVerticalCentersExecuted(para)));
}
}
private ICommand _alignBottomCommand;
public ICommand AlignBottomCommand
{
get
{
return this._alignBottomCommand ?? (this._alignBottomCommand = new DelegateCommand<object>(para => this.AlignBottomExecuted(para)));
}
}
private ICommand _alignLeftCommand;
public ICommand AlignLeftCommand
{
get
{
return this._alignLeftCommand ?? (this._alignLeftCommand = new DelegateCommand<object>(para => this.AlignLeftExecuted(para)));
}
}
private ICommand _alignHorizontalCentersCommand;
public ICommand AlignHorizontalCentersCommand
{
get
{
return this._alignHorizontalCentersCommand ?? (this._alignHorizontalCentersCommand = new DelegateCommand<object>(para => this.AlignHorizontalCentersExecuted(para)));
}
}
private ICommand _alignRightCommand;
public ICommand AlignRightCommand
{
get
{
return this._alignRightCommand ?? (this._alignRightCommand = new DelegateCommand<object>(para => this.AlignRightExecuted(para)));
}
}
private ICommand _groupCommand;
public ICommand GroupCommand
{
get
{
return this._groupCommand ?? (this._groupCommand = new DelegateCommand<object>(para => this.GroupExecuted(para)));
}
}
private ICommand _ungroupCommand;
public ICommand UngroupCommand
{
get
{
return this._ungroupCommand ?? (this._ungroupCommand = new DelegateCommand<object>(para => this.UngroupExecuted(para)));
}
}
private ICommand _bringForwardCommand;
public ICommand BringForwardCommand
{
get
{
return this._bringForwardCommand ?? (this._bringForwardCommand = new DelegateCommand<object>(para => this.BringForwardExecuted(para)));
}
}
private ICommand _bringToFrontCommand;
public ICommand BringToFrontCommand
{
get
{
return this._bringToFrontCommand ?? (this._bringToFrontCommand = new DelegateCommand<object>(para => this.BringToFrontExecuted(para)));
}
}
private ICommand _sendBackwardCommand;
public ICommand SendBackwardCommand
{
get
{
return this._sendBackwardCommand ?? (this._sendBackwardCommand = new DelegateCommand<object>(para => this.SendBackwardExecuted(para)));
}
}
private ICommand _sendToBackCommand;
public ICommand SendToBackCommand
{
get
{
return this._sendToBackCommand ?? (this._sendToBackCommand = new DelegateCommand<object>(para => this.SendToBackExecuted(para)));
}
}
private ICommand _distributeHorizontalCommand;
public ICommand DistributeHorizontalCommand
{
get
{
return this._distributeHorizontalCommand ?? (this._distributeHorizontalCommand = new DelegateCommand<object>(para => this.DistributeHorizontalExecuted(para)));
}
}
private ICommand _distributeVerticalCommand;
public ICommand DistributeVerticalCommand
{
get
{
return this._distributeVerticalCommand ?? (this._distributeVerticalCommand = new DelegateCommand<object>(para => this.DistributeVerticalExecuted(para)));
}
}
private ICommand _selectAllCommand;
public ICommand SelectAllCommand
{
get
{
return this._selectAllCommand ?? (this._selectAllCommand = new DelegateCommand<object>(para => this.SelectAllExecuted(para)));
}
}
private ICommand _centerCommand;
public ICommand CenterCommand
{
get
{
return this._centerCommand ?? (this._centerCommand = new DelegateCommand<object>(para => this.CenterMoveExecuted(para)));
}
}
private ICommand _sameWidthCommand;
public ICommand SameWidthCommand
{
get
{
return this._sameWidthCommand ?? (this._sameWidthCommand = new DelegateCommand<object>(para => this.SameWidthExecuted(para)));
}
}
private ICommand _sameHeightCommand;
public ICommand SameHeightCommand
{
get
{
return this._sameHeightCommand ?? (this._sameHeightCommand = new DelegateCommand<object>(para => this.SameHeightExecuted(para)));
}
}
private ICommand _sameSizeCommand;
public ICommand SameSizeCommand
{
get
{
return this._sameSizeCommand ?? (this._sameSizeCommand = new DelegateCommand<object>(para => this.SameSizeExecuted(para)));
}
}
private ICommand _sameAngleCommand;
public ICommand SameAngleCommand
{
get
{
return this._sameAngleCommand ?? (this._sameAngleCommand = new DelegateCommand<object>(para => this.SameAngleExecuted(para)));
}
}
}
private ICommand _lockCommand;
public ICommand LockCommand
@@ -523,118 +369,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
return this._selectedColorCommand ?? (this._selectedColorCommand = new DelegateCommand<object>(para => this.SelectedColorExecuted(para)));
}
}
private ICommand _addPageCommand;
public ICommand AddPageCommand
{
get
{
return this._addPageCommand ?? (this._addPageCommand = new DelegateCommand<object>(para => this.AddPageExecuted(para)));
}
}
private ICommand _addCopyPageCommand;
public ICommand AddCopyPageCommand
{
get
{
return this._addCopyPageCommand ?? (this._addCopyPageCommand = new DelegateCommand<object>(para => this.AddCopyPageExecuted(para)));
}
}
private ICommand _renamePageCommand;
public ICommand RenamePageCommand
{
get
{
return this._renamePageCommand ?? (this._renamePageCommand = new DelegateCommand<object>(para => this.RenamePageExecuted(para)));
}
}
private ICommand _endRenamePageCommand;
public ICommand EndRenamePageCommand
{
get
{
return this._endRenamePageCommand ?? (this._endRenamePageCommand = new DelegateCommand<object>(para => this.EndRenamePageExecuted(para)));
}
}
private ICommand _deletePageCommand;
public ICommand DeletePageCommand
{
get
{
return this._deletePageCommand ?? (this._deletePageCommand = new DelegateCommand<object>(para => this.DeletePageExecuted(para)));
}
}
private ICommand _addImageCommand;
public ICommand AddImageCommand
{
get
{
return this._addImageCommand ?? (this._addImageCommand = new DelegateCommand<object>(para => this.AddImageExecuted(para)));
}
}
private ICommand _editImageCommand;
public ICommand EditImageCommand
{
get
{
return this._editImageCommand ?? (this._editImageCommand = new DelegateCommand<object>(para => this.EditImageExecuted(para)));
}
}
private ICommand _resizeImageCommand;
public ICommand ResizeImageCommand
{
get
{
return this._resizeImageCommand ?? (this._resizeImageCommand = new DelegateCommand<object>(para => this.ResizeImageExecuted(para)));
}
}
private ICommand _resetImageCommand;
public ICommand ResetImageCommand
{
get
{
return this._resetImageCommand ?? (this._resetImageCommand = new DelegateCommand<object>(para => this.ResetImageExecuted(para)));
}
}
private ICommand _addVideoCommand;
public ICommand AddVideoCommand
{
get
{
return this._addVideoCommand ?? (this._addVideoCommand = new DelegateCommand<object>(para => this.AddVideoExectued(para)));
}
}
private ICommand _addOutLineTextCommand;
public ICommand AddOutLineTextCommand
{
get
{
return this._addOutLineTextCommand ?? (this._addOutLineTextCommand = new DelegateCommand<object>(para => this.AddOutLineTextExecuted(para)));
}
}
private ICommand _addBarcodeCommand;
public ICommand AddBarcodeCommand
{
get
{
return this._addBarcodeCommand ?? (this._addBarcodeCommand = new DelegateCommand<object>(para => this.AddBarcodeExecuted(para)));
}
}
}
private ICommand _aboutCommand;
public ICommand AboutCommand
@@ -644,11 +379,23 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
return this._aboutCommand ?? (this._aboutCommand = new DelegateCommand(() => this.AboutExecuted()));
}
}
private ICommand _screenshotCommand;
public ICommand ScreenshotCommand
{
get
{
return this._screenshotCommand ?? (this._screenshotCommand = new DelegateCommand(() => this.ScreenshotExecuted()));
}
}
#endregion
public ItemActionCallback ClosingTabItemHandler
{
get { return ClosingTabItemHandlerImpl; }
get
{
return ClosingTabItemHandlerImpl;
}
}
/// <summary>
@@ -665,11 +412,6 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
private void MainWindowViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
}
private void Provider_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(DrawModeViewModel)
@@ -678,74 +420,54 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|| e.PropertyName == nameof(ShapeViewModel)
|| e.PropertyName == nameof(QuickThemeViewModel)
|| e.PropertyName == nameof(LockObjectViewModel)
|| e.PropertyName == nameof(SelectedItem))
|| e.PropertyName == nameof(SelectedItemViewModel))
{
RaisePropertyChanged(e.PropertyName);
}
if (PageViewModel == null) return;
if (PageViewModel == null || PageViewModel.DiagramViewModel == null) return;
if (sender is IFontViewModel)
PageViewModel.SetFont(sender as IFontViewModel, e.PropertyName);
if (sender is IColorViewModel)
PageViewModel.SetColor(sender as IColorViewModel, e.PropertyName);
if (sender is IShapeViewModel)
PageViewModel.SetSharp(sender as IShapeViewModel, e.PropertyName);
if (sender is IQuickThemeViewModel)
PageViewModel.SetQuickItem(sender as IQuickThemeViewModel, e.PropertyName);
if (sender is LockObject)
PageViewModel.LockAction(sender as LockObject, e.PropertyName);
if (sender is DesignerItemViewModelBase designer
&& (e.PropertyName == nameof(designer.Angle)
|| e.PropertyName == nameof(designer.ItemWidth)
|| e.PropertyName == nameof(designer.ItemHeight)
|| e.PropertyName == nameof(designer.ScaleX)
|| e.PropertyName == nameof(designer.ScaleY)))
{
PageViewModel.SetPropertyValue(designer, e.PropertyName);
PageViewModel.DiagramViewModel.SetFont(sender as IFontViewModel, e.PropertyName, PageViewModel.DiagramViewModel.SelectedItems);
}
else if (sender is IColorViewModel)
{
PageViewModel.DiagramViewModel.SetColor(sender as IColorViewModel, e.PropertyName, PageViewModel.DiagramViewModel.SelectedItems);
}
else if (sender is IShapeViewModel)
{
PageViewModel.DiagramViewModel.SetSharp(sender as IShapeViewModel, e.PropertyName, PageViewModel.DiagramViewModel.SelectedItems);
}
else if (sender is IQuickThemeViewModel)
{
PageViewModel.DiagramViewModel.SetQuickItem(sender as IQuickThemeViewModel, e.PropertyName, PageViewModel.DiagramViewModel.SelectedItems);
}
else if (sender is LockObject)
{
PageViewModel.DiagramViewModel.LockAction(sender as LockObject, e.PropertyName, PageViewModel.DiagramViewModel.SelectedItems);
}
else if (sender is SelectableDesignerItemViewModelBase designer)
{
PageViewModel.DiagramViewModel.SetPropertyValue(designer, e.PropertyName, PageViewModel.DiagramViewModel.SelectedItems);
}
}
public bool KeyExecuted(KeyEventArgs e)
{
if (PageViewModel?.DiagramViewModel?.ExecuteShortcut(e) == true)
{
return true;
}
var para = e.KeyboardDevice.Modifiers == ModifierKeys.None ? e.Key.ToString() : e.KeyboardDevice.Modifiers.ToString() + "+" + e.Key.ToString();
bool executed = true;
switch (para)
switch (para)
{
case "Control+O": OpenExecuted(); break;
case "Control+N": New_Executed(); break;
case "Control+S": SaveExecuted(); break;
case "Control+S": SaveExecuted(); break;
default: executed = false; break;
}
return executed;
}
private void UnDoExecuted()
{
PageViewModel?.DiagramViewModel?.UndoCommand.Execute(null);
}
private void ReDoExecuted()
{
PageViewModel?.DiagramViewModel?.RedoCommand.Execute(null);
}
private void SelectedAllExecuted()
{
PageViewModel?.DiagramViewModel?.SelectAllCommand.Execute(null);
}
}
private void OpenExecuted(string para = null)
{
@@ -790,6 +512,14 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
flow = new SFCViewModel(filename, diagram);
}
else if (diagram.DiagramType == DiagramType.Mind)
{
flow = new MindViewModel(filename, diagram);
}
else if (diagram.DiagramType == DiagramType.Script)
{
flow = new ScriptViewModel(filename, diagram);
}
else
{
flow = new PageViewModel(filename, diagram);
@@ -905,9 +635,9 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
PageViewModel = new SFCViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
}
else if (type == DiagramType.Mind.ToString())
else if (type == DiagramType.Script.ToString())
{
PageViewModel = new MindViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
PageViewModel = new ScriptViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
}
else
{
@@ -917,120 +647,20 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
DiagramsViewModels.Add(PageViewModel);
}
private void NewMind_Executed(string mindtype = "Mind")
{
IsOpenBackstage = false;
PageViewModel = new MindViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", DiagramType.Mind, mindtype.ToEnum<MindType>());
DiagramsViewModels.Add(PageViewModel);
}
private void ExitExecuted()
{
throw new NotImplementedException();
}
private void GroupExecuted(object para)
{
PageViewModel?.DiagramViewModel?.GroupCommand.Execute(para);
}
private void UngroupExecuted(object para)
{
PageViewModel?.DiagramViewModel?.UngroupCommand.Execute(para);
}
#region
private void AlignTopExecuted(object para)
{
PageViewModel?.DiagramViewModel?.AlignTopCommand.Execute(para);
}
private void AlignVerticalCentersExecuted(object para)
{
PageViewModel?.DiagramViewModel?.AlignVerticalCentersCommand.Execute(para);
}
private void AlignBottomExecuted(object para)
{
PageViewModel?.DiagramViewModel?.AlignBottomCommand.Execute(para);
}
private void AlignLeftExecuted(object para)
{
PageViewModel?.DiagramViewModel?.AlignLeftCommand.Execute(para);
}
private void AlignHorizontalCentersExecuted(object para)
{
PageViewModel?.DiagramViewModel?.AlignHorizontalCentersCommand.Execute(para);
}
private void AlignRightExecuted(object para)
{
PageViewModel?.DiagramViewModel?.AlignRightCommand.Execute(para);
}
private void BringForwardExecuted(object para)
{
PageViewModel?.DiagramViewModel?.BringForwardCommand.Execute(para);
}
private void BringToFrontExecuted(object para)
{
PageViewModel?.DiagramViewModel?.BringToFrontCommand.Execute(para);
}
private void SendBackwardExecuted(object para)
{
PageViewModel?.DiagramViewModel?.SendBackwardCommand.Execute(para);
}
private void SendToBackExecuted(object para)
{
PageViewModel?.DiagramViewModel?.SendBackwardCommand.Execute(para);
}
private void DistributeHorizontalExecuted(object para)
{
PageViewModel?.DiagramViewModel?.DistributeHorizontalCommand.Execute(para);
}
private void DistributeVerticalExecuted(object para)
{
PageViewModel?.DiagramViewModel?.DistributeVerticalCommand.Execute(para);
}
private void SelectAllExecuted(object para)
{
PageViewModel?.DiagramViewModel?.SelectAllCommand.Execute(para);
}
#endregion
private void CenterMoveExecuted(object para)
{
PageViewModel?.DiagramViewModel?.CenterMoveCommand.Execute(para);
}
private void LeftMoveExecuted(object para = null)
{
PageViewModel?.DiagramViewModel?.LeftMoveCommand.Execute(para);
}
private void RightMoveExecuted(object para = null)
{
PageViewModel?.DiagramViewModel?.RightMoveCommand.Execute(para);
}
private void UpMoveExecuted(object para = null)
{
PageViewModel?.DiagramViewModel?.UpMoveCommand.Execute(para);
}
private void DownMoveExecuted(object para = null)
{
PageViewModel?.DiagramViewModel?.DownMoveCommand.Execute(para);
}
private void SameWidthExecuted(object para)
{
PageViewModel?.DiagramViewModel?.SameWidthCommand.Execute(para);
}
private void SameHeightExecuted(object para)
{
PageViewModel?.DiagramViewModel?.SameHeightCommand.Execute(para);
}
private void SameSizeExecuted(object para)
{
PageViewModel?.DiagramViewModel?.SameSizeCommand.Execute(para);
}
private void SameAngleExecuted(object para)
{
PageViewModel?.DiagramViewModel?.SameAngleCommand.Execute(para);
}
}
private void LockExecuted(object para)
{
@@ -1042,75 +672,15 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
LockObjectViewModel.LockObject.ForEach(p => p.IsChecked = false);
}
private void AddPageExecuted(object para)
{
PageViewModel?.AddPageExecuted(para);
}
private void AddCopyPageExecuted(object para)
{
PageViewModel?.AddCopyPageExecuted(para);
}
private void RenamePageExecuted(object para)
{
PageViewModel?.RenamePageExecuted(para);
}
private void EndRenamePageExecuted(object para)
{
PageViewModel?.EndRenamePageExecuted(para);
}
private void DeletePageExecuted(object para)
{
PageViewModel?.DeletePageExecuted(para);
}
private void AddImageExecuted(object para)
{
PageViewModel?.AddImageExecuted(para);
}
private void EditImageExecuted(object para)
{
PageViewModel?.EditImageExecuted(PageViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
}
private void ResizeImageExecuted(object para)
{
PageViewModel?.ResizeImageExecuted(PageViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
}
private void ResetImageExecuted(object para)
{
PageViewModel?.ResetImageExecuted(PageViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
}
private void AddVideoExectued(object para)
{
PageViewModel?.AddVideoExecuted(para);
}
private void AddOutLineTextExecuted(object para)
{
PageViewModel?.AddOutLineTextExecuted(para);
}
private void AddBarcodeExecuted(object para)
{
PageViewModel?.AddBarcodeExecuted(para);
}
private void SelectedColorExecuted(object para)
{
if (para == null) return;
switch (ColorType)
{
case Models.ColorType.Text: PageViewModel?.SetFont(new FontViewModel() { FontColor = (Color)para }, "FontColor"); break;
case Models.ColorType.Fill: PageViewModel?.SetColor(new ColorViewModel() { FillColor = new ColorObject() { Color = (Color)para } }, "FillColor"); break;
case Models.ColorType.Line: PageViewModel?.SetColor(new ColorViewModel() { LineColor = new ColorObject() { Color = (Color)para } }, "LineColor"); break;
case Models.ColorType.Text: PageViewModel?.DiagramViewModel?.SetFont(new FontViewModel() { FontColor = (Color)para }, "FontColor", PageViewModel.DiagramViewModel.SelectedItems); break;
case Models.ColorType.Fill: PageViewModel?.DiagramViewModel?.SetColor(new ColorViewModel() { FillColor = new ColorObject() { Color = (Color)para } }, "FillColor", PageViewModel.DiagramViewModel.SelectedItems); break;
case Models.ColorType.Line: PageViewModel?.DiagramViewModel?.SetColor(new ColorViewModel() { LineColor = new ColorObject() { Color = (Color)para } }, "LineColor", PageViewModel.DiagramViewModel.SelectedItems); break;
}
}
@@ -1120,6 +690,12 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
aboutWindow.ShowDialog();
}
private void ScreenshotExecuted()
{
AIStudio.Wpf.ComeCapture.MainWindow window = new AIStudio.Wpf.ComeCapture.MainWindow();
window.Show();
}
#region
private Color[] GenerateStandardGradients()
{
@@ -1130,14 +706,14 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
//var colors = ColorGallery.GetGradient(ColorGallery.StandardThemeColors[i], 10);
//for (var j = 9; j >= 0; j--)
//{
// result.Add(colors[j]);
// result.AddTo(colors[j]);
//}
}
{
//var colors = ColorGallery.GetGradient(Colors.Black, 10);
//for (var j = 9; j >= 0; j--)
//{
// result.Add(colors[j]);
// result.AddTo(colors[j]);
//}
}
return result.ToArray();

View File

@@ -11,39 +11,108 @@ using System.Windows;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.Mind.ViewModels;
using AIStudio.Wpf.Mind;
using AIStudio.Wpf.DiagramDesigner.Additionals;
using AIStudio.Wpf.Mind.Helpers;
using AIStudio.Wpf.Mind.Models;
namespace AIStudio.Wpf.Flowchart
{
public class MindViewModel : PageViewModel
{
public MindViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
public MindViewModel(string title, string status, DiagramType diagramType, MindType mindType) : base(title, status, diagramType, mindType.ToString())
{
}
public MindViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
_service.DrawModeViewModel.LineDrawMode = DrawMode.ConnectingLineSmooth;
{
foreach (var vm in DiagramViewModels)
{
vm.Init(false);
}
if (MindDiagramViewModel != null)
{
SubType = MindDiagramViewModel.MindType.ToString();
MindTheme = MindDiagramViewModel.MindTheme;
}
}
protected override void InitDiagramViewModel()
{
base.InitDiagramViewModel();
DiagramViewModel.GridCellSize = new Size(100, 100);
_service.DrawModeViewModel.LineDrawMode = DrawMode.ConnectingLineSmooth;
DiagramViewModel.GridCellSize = new Size(100, 100);
DiagramViewModel.ShowGrid = false;
DiagramViewModel.AllowDrop = false;
}
protected override void Init()
public IMindDiagramViewModel MindDiagramViewModel
{
base.Init();
get
{
return DiagramViewModel as IMindDiagramViewModel;
}
}
DesignerItemViewModelBase start = new MindLevel1Node() { Left = 100, Top = 0, ItemWidth = 80, ItemHeight = 40, Text = "思维导图" };
DiagramViewModel.DirectAddItemCommand.Execute(start);
DiagramViewModel?.CenterMoveCommand.Execute(start);
public MindType MindType
{
get
{
if (SubType == null)
{
return MindType.Mind;
}
else
{
return SubType.ToEnum<MindType>();
}
}
}
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
public MindTheme MindTheme
{
get;
}
protected override void Init(bool initNew)
{
DiagramViewModels = new ObservableCollection<IDiagramViewModel>()
{
GetDiagramViewModel("页-1", DiagramType, initNew),
};
DiagramViewModel = DiagramViewModels.FirstOrDefault();
InitDiagramViewModel();
var level1node = MindDiagramViewModel.RootItems.FirstOrDefault();
MindNode level2node1_1 = new MindNode(DiagramViewModel) { Text = "分支主题1" };
level2node1_1.AddTo(level1node, 0, false);
MindNode level2node1_1_1 = new MindNode(DiagramViewModel) { Text = "分支主题1_1" };
level2node1_1_1.AddTo(level2node1_1, 0, false);
MindNode level2node1_1_2 = new MindNode(DiagramViewModel) { Text = "分支主题1_2" };
level2node1_1_2.AddTo(level2node1_1, 0, false);
MindNode level2node1_1_3 = new MindNode(DiagramViewModel) { Text = "分支主题1_3" };
level2node1_1_3.AddTo(level2node1_1, 0, false);
MindNode level2node1_2 = new MindNode(DiagramViewModel) { Text = "分支主题2" };
level2node1_2.AddTo(level1node, 0, false);
MindNode level2node1_3 = new MindNode(DiagramViewModel) { Text = "分支主题3" };
level2node1_3.AddTo(level1node, 0, false);
DiagramViewModel.Init(initNew);
}
protected override DiagramViewModel GetDiagramViewModel(string name, DiagramType diagramType, bool initNew)
{
var viewmodel = new MindDiagramViewModel() { Name = name ?? NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = diagramType, MindType = MindType, MindTheme = MindTheme };
viewmodel.Init(initNew);
return viewmodel;
}
public override void Dispose()
@@ -52,7 +121,7 @@ namespace AIStudio.Wpf.Flowchart
foreach (var viewModel in DiagramViewModels)
{
FlowchartService.DisposeData(viewModel);
FlowchartService.Dispose(viewModel);
}
}
}

View File

@@ -18,26 +18,29 @@ using System.Xml.Serialization;
using AIStudio.Wpf.DiagramDesigner;
using ZXing;
using AIStudio.Wpf.DiagramDesigner.Helpers;
using AIStudio.Wpf.DiagramDesigner.ViewModels;
using AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel;
namespace AIStudio.Wpf.DiagramApp.ViewModels
{
public partial class PageViewModel : BindableBase
{
protected IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
public PageViewModel(string title, string status, DiagramType diagramType)
#region
protected IDiagramServiceProvider _service
{
get
{
return DiagramServicesProvider.Instance.Provider;
}
}
public PageViewModel(string title, string status, DiagramType diagramType, string subType = null)
{
Title = title;
Status = status;
DiagramType = diagramType;
DiagramViewModels = new ObservableCollection<IDiagramViewModel>()
{
new DiagramViewModel(){Name= "页-1", DiagramType = diagramType},
};
DiagramViewModel = DiagramViewModels.FirstOrDefault();
Init();
SubType = subType;
Init(true);
}
public PageViewModel(string filename)
{
@@ -59,14 +62,23 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
protected virtual void Init()
protected virtual void Init(bool initNew)
{
DiagramViewModels = new ObservableCollection<IDiagramViewModel>()
{
GetDiagramViewModel("页-1", DiagramType,initNew),
};
DiagramViewModel = DiagramViewModels.FirstOrDefault();
InitDiagramViewModel();
}
public string FileName { get; set; }
#endregion
#region
public string FileName
{
get; set;
}
private string _title;
public string Title
@@ -113,7 +125,15 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
public DiagramType DiagramType { get; set; }
public DiagramType DiagramType
{
get; set;
}
public string SubType
{
get; set;
}
private ObservableCollection<IDiagramViewModel> _diagramViewModels;
public ObservableCollection<IDiagramViewModel> DiagramViewModels
@@ -140,35 +160,143 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
if (_diagramViewModel != value)
{
if (_diagramViewModel != null)
{
{
_diagramViewModel.PropertyChanged -= DiagramViewModel_PropertyChanged;
_diagramViewModel.OutAddVerify -= AddVerify;
}
SetProperty(ref _diagramViewModel, value);
if (_diagramViewModel != null)
{
_diagramViewModel.PropertyChanged += DiagramViewModel_PropertyChanged;
_diagramViewModel.OutAddVerify += AddVerify;
}
}
}
}
#endregion
#region
#region
private ICommand _addPageCommand;
public ICommand AddPageCommand
{
get
{
return this._addPageCommand ?? (this._addPageCommand = new DelegateCommand<object>(para => this.AddPageExecuted(para)));
}
}
private ICommand _addCopyPageCommand;
public ICommand AddCopyPageCommand
{
get
{
return this._addCopyPageCommand ?? (this._addCopyPageCommand = new DelegateCommand<object>(para => this.AddCopyPageExecuted(para)));
}
}
private ICommand _renamePageCommand;
public ICommand RenamePageCommand
{
get
{
return this._renamePageCommand ?? (this._renamePageCommand = new DelegateCommand<object>(para => this.RenamePageExecuted(para)));
}
}
private ICommand _endRenamePageCommand;
public ICommand EndRenamePageCommand
{
get
{
return this._endRenamePageCommand ?? (this._endRenamePageCommand = new DelegateCommand<object>(para => this.EndRenamePageExecuted(para)));
}
}
private ICommand _deletePageCommand;
public ICommand DeletePageCommand
{
get
{
return this._deletePageCommand ?? (this._deletePageCommand = new DelegateCommand<object>(para => this.DeletePageExecuted(para)));
}
}
private ICommand _addImageCommand;
public ICommand AddImageCommand
{
get
{
return this._addImageCommand ?? (this._addImageCommand = new DelegateCommand<object>(para => this.AddImageExecuted(para)));
}
}
private ICommand _editImageCommand;
public ICommand EditImageCommand
{
get
{
return this._editImageCommand ?? (this._editImageCommand = new DelegateCommand<object>(para => this.EditImageExecuted(para)));
}
}
private ICommand _resizeImageCommand;
public ICommand ResizeImageCommand
{
get
{
return this._resizeImageCommand ?? (this._resizeImageCommand = new DelegateCommand<object>(para => this.ResizeImageExecuted(para)));
}
}
private ICommand _resetImageCommand;
public ICommand ResetImageCommand
{
get
{
return this._resetImageCommand ?? (this._resetImageCommand = new DelegateCommand<object>(para => this.ResetImageExecuted(para)));
}
}
private ICommand _addVideoCommand;
public ICommand AddVideoCommand
{
get
{
return this._addVideoCommand ?? (this._addVideoCommand = new DelegateCommand<object>(para => this.AddVideoExectued(para)));
}
}
private ICommand _addOutLineTextCommand;
public ICommand AddOutLineTextCommand
{
get
{
return this._addOutLineTextCommand ?? (this._addOutLineTextCommand = new DelegateCommand<object>(para => this.AddOutLineTextExecuted(para)));
}
}
private ICommand _addBarcodeCommand;
public ICommand AddBarcodeCommand
{
get
{
return this._addBarcodeCommand ?? (this._addBarcodeCommand = new DelegateCommand<object>(para => this.AddBarcodeExecuted(para)));
}
}
#endregion
#region
private void DiagramViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsSelected")
{
_service.SelectedItems = DiagramViewModel?.SelectedItems;
_service.SelectedItem = DiagramViewModel?.SelectedItems?.FirstOrDefault();
_service.SelectedItemViewModel = CopyHelper.Mapper(DiagramViewModel?.SelectedItem);
return;
}
var property = sender.GetType().GetProperty(e.PropertyName);
var attr = property.GetCustomAttributes(typeof(BrowsableAttribute), true);
if (attr != null && attr.Length != 0 && (attr[0] as BrowsableAttribute).Browsable == false)
if (attr != null && attr.OfType<BrowsableAttribute>().FirstOrDefault()?.Browsable != true)
{
return;
}
@@ -178,6 +306,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
#endregion
#region
protected virtual bool AddVerify(SelectableDesignerItemViewModelBase arg)
{
return true;
@@ -241,9 +370,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
List<DiagramViewModel> viewModels = new List<DiagramViewModel>();
foreach (var diagramItem in diagramDocument.DiagramItems)
{
var viewModel = new DiagramViewModel();
viewModel.Name = diagramItem.Name;
viewModel.DiagramType = diagramItem.DiagramType;
var viewModel = GetDiagramViewModel(diagramItem.Name, diagramItem.DiagramType, false);
viewModel.ShowGrid = diagramItem.ShowGrid;
viewModel.PhysicalGridCellSize = diagramItem.PhysicalGridCellSize;
viewModel.CellHorizontalAlignment = diagramItem.CellHorizontalAlignment;
@@ -259,7 +386,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
Type type = TypeHelper.GetType(diagramItemData.ModelTypeName);
DesignerItemViewModelBase itemBase = Activator.CreateInstance(type, viewModel, diagramItemData, ext) as DesignerItemViewModelBase;
viewModel.Items.Add(itemBase);
viewModel.Items.Add(itemBase);
}
foreach (var connection in diagramItem.Connections)
@@ -278,6 +405,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
FullyCreatedConnectorInfo sinkConnectorInfo = sinkItem.GetFullConnectorInfo(connectionItem.Id, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint, connectionItem.SinkInnerPoint);
ConnectionViewModel connectionVM = new ConnectionViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
connectionVM.Id = Guid.NewGuid();
viewModel.Items.Add(connectionVM);
}
@@ -315,7 +443,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
foreach (var viewModel in DiagramViewModels)
{
DiagramItem diagramItem = new DiagramItem(viewModel);
DiagramItem diagramItem = new DiagramItem(viewModel);
var selectedDesignerItems = viewModel.Items.OfType<DesignerItemViewModelBase>();
var selectedConnections = viewModel.Items.OfType<ConnectionViewModel>();
@@ -338,84 +466,6 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
Status = "";
return true;
}
private bool ItemsToDeleteHasConnector(List<SelectableDesignerItemViewModelBase> itemsToRemove, ConnectorInfoBase connector)
{
if (connector is FullyCreatedConnectorInfo fully)
{
return itemsToRemove.Contains(fully.DataItem);
}
return false;
}
#region
public void SetPropertyValue(SelectableDesignerItemViewModelBase selectable, string propertyName)
{
foreach (var item in DiagramViewModel.SelectedItems)
{
if (item != selectable)
{
CopyHelper.CopyPropertyValue(selectable, item, propertyName);
}
}
}
public void SetFont(IFontViewModel fontViewModel, string propertyName)
{
foreach (var item in DiagramViewModel.SelectedItems)
{
if (item.FontViewModel != fontViewModel)
{
CopyHelper.CopyPropertyValue(fontViewModel, item.FontViewModel, propertyName);
}
}
}
public void SetColor(IColorViewModel colorViewModel, string propertyName)
{
foreach (var item in DiagramViewModel.SelectedItems)
{
if (item.ColorViewModel != colorViewModel)
{
CopyHelper.CopyPropertyValue(colorViewModel, item.ColorViewModel, propertyName);
}
}
}
public void SetSharp(IShapeViewModel shapeViewModel, string propertyName)
{
foreach (var item in DiagramViewModel.SelectedItems)
{
if (item.ShapeViewModel != shapeViewModel)
{
CopyHelper.CopyPropertyValue(shapeViewModel, item.ShapeViewModel, propertyName);
}
}
}
public void SetQuickItem(IQuickThemeViewModel quickThemeViewModel, string propertyName)
{
if (propertyName == nameof(QuickTheme) && quickThemeViewModel.QuickTheme != null)
{
foreach (var item in DiagramViewModel.SelectedItems)
{
SetFont(quickThemeViewModel.QuickTheme.FontViewModel, "FontColor");
SetColor(quickThemeViewModel.QuickTheme.ColorViewModel, "FillColor");
SetColor(quickThemeViewModel.QuickTheme.ColorViewModel, "LineColor");
SetColor(quickThemeViewModel.QuickTheme.ColorViewModel, "LineWidth");
}
quickThemeViewModel.QuickTheme = null;
}
}
public void LockAction(LockObject lockObject, string propertyName)
{
foreach (var item in DiagramViewModel?.SelectedItems)
{
item.LockObjectViewModel.SetValue(lockObject);
}
}
public virtual void AddPageExecuted(object para)
@@ -429,12 +479,17 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
{
index = DiagramViewModels.Count;
}
var page = new DiagramViewModel() { Name = NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = DiagramType };
var page = GetDiagramViewModel(null, DiagramType, true);
DiagramViewModels.Insert(index, page);
DiagramViewModel = page;
InitDiagramViewModel();
}
protected virtual DiagramViewModel GetDiagramViewModel(string name, DiagramType diagramType, bool initNew)
{
return new DiagramViewModel() { Name = name ?? NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-"), DiagramType = diagramType };
}
public void AddCopyPageExecuted(object para)
{
if (DiagramViewModel != null)
@@ -466,13 +521,14 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
DesignerItemViewModelBase sourceItem = DiagramViewModelHelper.GetConnectorDataItem(viewModel.Items, connectionItem.SourceId, connectionItem.SourceType);
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
FullyCreatedConnectorInfo sourceConnectorInfo = sourceItem.GetFullConnectorInfo(connectionItem.Id,sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint, connectionItem.SourceIsPortless);
FullyCreatedConnectorInfo sourceConnectorInfo = sourceItem.GetFullConnectorInfo(connectionItem.Id, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint, connectionItem.SourceIsPortless);
DesignerItemViewModelBase sinkItem = DiagramViewModelHelper.GetConnectorDataItem(viewModel.Items, connectionItem.SinkId, connectionItem.SinkType);
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
FullyCreatedConnectorInfo sinkConnectorInfo = sinkItem.GetFullConnectorInfo(connectionItem.Id, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint, connectionItem.SinkIsPortless);
ConnectionViewModel connectionVM = new ConnectionViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
connectionVM.Id = Guid.NewGuid();
viewModel.Items.Add(connectionVM);
}
@@ -519,7 +575,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
public void AddImageExecuted(object para)
{
ImageItemViewModel itemBase = new ImageItemViewModel();
DiagramViewModel?.DirectAddItemCommand.Execute(itemBase);
DiagramViewModel?.AddItemCommand.Execute(itemBase);
if (itemBase.Root != null)
{
_service.DrawModeViewModel.CursorMode = CursorMode.Move;
@@ -528,6 +584,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
public void EditImageExecuted(object para)
{
if (para == null)
{
para = DiagramViewModel.SelectedItem;
}
ImageItemViewModel itemBase = para as ImageItemViewModel;
if (itemBase != null)
{
@@ -537,6 +598,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
public void ResizeImageExecuted(object para)
{
if (para == null)
{
para = DiagramViewModel.SelectedItem;
}
ImageItemViewModel itemBase = para as ImageItemViewModel;
if (itemBase != null)
{
@@ -546,6 +612,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
public void ResetImageExecuted(object para)
{
if (para == null)
{
para = DiagramViewModel.SelectedItem;
}
ImageItemViewModel itemBase = para as ImageItemViewModel;
if (itemBase != null)
{
@@ -553,10 +623,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
}
}
public void AddVideoExecuted(object para)
public void AddVideoExectued(object para)
{
VideoItemViewModel itemBase = new VideoItemViewModel();
DiagramViewModel?.DirectAddItemCommand.Execute(itemBase);
DiagramViewModel?.AddItemCommand.Execute(itemBase);
if (itemBase.Root != null)
{
_service.DrawModeViewModel.CursorMode = CursorMode.Move;
@@ -566,7 +636,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
public void AddOutLineTextExecuted(object para)
{
OutLineTextDesignerItemViewModel itemBase = new OutLineTextDesignerItemViewModel();
DiagramViewModel?.DirectAddItemCommand.Execute(itemBase);
DiagramViewModel?.AddItemCommand.Execute(itemBase);
if (itemBase.Root != null)
{
_service.DrawModeViewModel.CursorMode = CursorMode.Move;
@@ -575,27 +645,14 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
public void AddBarcodeExecuted(object para)
{
BarcodeDesignerItemViewModel itemBase = new BarcodeDesignerItemViewModel() { Format = (BarcodeFormat)Enum.Parse(typeof(BarcodeFormat), para.ToString()), Text="AIStudio.Wpf.DiagramApp" };
DiagramViewModel?.DirectAddItemCommand.Execute(itemBase);
BarcodeDesignerItemViewModel itemBase = new BarcodeDesignerItemViewModel() { Format = (BarcodeFormat)Enum.Parse(typeof(BarcodeFormat), para.ToString()), Text = "AIStudio.Wpf.DiagramApp" };
DiagramViewModel?.AddItemCommand.Execute(itemBase);
if (itemBase.Root != null)
{
_service.DrawModeViewModel.CursorMode = CursorMode.Move;
}
}
#endregion
private Size MeasureString(OutLineTextDesignerItemViewModel itemBase)
{
var formattedText = new FormattedText(
itemBase.Text,
CultureInfo.CurrentUICulture,
FlowDirection.LeftToRight,
new Typeface(new FontFamily(itemBase.FontViewModel.FontFamily), itemBase.FontViewModel.FontStyle, itemBase.FontViewModel.FontWeight, itemBase.FontViewModel.FontStretch),
itemBase.FontViewModel.FontSize,
Brushes.Black);
return new Size(formattedText.Width, formattedText.Height);
}
#endregion
public virtual void Dispose()
{

View File

@@ -20,8 +20,9 @@ namespace AIStudio.Wpf.Flowchart
{
public SFCViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
Init(true);
}
public SFCViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
if (DiagramViewModel != null)
@@ -47,157 +48,158 @@ namespace AIStudio.Wpf.Flowchart
}
private System.Timers.Timer readDataTimer = new System.Timers.Timer();
protected override void Init()
protected override void Init(bool initNew)
{
base.Init();
base.Init(initNew);
SFCStartNode start = new SFCStartNode() { Left = 0, Top = 60, Text = "S0" };
DiagramViewModel.DirectAddItemCommand.Execute(start);
SFCStartNode start = new SFCStartNode() { Name = nameof(start), Left = 0, Top = 60, Text = "S0" };
DiagramViewModel.Add(start);
SFCConditionNode condition1_1 = new SFCConditionNode() { Left = 0, Top = 120, Text = "X01", Expression = "p0==1&p1<20", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "S0"), SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition1_1);
SFCConditionNode condition1_1 = new SFCConditionNode() { Name = nameof(condition1_1), Left = 0, Top = 120, Text = "X01", Expression = "p0==1&p1<20", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "S0"), SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.Add(condition1_1);
SFCConditionNode condition1_2 = new SFCConditionNode() { Left = 100, Top = 120, Text = "X02", Expression = "p0==1&p1<30", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "S0"), SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition1_2);
SFCConditionNode condition1_2 = new SFCConditionNode() { Name = nameof(condition1_2), Left = 100, Top = 120, Text = "X02", Expression = "p0==1&p1<30", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "S0"), SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.Add(condition1_2);
SFCNodeNode step1 = new SFCNodeNode() { Left = 0, Top = 180, Text = "S1" };
DiagramViewModel.DirectAddItemCommand.Execute(step1);
SFCNodeNode step1 = new SFCNodeNode() { Name = nameof(step1), Left = 0, Top = 180, Text = "S1" };
DiagramViewModel.Add(step1);
SFCActionNode action11 = new SFCActionNode() { Left = 100, Top = 180, Text = "SET_V1", Expression = "1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action11);
SFCActionNode action11 = new SFCActionNode() { Name = nameof(action11), Left = 100, Top = 180, Text = "SET_V1", Expression = "1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DI") };
DiagramViewModel.Add(action11);
SFCActionNode action12 = new SFCActionNode() { Left = 200, Top = 180, Text = "SET_V2", Expression = "1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action12);
SFCActionNode action12 = new SFCActionNode() {Name = nameof(action12), Left = 200, Top = 180, Text = "SET_V2", Expression = "1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DI") };
DiagramViewModel.Add(action12);
SFCActionNode action13 = new SFCActionNode() { Left = 300, Top = 180, Text = "SET_V3", Expression = "1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action13);
SFCActionNode action13 = new SFCActionNode() {Name = nameof(action13), Left = 300, Top = 180, Text = "SET_V3", Expression = "1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DI") };
DiagramViewModel.Add(action13);
SFCActionNode action14 = new SFCActionNode() { Left = 400, Top = 180, Text = "RES_V4", Expression = "0", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action14);
SFCActionNode action14 = new SFCActionNode() {Name = nameof(action14), Left = 400, Top = 180, Text = "RES_V4", Expression = "0", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DI") };
DiagramViewModel.Add(action14);
SFCConditionNode condition2 = new SFCConditionNode() { Left = 0, Top = 240, Text = "X1", Expression = "p0>50", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition2);
SFCConditionNode condition2 = new SFCConditionNode() {Name = nameof(condition2), Left = 0, Top = 240, Text = "X1", Expression = "p0>50", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.Add(condition2);
SFCNodeNode step2 = new SFCNodeNode() { Left = 0, Top = 300, Text = "S2" };
DiagramViewModel.DirectAddItemCommand.Execute(step2);
SFCNodeNode step2 = new SFCNodeNode() {Name = nameof(step2), Left = 0, Top = 300, Text = "S2" };
DiagramViewModel.Add(step2);
SFCActionNode action2 = new SFCActionNode() { Left = 100, Top = 300, Text = "SET_V4", Expression = "1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action2);
SFCActionNode action2 = new SFCActionNode() {Name = nameof(action2), Left = 100, Top = 300, Text = "SET_V4", Expression = "1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DI") };
DiagramViewModel.Add(action2);
SFCConditionNode condition3 = new SFCConditionNode() { Left = 0, Top = 360, Text = "X2", Expression = "p0>70", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition3);
SFCConditionNode condition3 = new SFCConditionNode() {Name = nameof(condition3), Left = 0, Top = 360, Text = "X2", Expression = "p0>70", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.Add(condition3);
SFCNodeNode step3 = new SFCNodeNode() { Left = 0, Top = 420, Text = "S3" };
DiagramViewModel.DirectAddItemCommand.Execute(step3);
SFCNodeNode step3 = new SFCNodeNode() { Name = nameof(step3), Left = 0, Top = 420, Text = "S3" };
DiagramViewModel.Add(step3);
SFCActionNode action3 = new SFCActionNode() { Left = 100, Top = 420, Text = "RES_V1", Expression = "0", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action3);
SFCActionNode action3 = new SFCActionNode() {Name = nameof(action3), Left = 100, Top = 420, Text = "RES_V1", Expression = "0", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DI") };
DiagramViewModel.Add(action3);
SFCConditionNode condition4 = new SFCConditionNode() { Left = 0, Top = 480, Text = "X3", Expression = "p0>80", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition4);
SFCConditionNode condition4 = new SFCConditionNode() {Name = nameof(condition4), Left = 0, Top = 480, Text = "X3", Expression = "p0>80", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") } };
DiagramViewModel.Add(condition4);
SFCCOBeginNode cobegin = new SFCCOBeginNode() { Left = 38, Top = 540, Text = "" };
DiagramViewModel.DirectAddItemCommand.Execute(cobegin);
SFCCOBeginNode cobegin = new SFCCOBeginNode() {Name = nameof(cobegin), Left = 38, Top = 540, Text = "" };
DiagramViewModel.Add(cobegin);
SFCNodeNode step4 = new SFCNodeNode() { Left = 0, Top = 600, Text = "S4" };
DiagramViewModel.DirectAddItemCommand.Execute(step4);
SFCNodeNode step4 = new SFCNodeNode() {Name = nameof(step4), Left = 0, Top = 600, Text = "S4" };
DiagramViewModel.Add(step4);
SFCActionNode action4 = new SFCActionNode() { Left = 100, Top = 600, Text = "RES_V2", Expression = "0", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action4);
SFCActionNode action4 = new SFCActionNode() {Name = nameof(action4), Left = 100, Top = 600, Text = "RES_V2", Expression = "0", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DI") };
DiagramViewModel.Add(action4);
SFCConditionNode condition5 = new SFCConditionNode() { Left = 0, Top = 660, Text = "X4", Expression = "p0==0", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DO") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition5);
SFCConditionNode condition5 = new SFCConditionNode() {Name = nameof(condition5), Left = 0, Top = 660, Text = "X4", Expression = "p0==0", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DO") } };
DiagramViewModel.Add(condition5);
SFCNodeNode step5 = new SFCNodeNode() { Left = 200, Top = 600, Text = "S5" };
DiagramViewModel.DirectAddItemCommand.Execute(step5);
SFCNodeNode step5 = new SFCNodeNode() {Name = nameof(step5), Left = 200, Top = 600, Text = "S5" };
DiagramViewModel.Add(step5);
SFCActionNode action5 = new SFCActionNode() { Left = 300, Top = 600, Text = "RES_V3", Expression = "0", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DI") };
DiagramViewModel.DirectAddItemCommand.Execute(action5);
SFCActionNode action5 = new SFCActionNode() {Name = nameof(action5), Left = 300, Top = 600, Text = "RES_V3", Expression = "0", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DI") };
DiagramViewModel.Add(action5);
SFCConditionNode condition6 = new SFCConditionNode() { Left = 200, Top = 660, Text = "X5", Expression = "p0==0", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DO") } };
DiagramViewModel.DirectAddItemCommand.Execute(condition6);
SFCConditionNode condition6 = new SFCConditionNode() {Name = nameof(condition6), Left = 200, Top = 660, Text = "X5", Expression = "p0==0", LinkPoint = new ObservableCollection<LinkPoint> { SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DO") } };
DiagramViewModel.Add(condition6);
SFCCOEndNode coend = new SFCCOEndNode() { Left = 38, Top = 720, Text = "" };
DiagramViewModel.DirectAddItemCommand.Execute(coend);
SFCCOEndNode coend = new SFCCOEndNode() {Name = nameof(coend), Left = 38, Top = 720, Text = "" };
DiagramViewModel.Add(coend);
ConnectionViewModel connector1_1 = new ConnectionViewModel(start.Output[0], condition1_1.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector1_1);
ConnectionViewModel connector1_1 = new ConnectionViewModel(DiagramViewModel, start.Output[0], condition1_1.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector1_1), };
DiagramViewModel.Add(connector1_1);
ConnectionViewModel connector2_1 = new ConnectionViewModel(condition1_1.Output[0], step1.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector2_1);
ConnectionViewModel connector2_1 = new ConnectionViewModel(DiagramViewModel, condition1_1.Output[0], step1.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector2_1), };
DiagramViewModel.Add(connector2_1);
ConnectionViewModel connector1_2 = new ConnectionViewModel(start.Output[0], condition1_2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector1_2);
ConnectionViewModel connector1_2 = new ConnectionViewModel(DiagramViewModel, start.Output[0], condition1_2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector1_2) };
DiagramViewModel.Add(connector1_2);
ConnectionViewModel connector2_2 = new ConnectionViewModel(condition1_2.Output[0], step1.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector2_2);
ConnectionViewModel connector2_2 = new ConnectionViewModel(DiagramViewModel, condition1_2.Output[0], step1.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector2_2) };
DiagramViewModel.Add(connector2_2);
ConnectionViewModel connector31 = new ConnectionViewModel(step1.Action[0], action11.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector31);
ConnectionViewModel connector31 = new ConnectionViewModel(DiagramViewModel, step1.Action[0], action11.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector31), };
DiagramViewModel.Add(connector31);
ConnectionViewModel connector32 = new ConnectionViewModel(step1.Action[0], action12.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector32);
ConnectionViewModel connector32 = new ConnectionViewModel(DiagramViewModel, step1.Action[0], action12.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector32) };
DiagramViewModel.Add(connector32);
ConnectionViewModel connector33 = new ConnectionViewModel(step1.Action[0], action13.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector33);
ConnectionViewModel connector33 = new ConnectionViewModel(DiagramViewModel, step1.Action[0], action13.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector33) };
DiagramViewModel.Add(connector33);
ConnectionViewModel connector34 = new ConnectionViewModel(step1.Action[0], action14.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector34);
ConnectionViewModel connector34 = new ConnectionViewModel(DiagramViewModel, step1.Action[0], action14.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector34) };
DiagramViewModel.Add(connector34);
ConnectionViewModel connector4 = new ConnectionViewModel(step1.Output[0], condition2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector4);
ConnectionViewModel connector4 = new ConnectionViewModel(DiagramViewModel, step1.Output[0], condition2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector4) };
DiagramViewModel.Add(connector4);
ConnectionViewModel connector5 = new ConnectionViewModel(condition2.Output[0], step2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector5);
ConnectionViewModel connector5 = new ConnectionViewModel(DiagramViewModel, condition2.Output[0], step2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector5) };
DiagramViewModel.Add(connector5);
ConnectionViewModel connector6 = new ConnectionViewModel(step2.Action[0], action2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector6);
ConnectionViewModel connector6 = new ConnectionViewModel(DiagramViewModel, step2.Action[0], action2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector6) };
DiagramViewModel.Add(connector6);
ConnectionViewModel connector7 = new ConnectionViewModel(step2.Output[0], condition3.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector7);
ConnectionViewModel connector7 = new ConnectionViewModel(DiagramViewModel, step2.Output[0], condition3.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector7) };
DiagramViewModel.Add(connector7);
ConnectionViewModel connector8 = new ConnectionViewModel(condition3.Output[0], step3.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector8);
ConnectionViewModel connector8 = new ConnectionViewModel(DiagramViewModel, condition3.Output[0], step3.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector8) };
DiagramViewModel.Add(connector8);
ConnectionViewModel connector9 = new ConnectionViewModel(step3.Action[0], action3.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector9);
ConnectionViewModel connector9 = new ConnectionViewModel(DiagramViewModel, step3.Action[0], action3.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector9) };
DiagramViewModel.Add(connector9);
ConnectionViewModel connector10 = new ConnectionViewModel(step3.Output[0], condition4.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector10);
ConnectionViewModel connector10 = new ConnectionViewModel(DiagramViewModel, step3.Output[0], condition4.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector10) };
DiagramViewModel.Add(connector10);
ConnectionViewModel connector11 = new ConnectionViewModel(condition4.Output[0], cobegin.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector11);
ConnectionViewModel connector11 = new ConnectionViewModel(DiagramViewModel, condition4.Output[0], cobegin.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector11) };
DiagramViewModel.Add(connector11);
ConnectionViewModel connector12 = new ConnectionViewModel(cobegin.Output[0], step4.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector12);
ConnectionViewModel connector12 = new ConnectionViewModel(DiagramViewModel, cobegin.Output[0], step4.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector12) };
DiagramViewModel.Add(connector12);
ConnectionViewModel connector13 = new ConnectionViewModel(step4.Action[0], action4.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector13);
ConnectionViewModel connector13 = new ConnectionViewModel(DiagramViewModel, step4.Action[0], action4.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector13) };
DiagramViewModel.Add(connector13);
ConnectionViewModel connector14 = new ConnectionViewModel(step4.Output[0], condition5.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector14);
ConnectionViewModel connector14 = new ConnectionViewModel(DiagramViewModel, step4.Output[0], condition5.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector14) };
DiagramViewModel.Add(connector14);
ConnectionViewModel connector15 = new ConnectionViewModel(cobegin.Output[1], step5.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector15);
ConnectionViewModel connector15 = new ConnectionViewModel(DiagramViewModel, cobegin.Output[1], step5.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector15), };
DiagramViewModel.Add(connector15);
ConnectionViewModel connector16 = new ConnectionViewModel(step5.Action[0], action5.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector16);
ConnectionViewModel connector16 = new ConnectionViewModel(DiagramViewModel, step5.Action[0], action5.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector16), };
DiagramViewModel.Add(connector16);
ConnectionViewModel connector17 = new ConnectionViewModel(step5.Output[0], condition6.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector17);
ConnectionViewModel connector17 = new ConnectionViewModel(DiagramViewModel, step5.Output[0], condition6.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector17), };
DiagramViewModel.Add(connector17);
ConnectionViewModel connector18 = new ConnectionViewModel(condition5.Output[0], coend.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector18);
ConnectionViewModel connector18 = new ConnectionViewModel(DiagramViewModel, condition5.Output[0], coend.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector18), };
DiagramViewModel.Add(connector18);
ConnectionViewModel connector19 = new ConnectionViewModel(condition6.Output[0], coend.Input[1], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector19);
ConnectionViewModel connector19 = new ConnectionViewModel(DiagramViewModel, condition6.Output[0], coend.Input[1], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector19), };
DiagramViewModel.Add(connector19);
ConnectionViewModel connector20 = new ConnectionViewModel(coend.Output[0], start.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(connector20);
ConnectionViewModel connector20 = new ConnectionViewModel(DiagramViewModel, coend.Output[0], start.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(connector20), };
DiagramViewModel.Add(connector20);
#region
TextDesignerItemViewModel despcription = new TextDesignerItemViewModel()
{
Name = nameof(despcription),
Left = 230,
Top = 270,
ItemWidth = 300,
@@ -211,67 +213,66 @@ namespace AIStudio.Wpf.Flowchart
};
despcription.FontViewModel.HorizontalAlignment = HorizontalAlignment.Left;
despcription.FontViewModel.VerticalAlignment = VerticalAlignment.Top;
DiagramViewModel.DirectAddItemCommand.Execute(despcription);
DiagramViewModel.Add(despcription);
Simulate_ListViewModel list = new Simulate_ListViewModel()
{
Name = nameof(list),
Left = 410,
Top = 390,
};
DiagramViewModel.DirectAddItemCommand.Execute(list);
DiagramViewModel.Add(list);
Simulate_StartViewModel btnstart = new Simulate_StartViewModel() { Left = 0, Top = 0, LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "S0"), };
DiagramViewModel.DirectAddItemCommand.Execute(btnstart);
Simulate_StartViewModel btnstart = new Simulate_StartViewModel() { Name = nameof(btnstart), Left = 0, Top = 0, LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "S0"), };
DiagramViewModel.Add(btnstart);
Simulate_TankViewModel tank1 = new Simulate_TankViewModel() { Left = 100, Top = 43, ItemWidth = 48, ItemHeight = 60, Text = "T1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T1") };
DiagramViewModel.DirectAddItemCommand.Execute(tank1);
Simulate_TankViewModel tank1 = new Simulate_TankViewModel() {Name = nameof(tank1), Left = 100, Top = 43, ItemWidth = 48, ItemHeight = 60, Text = "T1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T1") };
DiagramViewModel.Add(tank1);
Simulate_SolenoidViewModel k1 = new Simulate_SolenoidViewModel() { Left = 200, Top = 0, Text = "K1", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DO") };
DiagramViewModel.DirectAddItemCommand.Execute(k1);
Simulate_SolenoidViewModel k1 = new Simulate_SolenoidViewModel() {Name = nameof(k1), Left = 200, Top = 0, Text = "K1", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DO") };
DiagramViewModel.Add(k1);
Simulate_SolenoidViewModel k2 = new Simulate_SolenoidViewModel() { Left = 200, Top = 60, Text = "K2", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DO") };
DiagramViewModel.DirectAddItemCommand.Execute(k2);
Simulate_SolenoidViewModel k2 = new Simulate_SolenoidViewModel() {Name = nameof(k2), Left = 200, Top = 60, Text = "K2", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DO") };
DiagramViewModel.Add(k2);
Simulate_SolenoidViewModel k3 = new Simulate_SolenoidViewModel() { Left = 200, Top = 120, Text = "K3", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DO") };
DiagramViewModel.DirectAddItemCommand.Execute(k3);
Simulate_SolenoidViewModel k3 = new Simulate_SolenoidViewModel() {Name = nameof(k3), Left = 200, Top = 120, Text = "K3", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DO") };
DiagramViewModel.Add(k3);
Simulate_TankViewModel tank2 = new Simulate_TankViewModel() { Left = 300, Top = 28, Text = "T2", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") };
Simulate_TankViewModel tank2 = new Simulate_TankViewModel() {Name = nameof(tank2), Left = 300, Top = 28, Text = "T2", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") };
DiagramViewModel.DirectAddItemCommand.Execute(tank2);
DiagramViewModel.Add(tank2);
Simulate_SolenoidViewModel k4 = new Simulate_SolenoidViewModel() { Left = 400, Top = 60, Text = "K4", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DO") };
DiagramViewModel.DirectAddItemCommand.Execute(k4);
Simulate_SolenoidViewModel k4 = new Simulate_SolenoidViewModel() {Name = nameof(k4), Left = 400, Top = 60, Text = "K4", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DO") };
DiagramViewModel.Add(k4);
Simulate_TankViewModel tank3 = new Simulate_TankViewModel() { Left = 500, Top = 103, ItemWidth = 48, ItemHeight = 60, Text = "T3", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T3") };
DiagramViewModel.DirectAddItemCommand.Execute(tank3);
Simulate_TankViewModel tank3 = new Simulate_TankViewModel() {Name = nameof(tank3), Left = 500, Top = 103, ItemWidth = 48, ItemHeight = 60, Text = "T3", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T3") };
DiagramViewModel.Add(tank3);
ConnectionViewModel conn1 = new ConnectionViewModel(tank1.Output[0], k1.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(conn1);
ConnectionViewModel conn1 = new ConnectionViewModel(DiagramViewModel, tank1.Output[0], k1.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(conn1), };
DiagramViewModel.Add(conn1);
ConnectionViewModel conn2 = new ConnectionViewModel(tank1.Output[0], k2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(conn2);
ConnectionViewModel conn2 = new ConnectionViewModel(DiagramViewModel, tank1.Output[0], k2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(conn2) };
DiagramViewModel.Add(conn2);
ConnectionViewModel conn3 = new ConnectionViewModel(tank1.Output[0], k3.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(conn3);
ConnectionViewModel conn3 = new ConnectionViewModel(DiagramViewModel, tank1.Output[0], k3.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(conn3) };
DiagramViewModel.Add(conn3);
ConnectionViewModel conn4 = new ConnectionViewModel(k1.Output[0], tank2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(conn4);
ConnectionViewModel conn4 = new ConnectionViewModel(DiagramViewModel, k1.Output[0], tank2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(conn4) };
DiagramViewModel.Add(conn4);
ConnectionViewModel conn5 = new ConnectionViewModel(k2.Output[0], tank2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(conn5);
ConnectionViewModel conn5 = new ConnectionViewModel(DiagramViewModel, k2.Output[0], tank2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(conn5) };
DiagramViewModel.Add(conn5);
ConnectionViewModel conn6 = new ConnectionViewModel(k3.Output[0], tank2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(conn6);
ConnectionViewModel conn6 = new ConnectionViewModel(DiagramViewModel, k3.Output[0], tank2.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(conn6) };
DiagramViewModel.Add(conn6);
ConnectionViewModel conn7 = new ConnectionViewModel(tank2.Output[1], k4.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(conn7);
ConnectionViewModel conn7 = new ConnectionViewModel(DiagramViewModel, tank2.Output[1], k4.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(conn7), };
DiagramViewModel.Add(conn7);
ConnectionViewModel conn8 = new ConnectionViewModel(k4.Output[0], tank3.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
DiagramViewModel.DirectAddItemCommand.Execute(conn8);
ConnectionViewModel conn8 = new ConnectionViewModel(DiagramViewModel, k4.Output[0], tank3.Input[0], _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode) { Name = nameof(conn8) };
DiagramViewModel.Add(conn8);
#endregion
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
SFCService.InitData(DiagramViewModel.Items.OfType<SFCNode>().ToList(), DiagramViewModel.Items.OfType<ConnectionViewModel>().ToList(), DiagramViewModel);
readDataTimer.Elapsed += timeCycle;
@@ -298,7 +299,7 @@ namespace AIStudio.Wpf.Flowchart
foreach (var viewModel in DiagramViewModels)
{
SFCService.DisposeData(viewModel);
SFCService.Dispose(viewModel);
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AIStudio.Wpf.DiagramApp.Models;
using AIStudio.Wpf.DiagramDesigner;
namespace AIStudio.Wpf.DiagramApp.ViewModels
{
public class ScriptViewModel : PageViewModel
{
public ScriptViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
Init(true);
}
public ScriptViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
if (DiagramViewModel != null)
{
}
}
protected override void InitDiagramViewModel()
{
base.InitDiagramViewModel();
}
}
}

View File

@@ -21,20 +21,18 @@ using AIStudio.Wpf.SFC.Models;
using System.Windows;
using System;
using AIStudio.Wpf.DiagramDesigner.Models;
using AIStudio.Wpf.DiagramDesigner.ViewModels;
using AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel;
namespace AIStudio.Wpf.DiagramApp.ViewModels
{
public class ToolBoxViewModel : BindableBase
{
private IDiagramServiceProvider _service
{
get
{
return DiagramServicesProvider.Instance.Provider;
}
}
public ToolBoxViewModel()
private MainWindowViewModel _mainWindowViewModel;
public ToolBoxViewModel(MainWindowViewModel mainWindowViewModel)
{
_mainWindowViewModel = mainWindowViewModel;
Init();
}
@@ -296,14 +294,14 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
private void AddMyItem()
{
if (_service.SelectedItems != null)
if (_mainWindowViewModel?.PageViewModel?.DiagramViewModel != null)
{
DiagramDocument diagramDocument = new DiagramDocument();
diagramDocument.DiagramItems = new List<DiagramItem>();
DiagramItem diagramItem = new DiagramItem();
var selectedDesignerItems = _service.SelectedItems.OfType<DesignerItemViewModelBase>();
var selectedConnections = _service.SelectedItems.OfType<ConnectionViewModel>();
var selectedDesignerItems = _mainWindowViewModel?.PageViewModel?.DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>();
var selectedConnections = _mainWindowViewModel?.PageViewModel?.DiagramViewModel.SelectedItems.OfType<ConnectionViewModel>();
diagramItem.DesignerItems = selectedDesignerItems.Select(p => p.ToSerializableItem(".json")).Where(p => p != null).ToList();
diagramItem.Connections = selectedConnections.Select(p => p.ToSerializableItem(".json")).Where(p => p != null).ToList();

File diff suppressed because it is too large Load Diff

View File

@@ -31,8 +31,6 @@ namespace AIStudio.Wpf.DiagramApp
{
InitializeComponent();
this.HookEvents();
MainWindowViewModel = new MainWindowViewModel();
this.DataContext = MainWindowViewModel;
this.Closing += MainWindow_Closing;
@@ -44,33 +42,12 @@ namespace AIStudio.Wpf.DiagramApp
e.Handled = MainWindowViewModel.KeyExecuted(e);
}
private void HookEvents()
{
this.PreviewMouseWheel += this.OnPreviewMouseWheel;
}
private void ZoomSlider_OnValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
var textFormattingMode = e.NewValue > 1.0 || Math.Abs(e.NewValue - 1.0) < double.Epsilon ? TextFormattingMode.Ideal : TextFormattingMode.Display;
TextOptions.SetTextFormattingMode(this, textFormattingMode);
}
private void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (Keyboard.IsKeyDown(Key.LeftCtrl) == false
&& Keyboard.IsKeyDown(Key.RightCtrl) == false)
{
return;
}
var newZoomValue = this.zoomSlider.Value + (e.Delta > 0 ? 0.1 : -0.1);
this.zoomSlider.Value = Math.Max(Math.Min(newZoomValue, this.zoomSlider.Maximum), this.zoomSlider.Minimum);
e.Handled = true;
}
private void btnPrint_Click(object sender, RoutedEventArgs e)
{
PrintDialog printDialog = new PrintDialog();

View File

@@ -23,7 +23,7 @@
<TabControl Style="{StaticResource UniformTabControlStyle}" >
<TabItem Header="填充" Height="34">
<StackPanel
DataContext="{Binding SelectedItem.ColorViewModel.FillColor}"
DataContext="{Binding SelectedItemViewModel.ColorViewModel.FillColor}"
Visibility="{Binding .,Converter={StaticResource NullableToVisibilityConverter}}">
<StackPanel>
<RadioButton Margin="5" IsChecked="{Binding BrushType,Converter={dd:ConverterValueMapToBool Parameter='None'}, ConverterParameter='None'}" Content="无填充" />
@@ -58,7 +58,7 @@
</DockPanel>
<StackPanel Visibility="{Binding BrushType,Converter={dd:ConverterValueMapSetToVisibility},ConverterParameter='LinearGradientBrush^RadialGradientBrush'}">
<DockPanel Visibility="{Binding BrushType,Converter={dd:ConverterValueMapSetToVisibility},ConverterParameter='LinearGradientBrush'}">
<Fluent:ComboBox DockPanel.Dock="Right" Margin="5" Size="Small" Width="140" IsEditable="False" helper:EnumHelper.Enum="{x:Type dd:LinearOrientation}" SelectedItem="{Binding LinearOrientation}">
<Fluent:ComboBox DockPanel.Dock="Right" Margin="5" Size="Small" Width="140" IsEditable="False" dd:EnumHelper.Enum="{x:Type dd:LinearOrientation}" SelectedItem="{Binding LinearOrientation}">
<Fluent:ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding .,Converter={StaticResource EnumDescriptionConverter}}" />
@@ -68,7 +68,7 @@
<TextBlock Text="方向" VerticalAlignment="Center" Margin="5"/>
</DockPanel>
<DockPanel Visibility="{Binding BrushType,Converter={dd:ConverterValueMapSetToVisibility},ConverterParameter='RadialGradientBrush'}">
<Fluent:ComboBox DockPanel.Dock="Right" Margin="5" Size="Small" Width="140" IsEditable="False" helper:EnumHelper.Enum="{x:Type dd:RadialOrientation}" SelectedItem="{Binding RadialOrientation}">
<Fluent:ComboBox DockPanel.Dock="Right" Margin="5" Size="Small" Width="140" IsEditable="False" dd:EnumHelper.Enum="{x:Type dd:RadialOrientation}" SelectedItem="{Binding RadialOrientation}">
<Fluent:ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding .,Converter={StaticResource EnumDescriptionConverter}}" />
@@ -104,7 +104,7 @@
</TabItem>
<TabItem Header="线条" Height="34">
<StackPanel
DataContext="{Binding SelectedItem.ColorViewModel.LineColor}"
DataContext="{Binding SelectedItemViewModel.ColorViewModel.LineColor}"
Visibility="{Binding .,Converter={StaticResource NullableToVisibilityConverter}}">
<StackPanel>
<RadioButton Margin="5" IsChecked="{Binding BrushType,Converter={dd:ConverterValueMapToBool Parameter='None'}, ConverterParameter='None'}" Content="无线条" />
@@ -138,7 +138,7 @@
</DockPanel>
<StackPanel Visibility="{Binding BrushType,Converter={dd:ConverterValueMapSetToVisibility},ConverterParameter='LinearGradientBrush^RadialGradientBrush'}">
<DockPanel Visibility="{Binding BrushType,Converter={dd:ConverterValueMapSetToVisibility},ConverterParameter='LinearGradientBrush'}">
<Fluent:ComboBox DockPanel.Dock="Right" Margin="5" Size="Small" Width="140" IsEditable="False" helper:EnumHelper.Enum="{x:Type dd:LinearOrientation}" SelectedItem="{Binding LinearOrientation}">
<Fluent:ComboBox DockPanel.Dock="Right" Margin="5" Size="Small" Width="140" IsEditable="False" dd:EnumHelper.Enum="{x:Type dd:LinearOrientation}" SelectedItem="{Binding LinearOrientation}">
<Fluent:ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding .,Converter={StaticResource EnumDescriptionConverter}}" />
@@ -148,7 +148,7 @@
<TextBlock Text="方向" VerticalAlignment="Center" Margin="5"/>
</DockPanel>
<DockPanel Visibility="{Binding BrushType,Converter={dd:ConverterValueMapSetToVisibility},ConverterParameter='RadialGradientBrush'}">
<Fluent:ComboBox DockPanel.Dock="Right" Margin="5" Size="Small" Width="140" IsEditable="False" helper:EnumHelper.Enum="{x:Type dd:RadialOrientation}" SelectedItem="{Binding RadialOrientation}">
<Fluent:ComboBox DockPanel.Dock="Right" Margin="5" Size="Small" Width="140" IsEditable="False" dd:EnumHelper.Enum="{x:Type dd:RadialOrientation}" SelectedItem="{Binding RadialOrientation}">
<Fluent:ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding .,Converter={StaticResource EnumDescriptionConverter}}" />
@@ -198,21 +198,21 @@
<TabControl Style="{StaticResource UniformTabControlStyle}">
<TabItem Header="图片" Height="34">
<UniformGrid Columns="2" VerticalAlignment="Top">
<Fluent:Button Header="插入图片" VerticalAlignment="Top" Command="{Binding AddImageCommand}">
<Fluent:Button Header="插入图片" VerticalAlignment="Top" Command="{Binding PageViewModel.AddImageCommand}">
<Fluent:Button.LargeIcon>
<iconPacks:PackIconMaterial Kind="Image" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Fluent:Button.LargeIcon>
</Fluent:Button>
<Fluent:Button Header="改变图片" VerticalAlignment="Top" Command="{Binding EditImageCommand}">
<Fluent:Button Header="改变图片" VerticalAlignment="Top" Command="{Binding PageViewModel.EditImageCommand}">
<Fluent:Button.LargeIcon>
<iconPacks:PackIconMaterial Kind="ImageEdit" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Fluent:Button.LargeIcon>
</Fluent:Button>
<Fluent:SplitButton Header="图片裁剪" VerticalAlignment="Top" HorizontalAlignment="Stretch" Command="{Binding ResizeImageCommand}">
<Fluent:SplitButton Header="图片裁剪" VerticalAlignment="Top" HorizontalAlignment="Stretch" Command="{Binding PageViewModel.ResizeImageCommand}">
<Fluent:SplitButton.LargeIcon>
<iconPacks:PackIconMaterial Kind="ImagePlus" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Fluent:SplitButton.LargeIcon>
<ListBox helper:EnumHelper.Enum="{x:Type dd:ClipMode}" SelectedItem="{Binding SelectedItem.ClipMode}" BorderThickness="0">
<ListBox dd:EnumHelper.Enum="{x:Type dd:ClipMode}" SelectedItem="{Binding SelectedItemViewModel.ClipMode}" BorderThickness="0">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding .,Converter={StaticResource EnumDescriptionConverter}}" />
@@ -220,7 +220,7 @@
</ListBox.ItemTemplate>
</ListBox>
</Fluent:SplitButton>
<Fluent:Button Header="原始图" VerticalAlignment="Top" Command="{Binding ResetImageCommand}">
<Fluent:Button Header="原始图" VerticalAlignment="Top" Command="{Binding PageViewModel.ResetImageCommand}">
<Fluent:Button.LargeIcon>
<iconPacks:PackIconMaterial Kind="ImageRemove" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Fluent:Button.LargeIcon>
@@ -229,7 +229,7 @@
</TabItem>
<TabItem Header="视频" Height="34">
<UniformGrid Columns="2" VerticalAlignment="Top">
<Fluent:Button Header="插入视频" VerticalAlignment="Top" Command="{Binding AddVideoCommand}">
<Fluent:Button Header="插入视频" VerticalAlignment="Top" Command="{Binding PageViewModel.AddVideoCommand}">
<Fluent:Button.LargeIcon>
<iconPacks:PackIconMaterial Kind="Video" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Fluent:Button.LargeIcon>
@@ -238,12 +238,12 @@
</TabItem>
<TabItem Header="二维码" Height="34">
<UniformGrid Columns="2" VerticalAlignment="Top">
<Fluent:Button Header="插入二维码" VerticalAlignment="Top" Command="{Binding AddBarcodeCommand}" CommandParameter="QR_CODE">
<Fluent:Button Header="插入二维码" VerticalAlignment="Top" Command="{Binding PageViewModel.AddBarcodeCommand}" CommandParameter="QR_CODE">
<Fluent:Button.LargeIcon>
<iconPacks:PackIconMaterial Kind="Qrcode" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Fluent:Button.LargeIcon>
</Fluent:Button>
<Fluent:Button Header="插入条形码" VerticalAlignment="Top" Command="{Binding AddBarcodeCommand}" CommandParameter="CODE_39">
<Fluent:Button Header="插入条形码" VerticalAlignment="Top" Command="{Binding PageViewModel.AddBarcodeCommand}" CommandParameter="CODE_39">
<Fluent:Button.LargeIcon>
<iconPacks:PackIconMaterial Kind="Barcode" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Fluent:Button.LargeIcon>
@@ -254,7 +254,7 @@
</ControlTemplate>
<ControlTemplate TargetType="Control" x:Key="PropertyTemplate">
<dd:PropertiesView SelectedObject="{Binding SelectedItem}">
<dd:PropertiesView SelectedObject="{Binding SelectedItemViewModel}">
<dd:PropertiesView.Resources>
<Style x:Key="ActTypeStyle" TargetType="{x:Type ContentControl}">
<Setter Property="ContentTemplate">

View File

@@ -0,0 +1,228 @@
<Project>
<PropertyGroup>
<AssemblyName>AIStudio.Wpf.DiagramDesigner.Additionals</AssemblyName>
<IntermediateOutputPath>obj\Debug\</IntermediateOutputPath>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<MSBuildProjectExtensionsPath>F:\aistudio.-wpf.-diagram\AIStudio.Wpf.DiagramDesigner.Additionals\obj\</MSBuildProjectExtensionsPath>
<_TargetAssemblyProjectName>AIStudio.Wpf.DiagramDesigner.Additionals</_TargetAssemblyProjectName>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk.WindowsDesktop" />
<PropertyGroup>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<Company>AIStudio.Wpf.Controls</Company>
<Authors>akwkevin</Authors>
<PackageProjectUrl>https://gitee.com/akwkevin</PackageProjectUrl>
<PackageIcon>A.png</PackageIcon>
<PackageIconUrl />
<NeutralLanguage />
<Version>1.0.1</Version>
<Description>一个Wpf的Diagram控件帮助库</Description>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Fluent.Ribbon" Version="8.0.3" />
<PackageReference Include="MahApps.Metro.IconPacks" Version="4.8.0" />
<PackageReference Include="AIStudio.Wpf.Svg2XamlExtension" Version="1.2.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ZXing.Net" Version="0.16.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AIStudio.Wpf.DiagramDesigner\AIStudio.Wpf.DiagramDesigner.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="A.png">
<Pack>True</Pack>
<PackagePath>
</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<ReferencePath Include="F:\aistudio.-wpf.-diagram\AIStudio.Wpf.DiagramDesigner\bin\Debug\net461\AIStudio.Wpf.DiagramDesigner.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\aistudio.wpf.svg2xamlextension\1.2.2\lib\net461\AIStudio.Wpf.Svg2XamlExtension.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\controlzex\4.4.0\lib\net45\ControlzEx.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\fluent.ribbon\8.0.3\lib\net452\Fluent.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.BootstrapIcons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.BoxIcons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.Codicons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.Core.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.Entypo.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.EvaIcons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.FeatherIcons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.FileIcons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.Fontaudio.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.FontAwesome.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.ForkAwesome.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.Ionicons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.JamIcons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.Material.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.MaterialDesign.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.MaterialLight.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.Microns.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.Modern.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.Octicons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.PicolIcons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.PixelartIcons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.RadixIcons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.RemixIcon.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.RPGAwesome.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.SimpleIcons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.Typicons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.Unicons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.VaadinIcons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.WeatherIcons.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\mahapps.metro.iconpacks\4.8.0\lib\net46\MahApps.Metro.IconPacks.Zondicons.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\Microsoft.Win32.Primitives.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\microsoft.xaml.behaviors.wpf\1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netfx.force.conflicts.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\newtonsoft.json\13.0.1\lib\net45\Newtonsoft.Json.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\PresentationCore.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\PresentationFramework.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\svgpathproperties\1.1.2\lib\netstandard2.0\SvgPathProperties.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.AppContext.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\system.codedom\7.0.0\lib\netstandard2.0\System.CodeDom.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Collections.Concurrent.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Collections.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Collections.NonGeneric.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Collections.Specialized.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.ComponentModel.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.ComponentModel.EventBasedAsync.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.ComponentModel.Primitives.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.ComponentModel.TypeConverter.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Console.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Data.Common.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Data.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Diagnostics.Contracts.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Diagnostics.Debug.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Diagnostics.FileVersionInfo.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Diagnostics.Process.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Diagnostics.StackTrace.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Diagnostics.TextWriterTraceListener.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Diagnostics.Tools.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Diagnostics.TraceSource.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Diagnostics.Tracing.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Drawing.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Drawing.Primitives.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Dynamic.Runtime.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Globalization.Calendars.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Globalization.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Globalization.Extensions.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.IO.Compression.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.IO.Compression.FileSystem.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.IO.Compression.ZipFile.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.IO.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.IO.FileSystem.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.IO.FileSystem.DriveInfo.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.IO.FileSystem.Primitives.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.IO.FileSystem.Watcher.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.IO.IsolatedStorage.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.IO.MemoryMappedFiles.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.IO.Pipes.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.IO.UnmanagedMemoryStream.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Linq.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Linq.Expressions.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Linq.Parallel.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Linq.Queryable.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\system.management\7.0.0\lib\netstandard2.0\System.Management.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.Http.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.NameResolution.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.NetworkInformation.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.Ping.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.Primitives.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.Requests.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.Security.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.Sockets.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.WebHeaderCollection.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.WebSockets.Client.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Net.WebSockets.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Numerics.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.ObjectModel.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\system.reactive\5.0.0\lib\netstandard2.0\System.Reactive.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Reflection.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Reflection.Extensions.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Reflection.Primitives.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Resources.Reader.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Resources.ResourceManager.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Resources.Writer.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\system.runtime.compilerservices.unsafe\4.5.3\ref\net461\System.Runtime.CompilerServices.Unsafe.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.CompilerServices.VisualC.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.Extensions.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.Handles.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.InteropServices.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.InteropServices.RuntimeInformation.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.Numerics.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Runtime.Serialization.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.Serialization.Formatters.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.Serialization.Json.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.Serialization.Primitives.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.Serialization.Xml.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Security.Claims.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Security.Cryptography.Algorithms.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Security.Cryptography.Csp.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Security.Cryptography.Encoding.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Security.Cryptography.Primitives.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Security.Cryptography.X509Certificates.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Security.Principal.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Security.SecureString.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Text.Encoding.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Text.Encoding.Extensions.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Text.RegularExpressions.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Threading.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Threading.Overlapped.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Threading.Tasks.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\system.threading.tasks.extensions\4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Threading.Tasks.Parallel.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Threading.Thread.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Threading.ThreadPool.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Threading.Timer.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.ValueTuple.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Web.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Web.Extensions.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Windows.Controls.Ribbon.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Windows.Forms.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xaml.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.Linq.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Xml.ReaderWriter.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Xml.XDocument.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Xml.XmlDocument.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Xml.XmlSerializer.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Xml.XPath.dll" />
<ReferencePath Include="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Xml.XPath.XDocument.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\UIAutomationClient.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\UIAutomationClientsideProviders.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\UIAutomationProvider.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\UIAutomationTypes.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\WindowsBase.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\WindowsFormsIntegration.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\wpfanimatedgif\2.0.0\lib\net40\WpfAnimatedGif.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\zxing.net\0.16.8\lib\net461\zxing.dll" />
<ReferencePath Include="C:\Users\Administrator\.nuget\packages\zxing.net\0.16.8\lib\net461\zxing.presentation.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.ComponentModel.Annotations.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Reflection.Emit.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Reflection.Emit.ILGeneration.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Reflection.Emit.Lightweight.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Runtime.InteropServices.WindowsRuntime.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.ServiceModel.Duplex.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.ServiceModel.Http.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.ServiceModel.NetTcp.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.ServiceModel.Primitives.dll" />
<ReferencePath Include="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.ServiceModel.Security.dll" />
</ItemGroup>
<ItemGroup>
<Compile Include="F:\aistudio.-wpf.-diagram\AIStudio.Wpf.DiagramDesigner.Additionals\obj\Debug\net461\Controls\Barcode.g.cs" />
<Compile Include="F:\aistudio.-wpf.-diagram\AIStudio.Wpf.DiagramDesigner.Additionals\obj\Debug\net461\Controls\GradientStopControl.g.cs" />
<Compile Include="F:\aistudio.-wpf.-diagram\AIStudio.Wpf.DiagramDesigner.Additionals\obj\Debug\net461\Controls\SliderRotation.g.cs" />
<Compile Include="F:\aistudio.-wpf.-diagram\AIStudio.Wpf.DiagramDesigner.Additionals\obj\Debug\net461\GeneratedInternalTypeHelper.g.cs" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="C:\Users\Administrator\.nuget\packages\wpfanalyzers\3.5.4\analyzers\dotnet\cs\Gu.Roslyn.Extensions.dll" />
<Analyzer Include="C:\Users\Administrator\.nuget\packages\wpfanalyzers\3.5.4\analyzers\dotnet\cs\WpfAnalyzers.dll" />
</ItemGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk.WindowsDesktop" />
</Project>

View File

@@ -13,26 +13,31 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Converters
{
if (values != null && values.Length > 2)
{
var diagram = values[0] as AIStudio.Wpf.DiagramDesigner.DiagramControl;
var zoomValue = (double)values[1];
var pageunit = (PageUnit)values[2];
var unit = Unit.Cm;
if (pageunit > PageUnit.km)
try
{
unit = Unit.Inch;
}
Vector vector = System.Windows.Media.VisualTreeHelper.GetOffset(diagram);
if (parameter?.ToString() == "Y")
{
var value = 0 - (unit == Unit.Cm? ScreenHelper.WidthToCm(vector.Y - 20) : ScreenHelper.WidthToInch(vector.Y - 20))/ zoomValue;
return value;
}
else
{
var value = 0 - (unit == Unit.Cm ? ScreenHelper.WidthToCm(vector.X - 20) : ScreenHelper.WidthToInch(vector.X - 20)) / zoomValue;
return value;
var diagram = values[0] as FrameworkElement;
var zoomValue = (double)values[1];
var pageunit = (PageUnit)values[2];
var unit = Unit.Cm;
if (pageunit > PageUnit.km)
{
unit = Unit.Inch;
}
Vector vector = System.Windows.Media.VisualTreeHelper.GetOffset(diagram);
if (parameter?.ToString() == "Y")
{
var value = 0 - (unit == Unit.Cm ? ScreenHelper.WidthToCm(vector.Y - 20) : ScreenHelper.WidthToInch(vector.Y - 20)) / zoomValue;
return value;
}
else
{
var value = 0 - (unit == Unit.Cm ? ScreenHelper.WidthToCm(vector.X - 20) : ScreenHelper.WidthToInch(vector.X - 20)) / zoomValue;
return value;
}
}
catch { }
}
return 0;
}

View File

@@ -34,15 +34,20 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
return new DesignerItemBase(this, Format.ToString());
}
protected override void Init(IDiagramViewModel root)
protected override void Init(IDiagramViewModel root, bool initNew)
{
base.Init(root);
base.Init(root, initNew);
CustomText = true;
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
}
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{
base.LoadDesignerItemViewModel(designerbase);

View File

@@ -13,7 +13,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
{
this.Title = "矢量文本";
this.Text = item.Text;
this.FontViewModel = CopyHelper.Mapper<FontViewModel, IFontViewModel>(item.FontViewModel);
this.FontViewModel = CopyHelper.Mapper(item.FontViewModel);
}
private IFontViewModel _fontViewModel;

View File

@@ -35,12 +35,16 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
return new TextDesignerItem(this);
}
protected override void Init(IDiagramViewModel root)
protected override void Init(IDiagramViewModel root, bool initNew)
{
base.Init(root);
base.Init(root, initNew);
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
}
protected override void InitNew()
{
base.InitNew();
FontViewModel.FontFamily = "Arial";
FontViewModel.FontSize = 36;
}
@@ -85,7 +89,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
if (visualiserService.ShowDialog(data) == true)
{
Text = data.Text;
FontViewModel = CopyHelper.Mapper<FontViewModel, IFontViewModel>(data.FontViewModel);
FontViewModel = CopyHelper.Mapper(data.FontViewModel);
AutoSize();
return true;
}

View File

@@ -32,11 +32,16 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
return new PathDesignerItem(this);
}
protected override void Init(IDiagramViewModel root)
protected override void Init(IDiagramViewModel root, bool initNew)
{
base.Init(root);
base.Init(root, initNew);
this.ShowConnectors = false;
}
protected override void InitNew()
{
base.InitNew();
}
}
}

View File

@@ -35,14 +35,19 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
return new PersistDesignerItem(this);
}
protected override void Init(IDiagramViewModel root)
protected override void Init(IDiagramViewModel root, bool initNew)
{
base.Init(root);
base.Init(root, initNew);
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
this.ShowConnectors = false;
}
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{
base.LoadDesignerItemViewModel(designerbase);

View File

@@ -35,15 +35,20 @@ namespace AIStudio.Wpf.DiagramDesigner.Additionals.Extensions.ViewModels
return new SettingsDesignerItem(this);
}
protected override void Init(IDiagramViewModel root)
protected override void Init(IDiagramViewModel root, bool initNew)
{
base.Init(root);
base.Init(root, initNew);
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
this.ShowConnectors = false;
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
protected override void InitNew()
{
base.InitNew();
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
{
base.LoadDesignerItemViewModel(designerbase);

View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Company>AIStudio.Wpf.Controls</Company>
<Authors>akwkevin</Authors>
<PackageProjectUrl>https://gitee.com/akwkevin</PackageProjectUrl>
<PackageIcon>A.png</PackageIcon>
<PackageIconUrl />
<NeutralLanguage />
<Version>1.0.7</Version>
<Description>一个Wpf的流程图控件Json对象</Description>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AIStudio.Wpf.DiagramDesigner\AIStudio.Wpf.DiagramDesigner.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,8 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using AIStudio.Wpf.DiagramDesigner.Serializable.ViewModels;
namespace AIStudio.Wpf.Flowchart.Models
namespace AIStudio.Wpf.DiagramDesigner.Serializable
{
/// <summary>
///
@@ -88,6 +87,7 @@ namespace AIStudio.Wpf.Flowchart.Models
{
get; set;
}
/// <summary>
/// Gets or sets the color.
/// </summary>
@@ -98,6 +98,62 @@ namespace AIStudio.Wpf.Flowchart.Models
{
get; set;
}
/// <summary>
/// Gets or sets the color.
/// </summary>
/// <value>
/// The color.
/// </value>
public string LineColor
{
get; set;
}
/// <summary>
/// Gets or sets the color.
/// </summary>
/// <value>
/// The color.
/// </value>
public string FontColor
{
get; set;
}
/// <summary>
/// Gets or sets the color.
/// </summary>
/// <value>
/// The color.
/// </value>
public double FontSize
{
get; set;
}
/// <summary>
/// Gets or sets the color.
/// </summary>
/// <value>
/// The color.
/// </value>
public string CornerRadius
{
get; set;
}
/// <summary>
/// Gets or sets the color.
/// </summary>
/// <value>
/// The color.
/// </value>
public string BorderThickness
{
get; set;
}
/// <summary>
/// Gets or sets the label.
/// </summary>
@@ -108,6 +164,7 @@ namespace AIStudio.Wpf.Flowchart.Models
{
get; set;
}
/// <summary>
/// Gets or sets the width.
/// </summary>
@@ -118,6 +175,7 @@ namespace AIStudio.Wpf.Flowchart.Models
{
get; set;
}
/// <summary>
/// Gets or sets the height.
/// </summary>
@@ -178,6 +236,22 @@ namespace AIStudio.Wpf.Flowchart.Models
{
get; set;
}
public bool IsInnerConnector
{
get; set;
}
public List<string> PortRatio
{
get; set;
}
public virtual DiagramItemViewModel ToNodel(IDiagramViewModel diagramViewModel)
{
return new DiagramItemViewModel(diagramViewModel);
}
}
/// <summary>
@@ -288,6 +362,17 @@ namespace AIStudio.Wpf.Flowchart.Models
get; set;
}
/// <summary>
/// Gets or sets the index of the z.
/// </summary>
/// <value>
/// The index of the z.
/// </value>
public int ZIndex
{
get; set;
} = -1;
/// <summary>
/// Gets or sets the router.
/// </summary>
@@ -353,56 +438,6 @@ namespace AIStudio.Wpf.Flowchart.Models
}
}
/// <summary>
///
/// </summary>
/// <seealso cref="AIStudio.Util.DiagramEntity.DiagramNode" />
public class FlowchartNode : DiagramNode
{
/// <summary>
/// Gets or sets the kind.
/// </summary>
/// <value>
/// The kind.
/// </value>
public NodeKinds Kind
{
get; set;
}
/// <summary>
/// Gets or sets the user ids.
/// </summary>
/// <value>
/// The user ids.
/// </value>
public IEnumerable<string> UserIds
{
get; set;
}
/// <summary>
/// Gets or sets the role ids.
/// </summary>
/// <value>
/// The role ids.
/// </value>
public IEnumerable<string> RoleIds
{
get; set;
}
/// <summary>
/// Gets or sets the type of the act.
/// </summary>
/// <value>
/// The type of the act.
/// </value>
public string ActType
{
get; set;
}
}
/// <summary>
///
/// </summary>

View File

@@ -1,24 +1,19 @@
using System;
using AIStudio.Wpf.DiagramDesigner.Helpers;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace AIStudio.Wpf.Flowchart.Models
namespace AIStudio.Wpf.DiagramDesigner.Serializable
{
public class DiagramNodeConverter : DATACreationConverter<DiagramNode>
{
protected override DiagramNode Create(Type objectType, JObject jObject)
{
//第一种方法:判断属性值来确认是哪个派生类
if (FieldExists("Type", jObject, out string type))
if (FieldExists("Type", jObject, out string typename))
{
if (type == "FlowchartNode")
{
return new FlowchartNode();
}
else
{
return new DiagramNode();
}
var type = TypeHelper.GetType(typename);
return type != null ? (System.Activator.CreateInstance(type) as DiagramNode) : new DiagramNode();
}
else
{
@@ -40,9 +35,10 @@ namespace AIStudio.Wpf.Flowchart.Models
protected override DiagramLink Create(Type objectType, JObject jObject)
{
//第一种方法:判断属性值来确认是哪个派生类
if (FieldExists("Type", jObject, out string type))
if (FieldExists("Type", jObject, out string typename))
{
return new DiagramLink();
var type = TypeHelper.GetType(typename);
return type != null ? (System.Activator.CreateInstance(type) as DiagramLink) : new DiagramLink();
}
else
{

View File

@@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner.Serializable.ViewModels;
using Newtonsoft.Json;
namespace AIStudio.Wpf.DiagramDesigner.Serializable
{
public static class DiagramDataExtention
{
#region ToJson
public static string ToJson(this IDiagramViewModel diagram)
{
var json = JsonConvert.SerializeObject(new {
Nodes = diagram.Items.OfType<DiagramItemViewModel>().Select(p => p.ToDiagramNode()).Where(p => p != null),
Links = diagram.Items.OfType<ConnectionViewModel>().Select(p => p.ToDiagramLink()).Where(p => p != null)
}, new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
return json;
}
public static DiagramNode ToDiagramNode(this DiagramItemViewModel nodeModel)
{
DiagramNode diagramNode = nodeModel.ToDiagram();
diagramNode.Id = nodeModel.Id.ToString();
if (nodeModel.ParentId != Guid.Empty)
{
diagramNode.ParentId = nodeModel.ParentId.ToString();
}
diagramNode.Color = SerializeHelper.SerializeColor(nodeModel.ColorViewModel.FillColor.Color);
diagramNode.LineColor = SerializeHelper.SerializeColor(nodeModel.ColorViewModel.LineColor.Color);
diagramNode.FontColor = SerializeHelper.SerializeColor(nodeModel.FontViewModel.FontColor);
diagramNode.FontSize = nodeModel.FontViewModel.FontSize;
diagramNode.CornerRadius = SerializeHelper.SerializeCornerRadius(nodeModel.CornerRadius);
diagramNode.BorderThickness = SerializeHelper.SerializeThickness(nodeModel.BorderThickness);
diagramNode.Name = nodeModel.Name;
diagramNode.Label = nodeModel.Text;
diagramNode.Width = nodeModel.ItemWidth * ScreenHelper.ScreenScale;
diagramNode.Height = nodeModel.ItemHeight * ScreenHelper.ScreenScale;
diagramNode.X = nodeModel.Left * ScreenHelper.ScreenScale;
diagramNode.Y = nodeModel.Top * ScreenHelper.ScreenScale;
diagramNode.ZIndex = nodeModel.ZIndex;
diagramNode.Type = diagramNode.GetType().Name;
diagramNode.PortAlignmentList = nodeModel.Connectors.Select(p => p.Orientation.ToString()).ToList();
diagramNode.IsInnerConnector = nodeModel.IsInnerConnector;
diagramNode.PortRatio = nodeModel.Connectors.Select(p => SerializeHelper.SerializePoint(p.Ratio)).ToList();
return diagramNode;
}
public static DiagramLink ToDiagramLink(this ConnectionViewModel linkModel)
{
DiagramLink diagramLink = new DiagramLink();
diagramLink.Id = linkModel.Id.ToString();
diagramLink.Color = SerializeHelper.SerializeColor(linkModel.ColorViewModel.LineColor.Color);
diagramLink.SelectedColor = SerializeHelper.SerializeColor(Colors.Black);
diagramLink.Width = linkModel.ColorViewModel.LineWidth;
diagramLink.Label = linkModel.Text;
diagramLink.ZIndex = linkModel.ZIndex;
if (linkModel.IsFullConnection)
{
diagramLink.SourceId = linkModel.SourceConnectorInfo.DataItem.Id.ToString();
diagramLink.TargetId = linkModel.SinkConnectorInfoFully.DataItem.Id.ToString();
diagramLink.Router = linkModel.RouterMode;
diagramLink.PathGenerator = linkModel.PathMode;
diagramLink.SourceMarkerPath = linkModel.ShapeViewModel.SourceMarker.Path;
diagramLink.SourceMarkerWidth = linkModel.ShapeViewModel.SourceMarker.Width;
diagramLink.TargetMarkerPath = linkModel.ShapeViewModel.SinkMarker.Path;
diagramLink.TargetMarkerWidth = linkModel.ShapeViewModel.SinkMarker.Width;
diagramLink.Type = diagramLink.GetType().Name;
diagramLink.SourcePortAlignment = linkModel.SourceConnectorInfo.Orientation.ToString();
diagramLink.TargetPortAlignment = linkModel.SinkConnectorInfoFully.Orientation.ToString();
}
else
{
return null;
}
return diagramLink;
}
#endregion
#region ToObject
public static void ToObject(this IDiagramViewModel diagram, string json)
{
var data = JsonConvert.DeserializeObject<DiagramData>(json, new JsonConverter[] { new DiagramNodeConverter(), new DiagramLinkConverter() });
if (data != null)
{
ToObject(diagram, data);
}
}
public static void ToObject(this IDiagramViewModel diagram, DiagramData data)
{
diagram.Items.Clear();
List<DiagramItemViewModel> nodes = new List<DiagramItemViewModel>();
if (data.Nodes != null)
{
foreach (var node in data.Nodes)
{
var nodemodel = node.ToNodelModel(diagram);
nodes.Add(nodemodel);
diagram.Items.Add(nodemodel);
}
}
if (data.Links != null)
{
foreach (var link in data.Links)
{
var source = nodes.FirstOrDefault(p => p.Id == new Guid(link.SourceId));
var target = nodes.FirstOrDefault(p => p.Id == new Guid(link.TargetId));
var linkmodel = link.ToLinkModel(diagram, source, target);
diagram.Items.Add(linkmodel);
}
}
}
private static DiagramItemViewModel ToNodelModel(this DiagramNode diagramNode, IDiagramViewModel diagram)
{
DiagramItemViewModel nodeModel = diagramNode.ToNodel(diagram);
nodeModel.Id = new Guid(diagramNode.Id);
if (!string.IsNullOrEmpty(diagramNode.ParentId))
{
nodeModel.ParentId = new Guid(diagramNode.ParentId);
}
nodeModel.Root = diagram;
nodeModel.ColorViewModel.FillColor.Color = SerializeHelper.DeserializeColor(diagramNode.Color);
nodeModel.ColorViewModel.LineColor.Color = SerializeHelper.DeserializeColor(diagramNode.LineColor);
nodeModel.FontViewModel.FontColor = SerializeHelper.DeserializeColor(diagramNode.FontColor);
nodeModel.FontViewModel.FontSize = diagramNode.FontSize;
nodeModel.CornerRadius = SerializeHelper.DeserializeCornerRadius(diagramNode.CornerRadius);
nodeModel.BorderThickness = SerializeHelper.DeserializeThickness(diagramNode.BorderThickness);
nodeModel.Text = diagramNode.Label;
nodeModel.Name = diagramNode.Name;
nodeModel.ItemWidth = diagramNode.Width / ScreenHelper.ScreenScale;
nodeModel.ItemHeight = diagramNode.Height / ScreenHelper.ScreenScale;
nodeModel.Left = diagramNode.X / ScreenHelper.ScreenScale;
nodeModel.Top = diagramNode.Y / ScreenHelper.ScreenScale;
nodeModel.ZIndex = diagramNode.ZIndex;
nodeModel.IsInnerConnector = diagramNode.IsInnerConnector;
if (diagramNode.PortAlignmentList != null)
{
nodeModel.ClearConnectors();
for (int i = 0; i < diagramNode.PortAlignmentList.Count; i++)
{
var connecter = new FullyCreatedConnectorInfo(nodeModel, diagramNode.PortAlignmentList[i].ToEnum<ConnectorOrientation>(), nodeModel.IsInnerConnector);
connecter.Ratio = SerializeHelper.DeserializePoint(diagramNode.PortRatio[i]);
nodeModel.AddConnector(connecter);
}
}
return nodeModel;
}
public static ConnectionViewModel ToLinkModel(this DiagramLink diagramLink, IDiagramViewModel diagram, DiagramItemViewModel sourceNode, DiagramItemViewModel targetNode)
{
FullyCreatedConnectorInfo sourceConnectorInfo = sourceNode.Connectors.FirstOrDefault(p => p.Orientation.ToString() == diagramLink.SourcePortAlignment);
FullyCreatedConnectorInfo sinkConnectorInfo = targetNode.Connectors.FirstOrDefault(p => p.Orientation.ToString() == diagramLink.TargetPortAlignment);
ConnectionViewModel linkModel = new ConnectionViewModel(diagram, sourceConnectorInfo, sinkConnectorInfo,
(DrawMode)Enum.Parse(typeof(DrawMode), diagramLink.PathGenerator?? DrawMode.ConnectingLineSmooth.ToString()),
(RouterMode)Enum.Parse(typeof(RouterMode), diagramLink.Router ?? RouterMode.RouterNormal.ToString()));
linkModel.Id = new Guid(diagramLink.Id);
linkModel.ColorViewModel.LineColor.Color = SerializeHelper.DeserializeColor(diagramLink.Color);
linkModel.ColorViewModel.LineWidth = diagramLink.Width;
linkModel.Text = diagramLink.Label;
linkModel.ZIndex = diagramLink.ZIndex;
if (!string.IsNullOrEmpty(diagramLink.SourceMarkerPath))
{
linkModel.ShapeViewModel.SourceMarker = new LinkMarker() { Path = diagramLink.SourceMarkerPath, Width = diagramLink.SourceMarkerWidth ?? 10, Height = diagramLink.SourceMarkerWidth ?? 10 };
}
if (!string.IsNullOrEmpty(diagramLink.TargetMarkerPath))
{
linkModel.ShapeViewModel.SinkMarker = new LinkMarker() { Path = diagramLink.TargetMarkerPath, Width = diagramLink.TargetMarkerWidth ?? 10.0, Height = diagramLink.TargetMarkerWidth ?? 10 };
}
return linkModel;
}
#endregion
}
}

View File

@@ -0,0 +1,29 @@
using AIStudio.Wpf.DiagramDesigner.Models;
namespace AIStudio.Wpf.DiagramDesigner.Serializable.ViewModels
{
public class DiagramItemViewModel : DesignerItemViewModelBase
{
public DiagramItemViewModel() : this(null)
{
}
public DiagramItemViewModel(IDiagramViewModel root) : base(root)
{
}
public DiagramItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
{
}
public DiagramItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
{
}
public virtual DiagramNode ToDiagram()
{
return new DiagramNode();
}
}
}

View File

@@ -2,16 +2,20 @@
<PropertyGroup>
<UseWPF>true</UseWPF>
<Company>AIStudio.Wpf.Controls</Company>
<Company> AIStudio.Wpf.DiagramDesigner.Controls</Company>
<Authors>akwkevin</Authors>
<PackageProjectUrl>https://gitee.com/akwkevin</PackageProjectUrl>
<PackageIcon>A.png</PackageIcon>
<PackageIconUrl />
<NeutralLanguage />
<Version>1.0.7</Version>
<Version>1.1.4</Version>
<Description>一个Wpf的Diagram控件基础库</Description>
</PropertyGroup>
<ItemGroup>
<Compile Remove="PathGenerators\PathGenerators.FishBone.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="Images\file.png" />
<None Remove="Images\FormatPainter.cur" />
@@ -19,6 +23,7 @@
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="PathGenerators\PathGenerators.FishBone.cs" />
</ItemGroup>
<ItemGroup>

View File

@@ -6,6 +6,9 @@ using System.Windows.Media;
using System;
using System.Collections.Generic;
using System.Linq;
using AIStudio.Wpf.DiagramDesigner.ViewModels;
using AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel;
using System.Windows.Threading;
namespace AIStudio.Wpf.DiagramDesigner
{
@@ -13,19 +16,31 @@ namespace AIStudio.Wpf.DiagramDesigner
{
private Point? startPoint;
private Point? endPoint;
private List<Point> pointList = new List<Point>();
private List<PointDesignerItemViewModel> pointDesignerItemViewModelList = new List<PointDesignerItemViewModel>();
private List<Point> pointList = new List<Point>();
private Pen rubberbandPen;
private DesignerCanvas _designerCanvas;
private IDiagramViewModel _viewModel { get { return _designerCanvas.DataContext as IDiagramViewModel; } }
private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
private IDiagramViewModel _viewModel
{
get
{
return _designerCanvas.DataContext as IDiagramViewModel;
}
}
private IDiagramServiceProvider _service
{
get
{
return DiagramServicesProvider.Instance.Provider;
}
}
public RubberbandAdorner(DesignerCanvas designerCanvas, Point? dragStartPoint)
: base(designerCanvas)
{
this._designerCanvas = designerCanvas;
this._designerCanvas.Focus();
this.startPoint = dragStartPoint;
rubberbandPen = new Pen(Brushes.LightSlateGray, 1);
rubberbandPen.DashStyle = new DashStyle(new double[] { 2 }, 1);
@@ -53,14 +68,18 @@ namespace AIStudio.Wpf.DiagramDesigner
}
else if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine)
{
if (!this.IsMouseCaptured)
this.CaptureMouse();
endPoint = e.GetPosition(this);
if (pointList.Count == 0 && this.startPoint.HasValue)
{
pointList.Add(this.startPoint.Value);
var item = new PointDesignerItemViewModel(startPoint.Value);
item.ShowConnectors = true;
_viewModel.DirectAddItemCommand.Execute(item);
pointDesignerItemViewModelList.Add(item);
}
UpdateSelection();
this.InvalidateVisual();
}
else
{
@@ -72,38 +91,23 @@ namespace AIStudio.Wpf.DiagramDesigner
protected override void OnMouseUp(System.Windows.Input.MouseButtonEventArgs e)
{
if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine && e.ChangedButton == MouseButton.Left )
if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine && e.ChangedButton == MouseButton.Left)
{
endPoint = e.GetPosition(this);
bool isend = false;
var connector = ControlExtession.TryFindFromPoint<PointConnector>(this._designerCanvas, endPoint.Value);
if (connector != null)
{
if (object.Equals(connector.DataContext, pointDesignerItemViewModelList[0].TopConnector))
{
isend = true;
}
}
if (isend == false)
//按着ctrl自动封闭曲线
if (Keyboard.IsKeyDown(Key.LeftCtrl) == true || Keyboard.IsKeyDown(Key.RightCtrl) == true)
{
pointList.Add(this.startPoint.Value);
}
else
{
endPoint = e.GetPosition(this);
pointList.Add(endPoint.Value);
var item = new PointDesignerItemViewModel(endPoint.Value);
item.ShowConnectors = true;
_viewModel.DirectAddItemCommand.Execute(item);
pointDesignerItemViewModelList.Add(item);
UpdateSelection();
this.InvalidateVisual();
return;
}
else
{
this._service.DrawModeViewModel.SetDrawMode(DrawMode.Polygon);
}
}
// release mouse capture
@@ -124,19 +128,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
if (this.startPoint.HasValue && this.endPoint.HasValue)
{
if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.Polyline
|| this._service.DrawModeViewModel.GetDrawMode() == DrawMode.Polygon
|| this._service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine)
{
ShapeDesignerItemViewModel itemBase = new ShapeDesignerItemViewModel(this._service.DrawModeViewModel.GetDrawMode(), pointList);
_viewModel.AddItemCommand.Execute(itemBase);
itemBase.PointDesignerItemViewModels.ForEach(p =>
{
p.ParentId = itemBase.Id;
_viewModel.DirectAddItemCommand.Execute(p);
});
}
else if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.Text)
if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.Text)
{
TextDesignerItemViewModel itemBase = new TextDesignerItemViewModel();
Point position = e.GetPosition(this);
@@ -147,22 +139,22 @@ namespace AIStudio.Wpf.DiagramDesigner
_viewModel.AddItemCommand.Execute(itemBase);
}
else if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.Polyline
|| this._service.DrawModeViewModel.GetDrawMode() == DrawMode.Polygon
|| this._service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine)
{
ShapeDesignerItemViewModel itemBase = new ShapeDesignerItemViewModel(this._service.DrawModeViewModel.GetDrawMode(), pointList);
_viewModel.AddItemCommand.Execute(itemBase);
}
else
{
ShapeDesignerItemViewModel itemBase = new ShapeDesignerItemViewModel(this._service.DrawModeViewModel.GetDrawMode(), new List<Point> { this.startPoint.Value, this.endPoint.Value });
_viewModel.AddItemCommand.Execute(itemBase);
itemBase.PointDesignerItemViewModels.ForEach(p =>
{
p.ParentId = itemBase.Id;
_viewModel.DirectAddItemCommand.Execute(p);
});
}
}
}
this._service.DrawModeViewModel.ResetDrawMode();
}
pointDesignerItemViewModelList.ForEach(p => _viewModel.DirectRemoveItemCommand.Execute(p));
e.Handled = true;
}
@@ -197,7 +189,17 @@ namespace AIStudio.Wpf.DiagramDesigner
else if (_service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine)
{
var disList = pointList.ToList();
for (int i = 1; i < pointList.Count; i++)
//按着ctrl自动封闭曲线
if (Keyboard.IsKeyDown(Key.LeftCtrl) == true || Keyboard.IsKeyDown(Key.RightCtrl) == true)
{
disList.Add(this.startPoint.Value);
}
else
{
disList.Add(this.endPoint.Value);
}
for (int i = 1; i < disList.Count; i++)
{
dc.DrawLine(rubberbandPen, disList[i - 1], disList[i]);
}
@@ -219,8 +221,6 @@ namespace AIStudio.Wpf.DiagramDesigner
return GetParent<T>(parentType, parent);
}
private void UpdateSelection()
{
IDiagramViewModel vm = (_designerCanvas.DataContext as IDiagramViewModel);

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
namespace AIStudio.Wpf.DiagramDesigner
{
@@ -59,13 +60,13 @@ namespace AIStudio.Wpf.DiagramDesigner
public class CinchMenuItem
{
#region Public Properties
public String Text { get; set; }
public String IconUrl { get; set; }
public string Text { get; set; }
public string IconUrl { get; set; }
public bool IsChecked { get; set; }
public bool IsCheckable { get; set; }
public List<CinchMenuItem> Children { get; private set; }
public Object CommandParameter { get; set; }
public SimpleCommand Command { get; set; }
public object CommandParameter { get; set; }
public ICommand Command { get; set; }
#endregion
#region Ctor

View File

@@ -14,11 +14,15 @@ using System.Windows.Resources;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using AIStudio.Wpf.DiagramDesigner.Models;
using AIStudio.Wpf.DiagramDesigner.ViewModels;
using AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel;
using System.Diagnostics;
namespace AIStudio.Wpf.DiagramDesigner
{
public class DesignerCanvas : Canvas
{
#region
private IDiagramViewModel _viewModel
{
get
@@ -33,7 +37,6 @@ namespace AIStudio.Wpf.DiagramDesigner
return DiagramServicesProvider.Instance.Provider;
}
}
private ConnectionViewModel partialConnection;
private List<Connector> connectorsHit = new List<Connector>();
@@ -186,12 +189,30 @@ namespace AIStudio.Wpf.DiagramDesigner
#endregion
#endregion
#region
public DesignerCanvas()
{
this.AllowDrop = true;
this.Focusable = true;
Mediator.Instance.Register(this);
_service.PropertyChanged += _service_PropertyChanged;
this.Loaded += DesignerCanvas_Loaded;
this.IsVisibleChanged += DesignerCanvas_IsVisibleChanged;
}
private void DesignerCanvas_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (IsVisible)
{
this.Focus();
}
}
private void DesignerCanvas_Loaded(object sender, RoutedEventArgs e)
{
this.Focus();
}
protected override void OnRender(DrawingContext dc)
@@ -213,7 +234,9 @@ namespace AIStudio.Wpf.DiagramDesigner
dc.DrawLine(new Pen(new SolidColorBrush(GridColor), 1), new Point(i, GridMarginSize.Height), new Point(i, rect.Height - GridMarginSize.Height));
dc.DrawLine(new Pen(new SolidColorBrush(GridColor), 1), new Point(rect.Width - GridMarginSize.Width, GridMarginSize.Height), new Point(rect.Width - GridMarginSize.Width, rect.Height - GridMarginSize.Height));
}
#endregion
#region Format/Move
private void _service_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (sender is IDrawModeViewModel)
@@ -232,7 +255,6 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
#region Format/Move
private void EnterFormat()
{
StreamResourceInfo sri = Application.GetResourceStream(new Uri("pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Images/FormatPainter.cur", UriKind.RelativeOrAbsolute));
@@ -261,13 +283,14 @@ namespace AIStudio.Wpf.DiagramDesigner
}
_service.DrawModeViewModel.CursorMode = CursorMode.Normal;
}
#endregion
private void Format(SelectableDesignerItemViewModelBase source, SelectableDesignerItemViewModelBase target)
{
CopyHelper.CopyPropertyValue(source.ColorViewModel, target.ColorViewModel);
CopyHelper.CopyPropertyValue(source.FontViewModel, target.FontViewModel);
CopyHelper.CopyPropertyValue(source.ShapeViewModel, target.ShapeViewModel);
}
#endregion
private Connector sourceConnector;
public Connector SourceConnector
@@ -285,37 +308,12 @@ namespace AIStudio.Wpf.DiagramDesigner
FullyCreatedConnectorInfo sourceDataItem = sourceConnector.Info;
Rect rectangleBounds = sourceConnector.TransformToVisual(this).TransformBounds(new Rect(sourceConnector.RenderSize));
Point point = new Point(rectangleBounds.Left + (rectangleBounds.Width / 2),
rectangleBounds.Bottom + (rectangleBounds.Height / 2));
partialConnection = new ConnectionViewModel(_viewModel, sourceDataItem, new PartCreatedConnectorInfo(point.X, point.Y), DrawMode, RouterMode);
_viewModel.DirectAddItemCommand.Execute(partialConnection);
}
}
}
private FullyCreatedConnectorInfo sourceConnectorInfo;
public FullyCreatedConnectorInfo SourceConnectorInfo
{
get
{
return sourceConnectorInfo;
}
set
{
if (sourceConnectorInfo != value)
{
sourceConnectorInfo = value;
sourceConnector = new Connector() { Name = "占位" };//占位使用
connectorsHit.Add(sourceConnector);
Rect rectangleBounds = new Rect(sourceConnectorInfo.DataItem.Left, sourceConnectorInfo.DataItem.Top, 3, 3);
Point point = new Point(rectangleBounds.Left + (rectangleBounds.Width / 2),
rectangleBounds.Bottom + (rectangleBounds.Height / 2));
partialConnection = new ConnectionViewModel(_viewModel, sourceConnectorInfo, new PartCreatedConnectorInfo(point.X, point.Y), DrawMode, RouterMode);
_viewModel.DirectAddItemCommand.Execute(partialConnection);
_viewModel.Add(partialConnection);
}
}
}
@@ -323,6 +321,7 @@ namespace AIStudio.Wpf.DiagramDesigner
protected override void OnMouseDown(MouseButtonEventArgs e)
{
base.OnMouseDown(e);
if (_viewModel.IsReadOnly) return;
if (_service.DrawModeViewModel.CursorMode == CursorMode.Format)
@@ -353,20 +352,10 @@ namespace AIStudio.Wpf.DiagramDesigner
if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
{
_viewModel.ClearSelectedItemsCommand.Execute(null);
_viewModel.ClearSelectedItems();
}
e.Handled = true;
if (_service.DrawModeViewModel.GetDrawMode() == DrawMode.ConnectingLineSmooth)
{
if (connectorsHit.Count == 0)
{
LinkPointDesignerItemViewModel pointItemView = new LinkPointDesignerItemViewModel(rubberbandSelectionStartPoint.Value);
_viewModel.DirectAddItemCommand.Execute(pointItemView);
SourceConnectorInfo = pointItemView.Connectors.FirstOrDefault();
}
}
}
}
@@ -374,6 +363,9 @@ namespace AIStudio.Wpf.DiagramDesigner
protected override void OnMouseMove(MouseEventArgs e)
{
var focusedElement = Keyboard.FocusedElement;
Debug.WriteLine("focusedElement" + focusedElement?.ToString());
base.OnMouseMove(e);
if (_viewModel.IsReadOnly) return;
@@ -404,10 +396,6 @@ namespace AIStudio.Wpf.DiagramDesigner
var nearPort = FindNearPortToAttachTo();
if (nearPort != null || partialConnection.SinkConnectorInfoFully != null)
{
//var oldPort = _ongoingLink.TargetPort;
//_ongoingLink.SetTargetPort(nearPort);
//oldPort?.Refresh();
//nearPort?.Refresh();
partialConnection.SinkConnectorInfo = nearPort;
}
}
@@ -435,6 +423,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
}
e.Handled = true;
}
@@ -444,50 +433,30 @@ namespace AIStudio.Wpf.DiagramDesigner
if (_viewModel.IsReadOnly) return;
if (_service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine)
{
return;
}
Mediator.Instance.NotifyColleagues<bool>("DoneDrawingMessage", true);
if (sourceConnector != null)
{
FullyCreatedConnectorInfo sourceDataItem = sourceConnectorInfo ?? (sourceConnector.Info);
FullyCreatedConnectorInfo sourceDataItem = sourceConnector.Info;
if (connectorsHit.Count() == 2)
{
Connector sinkConnector = connectorsHit.Last();
FullyCreatedConnectorInfo sinkDataItem = sinkConnector.Info;
int indexOfLastTempConnection = sinkDataItem.DataItem.Root.Items.Count - 1;
sinkDataItem.DataItem.Root.DirectRemoveItemCommand.Execute(
sinkDataItem.DataItem.Root.Remove(
sinkDataItem.DataItem.Root.Items[indexOfLastTempConnection]);
sinkDataItem.DataItem.Root.AddItemCommand.Execute(new ConnectionViewModel(_viewModel, sourceDataItem, sinkDataItem, DrawMode, RouterMode));
}
else if (partialConnection.IsFullConnection)
else if (partialConnection.IsFullConnection)//自动连接模式
{
partialConnection.RaiseFullConnection();
}
else if (_service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine && connectorsHit.Count() == 1)
{
LinkPointDesignerItemViewModel pointItemView = new LinkPointDesignerItemViewModel(e.GetPosition(this));
FullyCreatedConnectorInfo sinkDataItem = pointItemView.TopConnector;
int indexOfLastTempConnection = _viewModel.Items.Count - 1;
_viewModel.DirectRemoveItemCommand.Execute(_viewModel.Items[indexOfLastTempConnection]);
_viewModel.DirectAddItemCommand.Execute(pointItemView);
var connector = new ConnectionViewModel(_viewModel, sourceDataItem, sinkDataItem, DrawMode, RouterMode);
_viewModel.AddItemCommand.Execute(connector);
sourceDataItem.DataItem.ZIndex++;
connector.ZIndex--;
}
else
{
//Need to remove last item as we did not finish drawing the path
int indexOfLastTempConnection = sourceDataItem.DataItem.Root.Items.Count - 1;
sourceDataItem.DataItem.Root.DirectRemoveItemCommand.Execute(
sourceDataItem.DataItem.Root.Remove(
sourceDataItem.DataItem.Root.Items[indexOfLastTempConnection]);
@@ -496,10 +465,38 @@ namespace AIStudio.Wpf.DiagramDesigner
connectorsHit = new List<Connector>();
sourceConnector = null;
sourceConnectorInfo = null;
_service.DrawModeViewModel.ResetDrawMode();
}
if (_service.DrawModeViewModel.GetDrawMode() != DrawMode.DirectLine)
{
_service.DrawModeViewModel.ResetDrawMode();
}
}
protected override void OnPreviewKeyDown(KeyEventArgs e)
{
base.OnPreviewKeyDown(e);
if (_viewModel.IsReadOnly) return;
e.Handled = _viewModel.ExecuteShortcut(e);
}
protected override void OnPreviewMouseWheel(MouseWheelEventArgs e)
{
base.OnPreviewMouseWheel(e);
if (Keyboard.IsKeyDown(Key.LeftCtrl) == false
&& Keyboard.IsKeyDown(Key.RightCtrl) == false)
{
return;
}
var newZoomValue = _viewModel.ZoomValue + (e.Delta > 0 ? 0.1 : -0.1);
_viewModel.ZoomValue = Math.Max(Math.Min(newZoomValue, _viewModel.MaximumZoomValue), _viewModel.MinimumZoomValue);
e.Handled = true;
}
protected override Size MeasureOverride(Size constraint)
{
@@ -534,21 +531,13 @@ namespace AIStudio.Wpf.DiagramDesigner
while (hitObject != null &&
hitObject.GetType() != typeof(DesignerCanvas))
{
if (hitObject is Connector connector && connector.Info != null)
if (hitObject is Connector connector)
{
if (SourceConnector == null || connector.Info.CanAttachTo(SourceConnector.Info))
{
if (connectorsHit.Any(p => p.Name == "占位"))
{
connectorsHit.Remove(connectorsHit.FirstOrDefault(p => p.Name == "占位"));
}
if (!connectorsHit.Contains(hitObject as Connector))
connectorsHit.Add(hitObject as Connector);
}
if (!connectorsHit.Contains(hitObject as Connector))
connectorsHit.Add(hitObject as Connector);
}
hitObject = VisualTreeHelper.GetParent(hitObject);
}
}
protected override void OnDrop(DragEventArgs e)
@@ -560,8 +549,8 @@ namespace AIStudio.Wpf.DiagramDesigner
DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;
if (dragObject != null)
{
_viewModel.ClearSelectedItemsCommand.Execute(null);
Point position = e.GetPosition(this);
_viewModel.ClearSelectedItems();
Point position = e.GetPosition(this);
if (dragObject.DesignerItem is SerializableObject serializableObject)
{
var designerItems = serializableObject.ToObject();
@@ -575,7 +564,7 @@ namespace AIStudio.Wpf.DiagramDesigner
foreach (var item in designerItems.OfType<DesignerItemViewModelBase>())
{
item.Left += position.X - itemswidth / 2;
item.Top += position.Y - itemsheight / 2;
item.Top += position.Y - itemsheight / 2;
}
_viewModel.AddItemCommand.Execute(designerItems);
}
@@ -607,7 +596,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
foreach (var file in files)
{
_viewModel.ClearSelectedItemsCommand.Execute(null);
_viewModel.ClearSelectedItems();
Point position = e.GetPosition(this);
ImageItemViewModel itemBase = new ImageItemViewModel();
itemBase.Icon = file;
@@ -621,9 +610,12 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
e.Handled = true;
this.Focus();
}
public FullyCreatedConnectorInfo FindNearPortToAttachTo()
#region
private FullyCreatedConnectorInfo FindNearPortToAttachTo()
{
foreach (var port in _viewModel.Items.OfType<DesignerItemViewModelBase>().ToList().SelectMany(n => n.Connectors))
{
@@ -634,5 +626,6 @@ namespace AIStudio.Wpf.DiagramDesigner
return null;
}
#endregion
}
}

View File

@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
namespace AIStudio.Wpf.DiagramDesigner.Controls
{
@@ -18,11 +18,20 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
base.DragCompleted += DragThumb_DragCompleted;
}
public IDiagramViewModel DiagramViewModel
{
get
{
return (this.DataContext as SelectableDesignerItemViewModelBase)?.Root;
}
}
private List<SelectableDesignerItemViewModelBase> designerItems;
private bool drag;
private void DragThumb_DragStarted(object sender, DragStartedEventArgs e)
{
GetDesignerCanvas(this)?.Focus();
drag = false;
SelectableDesignerItemViewModelBase designerItem = this.DataContext as SelectableDesignerItemViewModelBase;
@@ -30,6 +39,11 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
{
// we only move DesignerItems
designerItems = designerItem.Root.SelectedItems.ToList();
if (designerItem is IGroupable groupable)
{
designerItems.AddRange(designerItem.Root.SelectionService.GetGroupMembers(groupable).OfType<SelectableDesignerItemViewModelBase>());
}
if (designerItem is ConnectionViewModel connector)
{
designerItems.Add(connector.SourceConnectorInfo.DataItem);
@@ -44,11 +58,12 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
designerItems = new List<SelectableDesignerItemViewModelBase> { designerItem };
}
designerItems = designerItems.Distinct().ToList();
Interlocked.Increment(ref DiagramViewModel.DoCommandManager.BeginDo);
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
{
item.BeginDo = true;
item.SetOldValue(item.Left, nameof(item.Left));
item.SetOldValue(item.Top, nameof(item.Top));
item.SetOldValue(item.TopLeft, nameof(item.TopLeft));
}
e.Handled = true;
@@ -61,17 +76,36 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
private void DragThumb_DragCompleted(object sender, DragCompletedEventArgs e)
{
if (drag == false) return;
if (drag == false)
{
Interlocked.Decrement(ref DiagramViewModel.DoCommandManager.BeginDo);
return;
}
if (designerItems != null)
{
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
{
item.SetCellAlignment();
item.BeginDo = false;
item.RaiseTopLeft();
}
Dictionary<DesignerItemViewModelBase, Tuple<PointBase, PointBase>> infos =
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
p => new Tuple<PointBase, PointBase>(p.GetOldValue<PointBase>(nameof(p.TopLeft)), p.TopLeft));
Interlocked.Decrement(ref DiagramViewModel.DoCommandManager.BeginDo);
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
() => {
foreach (var info in infos)
{
info.Key.TopLeft = info.Value.Item2;
}
},
() => {
foreach (var info in infos)
{
info.Key.TopLeft = info.Value.Item1;
}
});
e.Handled = true;
}
}
@@ -81,23 +115,12 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
drag = true;
if (designerItems != null)
{
double minLeft = double.MaxValue;
double minTop = double.MaxValue;
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
{
double left = item.Left;
double top = item.Top;
minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft);
minTop = double.IsNaN(top) ? 0 : Math.Min(top, minTop);
double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
double deltaVertical = Math.Max(-minTop, e.VerticalChange);
item.Left += deltaHorizontal;
item.Top += deltaVertical;
item.Left += e.HorizontalChange;
item.Top += e.VerticalChange;
}
e.Handled = true;
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace AIStudio.Wpf.DiagramDesigner.Controls
{
public class DiagramTabControl : TabControl
{
public DiagramTabControl()
{
// Attach event handler to TabControl.SelectionChanged event
this.SelectionChanged += DiagramTabControl_SelectionChanged;
this.IsVisibleChanged += DiagramTabControl_IsVisibleChanged;
}
private void DiagramTabControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
foreach (var item in this.Items)
{
if (item is DiagramViewModel viewModel)
{
viewModel.ShowSearch = false;
}
}
}
private void DiagramTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Iterate through all TabItems and manually set the Visibility property
foreach (var item in this.Items)
{
if (item is DiagramViewModel viewModel)
{
if (item != this.SelectedItem)
{
viewModel.ShowSearch = false;
}
}
}
}
}
}

View File

@@ -29,5 +29,14 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
this.DialogResult = true;
this.Close();
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
if (this.DataContext is IDisposable disposable)
{
disposable.Dispose();
}
}
}
}

View File

@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
namespace AIStudio.Wpf.DiagramDesigner.Controls
{
@@ -17,21 +19,27 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
base.DragCompleted += ResizeThumb_DragCompleted;
}
public IDiagramViewModel DiagramViewModel
{
get
{
return (this.DataContext as SelectableDesignerItemViewModelBase)?.Root;
}
}
private List<SelectableDesignerItemViewModelBase> designerItems;
IDiagramViewModel diagarmViewModel;
private void ResizeThumb_DragStarted(object sender, DragStartedEventArgs e)
{
DesignerItemViewModelBase designerItem = this.DataContext as DesignerItemViewModelBase;
diagarmViewModel = designerItem.Root;
if (designerItem != null && designerItem.IsSelected)
{
designerItems = designerItem.Root.SelectedItems.ToList();
Interlocked.Increment(ref DiagramViewModel.DoCommandManager.BeginDo);
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
{
item.BeginDo = true;
item.SetOldValue(item.ItemWidth, nameof(item.ItemWidth));
item.SetOldValue(item.ItemHeight, nameof(item.ItemHeight));
item.SetOldValue(item.Size, nameof(item.Size));
}
e.Handled = true;
@@ -46,12 +54,24 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
{
if (designerItems != null)
{
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
{
item.BeginDo = false;
item.RaiseItemWidthHeight();
}
Dictionary<DesignerItemViewModelBase, Tuple<SizeBase, SizeBase>> infos =
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
p => new Tuple<SizeBase, SizeBase>(p.GetOldValue<SizeBase>(nameof(p.Size)), p.Size));
Interlocked.Decrement(ref DiagramViewModel.DoCommandManager.BeginDo);
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
() => {
foreach (var info in infos)
{
info.Key.Size = info.Value.Item2;
}
},
() => {
foreach (var info in infos)
{
info.Key.Size = info.Value.Item1;
}
});
e.Handled = true;
}
}
@@ -69,20 +89,20 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
{
if (item != null && item.ParentId == Guid.Empty)
if (item != null)
{
switch (base.VerticalAlignment)
{
case VerticalAlignment.Bottom:
dragDeltaVertical = Math.Min(-e.VerticalChange, minDeltaVertical);
scale = (item.ItemHeight - dragDeltaVertical) / item.ItemHeight;
DragBottom(scale, item, diagarmViewModel.SelectionService);
DragBottom(scale, item, DiagramViewModel.SelectionService);
break;
case VerticalAlignment.Top:
double top = item.Top;
dragDeltaVertical = Math.Min(Math.Max(-minTop, e.VerticalChange), minDeltaVertical);
scale = (item.ItemHeight - dragDeltaVertical) / item.ItemHeight;
DragTop(scale, item, diagarmViewModel.SelectionService);
DragTop(scale, item, DiagramViewModel.SelectionService);
break;
default:
break;
@@ -94,12 +114,12 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
double left = item.Left;
dragDeltaHorizontal = Math.Min(Math.Max(-minLeft, e.HorizontalChange), minDeltaHorizontal);
scale = (item.ItemWidth - dragDeltaHorizontal) / item.ItemWidth;
DragLeft(scale, item, diagarmViewModel.SelectionService);
DragLeft(scale, item, DiagramViewModel.SelectionService);
break;
case HorizontalAlignment.Right:
dragDeltaHorizontal = Math.Min(-e.HorizontalChange, minDeltaHorizontal);
scale = (item.ItemWidth - dragDeltaHorizontal) / item.ItemWidth;
DragRight(scale, item, diagarmViewModel.SelectionService);
DragRight(scale, item, DiagramViewModel.SelectionService);
break;
default:
break;
@@ -115,7 +135,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
private void DragLeft(double scale, DesignerItemViewModelBase item, SelectionService selectionService)
{
IEnumerable<DesignerItemViewModelBase> groupItems = selectionService.GetGroupMembers(item).Cast<DesignerItemViewModelBase>();
IEnumerable<DesignerItemViewModelBase> groupItems = selectionService.GetGroupMembers(item, false).Cast<DesignerItemViewModelBase>();
double groupLeft = item.Left + item.ItemWidth;
foreach (DesignerItemViewModelBase groupItem in groupItems)
@@ -129,7 +149,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
private void DragTop(double scale, DesignerItemViewModelBase item, SelectionService selectionService)
{
IEnumerable<DesignerItemViewModelBase> groupItems = selectionService.GetGroupMembers(item).Cast<DesignerItemViewModelBase>();
IEnumerable<DesignerItemViewModelBase> groupItems = selectionService.GetGroupMembers(item, false).Cast<DesignerItemViewModelBase>();
double groupBottom = item.Top + item.ItemHeight;
foreach (DesignerItemViewModelBase groupItem in groupItems)
{
@@ -142,7 +162,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
private void DragRight(double scale, DesignerItemViewModelBase item, SelectionService selectionService)
{
IEnumerable<DesignerItemViewModelBase> groupItems = selectionService.GetGroupMembers(item).Cast<DesignerItemViewModelBase>();
IEnumerable<DesignerItemViewModelBase> groupItems = selectionService.GetGroupMembers(item, false).Cast<DesignerItemViewModelBase>();
double groupLeft = item.Left;
foreach (DesignerItemViewModelBase groupItem in groupItems)
@@ -157,7 +177,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
private void DragBottom(double scale, DesignerItemViewModelBase item, SelectionService selectionService)
{
IEnumerable<DesignerItemViewModelBase> groupItems = selectionService.GetGroupMembers(item).Cast<DesignerItemViewModelBase>();
IEnumerable<DesignerItemViewModelBase> groupItems = selectionService.GetGroupMembers(item, false).Cast<DesignerItemViewModelBase>();
double groupTop = item.Top;
foreach (DesignerItemViewModelBase groupItem in groupItems)
{

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
@@ -24,6 +25,14 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
DragCompleted += RotateThumb_DragCompleted;
}
public IDiagramViewModel DiagramViewModel
{
get
{
return (this.DataContext as SelectableDesignerItemViewModelBase)?.Root;
}
}
private List<SelectableDesignerItemViewModelBase> designerItems;
private void RotateThumb_DragStarted(object sender, DragStartedEventArgs e)
@@ -34,9 +43,9 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
{
designerItems = designerItem.Root.SelectedItems.ToList();
Interlocked.Increment(ref DiagramViewModel.DoCommandManager.BeginDo);
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
{
item.BeginDo = true;
item.SetOldValue(this.designerItem.Angle, nameof(this.designerItem.Angle));
}
@@ -67,12 +76,23 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
if (this.designerItems != null)
{
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
{
item.BeginDo = false;
item.RaiseAngle();
}
Dictionary<DesignerItemViewModelBase, Tuple<double, double>> infos =
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
p => new Tuple<double, double>(p.GetOldValue<double>(nameof(p.Angle)), p.Angle));
Interlocked.Decrement(ref DiagramViewModel.DoCommandManager.BeginDo);
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
() => {
foreach (var info in infos)
{
info.Key.Angle = info.Value.Item2;
}
},
() => {
foreach (var info in infos)
{
info.Key.Angle = info.Value.Item1;
}
});
e.Handled = true;
}
}

View File

@@ -4,6 +4,8 @@ using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using System.Windows.Input;
using AIStudio.Wpf.DiagramDesigner.Helpers;
using System.Diagnostics;
namespace AIStudio.Wpf.DiagramDesigner
{
@@ -12,70 +14,211 @@ namespace AIStudio.Wpf.DiagramDesigner
private Thumb zoomThumb;
private Canvas zoomCanvas;
private Slider zoomSlider;
private ScaleTransform scaleTransform;
#region DPs
#region ScrollViewer
public ScrollViewer ScrollViewer
{
get { return (ScrollViewer)GetValue(ScrollViewerProperty); }
set { SetValue(ScrollViewerProperty, value); }
get
{
return (ScrollViewer)GetValue(ScrollViewerProperty);
}
set
{
SetValue(ScrollViewerProperty, value);
}
}
public static readonly DependencyProperty ScrollViewerProperty =
DependencyProperty.Register(nameof(ScrollViewer), typeof(ScrollViewer), typeof(ZoomBox));
#endregion
#region DesignerCanvas
#region FrameworkElement
public static readonly DependencyProperty DesignerCanvasProperty =
DependencyProperty.Register(nameof(DesignerCanvas), typeof(DesignerCanvas), typeof(ZoomBox),
DependencyProperty.Register(nameof(DesignerCanvas), typeof(FrameworkElement), typeof(ZoomBox),
new FrameworkPropertyMetadata(null,
new PropertyChangedCallback(OnDesignerCanvasChanged)));
public DesignerCanvas DesignerCanvas
public FrameworkElement DesignerCanvas
{
get { return (DesignerCanvas)GetValue(DesignerCanvasProperty); }
set { SetValue(DesignerCanvasProperty, value); }
get
{
return (FrameworkElement)GetValue(DesignerCanvasProperty);
}
set
{
SetValue(DesignerCanvasProperty, value);
}
}
private static void OnDesignerCanvasChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
ZoomBox target = (ZoomBox)d;
DesignerCanvas oldDesignerCanvas = (DesignerCanvas)e.OldValue;
DesignerCanvas newDesignerCanvas = target.DesignerCanvas;
FrameworkElement oldDesignerCanvas = (FrameworkElement)e.OldValue;
FrameworkElement newDesignerCanvas = (FrameworkElement)e.NewValue;
target.OnDesignerCanvasChanged(oldDesignerCanvas, newDesignerCanvas);
}
protected virtual void OnDesignerCanvasChanged(DesignerCanvas oldDesignerCanvas, DesignerCanvas newDesignerCanvas)
protected virtual void OnDesignerCanvasChanged(FrameworkElement oldDesignerCanvas, FrameworkElement newDesignerCanvas)
{
if (oldDesignerCanvas != null)
{
newDesignerCanvas.LayoutUpdated -= new EventHandler(this.DesignerCanvas_LayoutUpdated);
newDesignerCanvas.MouseWheel -= new MouseWheelEventHandler(this.DesignerCanvas_MouseWheel);
oldDesignerCanvas.LayoutUpdated -= this.DesignerCanvas_LayoutUpdated;
oldDesignerCanvas.MouseDown -= this.DesignerCanvas_MouseRightButtonDown;
oldDesignerCanvas.MouseUp -= this.DesignerCanvas_MouseRightButtonUp;
oldDesignerCanvas.MouseMove -= this.DesignerCanvas_MouseMove;
}
if (newDesignerCanvas != null)
{
newDesignerCanvas.LayoutUpdated += new EventHandler(this.DesignerCanvas_LayoutUpdated);
newDesignerCanvas.MouseWheel += new MouseWheelEventHandler(this.DesignerCanvas_MouseWheel);
newDesignerCanvas.LayoutTransform = this.scaleTransform;
newDesignerCanvas.LayoutUpdated += this.DesignerCanvas_LayoutUpdated;
newDesignerCanvas.MouseRightButtonDown += this.DesignerCanvas_MouseRightButtonDown;
newDesignerCanvas.MouseRightButtonUp += this.DesignerCanvas_MouseRightButtonUp;
newDesignerCanvas.MouseMove += this.DesignerCanvas_MouseMove;
}
}
#endregion
public static readonly DependencyProperty OffSetProperty =
DependencyProperty.Register(nameof(OffSet), typeof(bool), typeof(ZoomBox), new UIPropertyMetadata(false));
public bool OffSet
{
get
{
return (bool)GetValue(OffSetProperty);
}
set
{
SetValue(OffSetProperty, value);
}
}
public static readonly DependencyProperty ZoomValueProperty =
DependencyProperty.Register(nameof(ZoomValue), typeof(double), typeof(ZoomBox), new UIPropertyMetadata(1d));
public double ZoomValue
{
get
{
return (double)GetValue(ZoomValueProperty);
}
set
{
SetValue(ZoomValueProperty, value);
}
}
public static readonly DependencyProperty MaximumZoomValueProperty =
DependencyProperty.Register(nameof(MaximumZoomValue), typeof(double), typeof(ZoomBox), new UIPropertyMetadata(3d));
public double MaximumZoomValue
{
get
{
return (double)GetValue(MaximumZoomValueProperty);
}
set
{
SetValue(MaximumZoomValueProperty, value);
}
}
public static readonly DependencyProperty MinimumZoomValueProperty =
DependencyProperty.Register(nameof(MinimumZoomValue), typeof(double), typeof(ZoomBox), new UIPropertyMetadata(0.5d));
public double MinimumZoomValue
{
get
{
return (double)GetValue(MinimumZoomValueProperty);
}
set
{
SetValue(MinimumZoomValueProperty, value);
}
}
public static readonly DependencyProperty FitViewModelProperty =
DependencyProperty.Register(nameof(FitViewModel), typeof(FitViewModel), typeof(ZoomBox),
new FrameworkPropertyMetadata(null,
new PropertyChangedCallback(OnFitViewModelChanged)));
public FitViewModel FitViewModel
{
get
{
return (FitViewModel)GetValue(FitViewModelProperty);
}
set
{
SetValue(FitViewModelProperty, value);
}
}
private static void OnFitViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
ZoomBox target = (ZoomBox)d;
var fitviewmodel = e.NewValue as FitViewModel;
if (fitviewmodel != null)
{
target.OnFitViewModelChanged(fitviewmodel);
}
}
private void OnFitViewModelChanged(FitViewModel fitViewModel)
{
if (IsLoaded && fitViewModel != null)
{
if (fitViewModel.FitMode == FitMode.None)
{
}
else if (fitViewModel.FitMode == FitMode.FitWidth)
{
ZoomValue = (this.ScrollViewer.ViewportWidth * fitViewModel.PaddingRate) / fitViewModel.BoundingRect.Width;
}
else if (fitViewModel.FitMode == FitMode.FitHeight)
{
ZoomValue = (this.ScrollViewer.ViewportHeight * fitViewModel.PaddingRate) / fitViewModel.BoundingRect.Height;
}
else if (fitViewModel.FitMode == FitMode.FitAuto)
{
ZoomValue = Math.Min(
(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;
if (OffSet)
{
Vector vector = System.Windows.Media.VisualTreeHelper.GetOffset(DesignerCanvas);
xOffset += vector.X;
yOffset += vector.Y;
}
this.ScrollViewer.ScrollToHorizontalOffset(xOffset);
this.ScrollViewer.ScrollToVerticalOffset(yOffset);
}
}
#endregion
#endregion
public ZoomBox()
{
this.Loaded += ZoomBox_Loaded;
}
private void ZoomBox_Loaded(object sender, RoutedEventArgs e)
{
OnFitViewModelChanged(FitViewModel);
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
this.ScrollViewer = VisualHelper.TryFindParent<ScrollViewer>(this.DesignerCanvas);
if (this.ScrollViewer == null)
return;
@@ -93,9 +236,11 @@ namespace AIStudio.Wpf.DiagramDesigner
this.zoomThumb.DragDelta += new DragDeltaEventHandler(this.Thumb_DragDelta);
this.zoomSlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(this.ZoomSlider_ValueChanged);
this.scaleTransform = new ScaleTransform();
}
private static object thisLock = new Object();
private void ZoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
double scale = e.NewValue / e.OldValue;
@@ -103,8 +248,6 @@ namespace AIStudio.Wpf.DiagramDesigner
double newVerticalOffset = ((this.ScrollViewer.VerticalOffset + halfViewportHeight) * scale - halfViewportHeight);
double halfViewportWidth = this.ScrollViewer.ViewportWidth / 2;
double newHorizontalOffset = ((this.ScrollViewer.HorizontalOffset + halfViewportWidth) * scale - halfViewportWidth);
this.scaleTransform.ScaleX *= scale;
this.scaleTransform.ScaleY *= scale;
this.ScrollViewer.ScrollToHorizontalOffset(newHorizontalOffset);
this.ScrollViewer.ScrollToVerticalOffset(newVerticalOffset);
}
@@ -119,44 +262,111 @@ namespace AIStudio.Wpf.DiagramDesigner
private void DesignerCanvas_LayoutUpdated(object sender, EventArgs e)
{
//htzk
try
{
double scale, xOffset, yOffset;
this.InvalidateScale(out scale, out xOffset, out yOffset);
this.zoomThumb.Width = this.ScrollViewer.ViewportWidth * scale;
this.zoomThumb.Height = this.ScrollViewer.ViewportHeight * scale;
this.zoomThumb.Width = (this.ScrollViewer.ViewportWidth) * scale;
this.zoomThumb.Height = (this.ScrollViewer.ViewportHeight) * scale;
Canvas.SetLeft(this.zoomThumb, xOffset + this.ScrollViewer.HorizontalOffset * scale);
Canvas.SetTop(this.zoomThumb, yOffset + this.ScrollViewer.VerticalOffset * scale);
}
catch { }
}
private void DesignerCanvas_MouseWheel(object sender, EventArgs e)
/// <summary>
/// 用于记录鼠标按下的点
/// </summary>
private Point _clickPoint = new Point(0, 0);
private void DesignerCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
MouseWheelEventArgs wheel = (MouseWheelEventArgs)e;
//divide the value by 10 so that it is more smooth
double value = Math.Max(0, wheel.Delta / 10);
value = Math.Min(wheel.Delta, 10);
this.zoomSlider.Value += value;
_clickPoint = e.GetPosition((FrameworkElement)sender);
DesignerCanvas.Cursor = Cursors.Hand;
}
private void DesignerCanvas_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
DesignerCanvas.Cursor = Cursors.Arrow;
}
private void DesignerCanvas_MouseMove(object sender, MouseEventArgs e)
{
if (e.RightButton == MouseButtonState.Pressed)
{
FrameworkElement cabSender = (FrameworkElement)sender;
double x;
double y;
Point p = e.MouseDevice.GetPosition(cabSender);
x = _clickPoint.X - p.X;
y = _clickPoint.Y - p.Y;
ScrollViewer?.ScrollToHorizontalOffset(ScrollViewer.HorizontalOffset + x);
ScrollViewer?.ScrollToVerticalOffset(ScrollViewer.VerticalOffset + y);
}
}
private void InvalidateScale(out double scale, out double xOffset, out double yOffset)
{
double w = DesignerCanvas.ActualWidth * this.scaleTransform.ScaleX;
double h = DesignerCanvas.ActualHeight * this.scaleTransform.ScaleY;
if (OffSet)
{
Vector vector = System.Windows.Media.VisualTreeHelper.GetOffset(DesignerCanvas);
double w = DesignerCanvas.ActualWidth + vector.X * 2;
double h = DesignerCanvas.ActualHeight + vector.Y * 2;
// zoom canvas size
double x = this.zoomCanvas.ActualWidth;
double y = this.zoomCanvas.ActualHeight;
double scaleX = x / w;
double scaleY = y / h;
scale = (scaleX < scaleY) ? scaleX : scaleY;
xOffset = (x - scale * w) / 2;
yOffset = (y - scale * h) / 2;
}
else
{
double w = DesignerCanvas.ActualWidth;
double h = DesignerCanvas.ActualHeight;
// zoom canvas size
double x = this.zoomCanvas.ActualWidth;
double y = this.zoomCanvas.ActualHeight;
double scaleX = x / w;
double scaleY = y / h;
scale = (scaleX < scaleY) ? scaleX : scaleY;
xOffset = (x - scale * w) / 2;
yOffset = (y - scale * h) / 2;
}
// zoom canvas size
double x = this.zoomCanvas.ActualWidth;
double y = this.zoomCanvas.ActualHeight;
double scaleX = x / w;
double scaleY = y / h;
scale = (scaleX < scaleY) ? scaleX : scaleY;
xOffset = (x - scale * w) / 2;
yOffset = (y - scale * h) / 2;
}
}
public class FitViewModel
{
public Rect BoundingRect
{
get; set;
}
public FitMode FitMode
{
get; set;
}
public double PaddingRate
{
get; set;
} = 0.9;
}
public enum FitMode
{
None,
FitAuto,
FitWidth,
FitHeight,
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace AIStudio.Wpf.DiagramDesigner
{
public class AdditionConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((value != null) && (parameter != null))
{
var firstValue = (double)value;
var secondValue = double.Parse(parameter?.ToString());
return firstValue + secondValue;
}
return 0d;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
namespace AIStudio.Wpf.DiagramDesigner
{
public class BrushOpacityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is SolidColorBrush brush)
{
var opacity = System.Convert.ToDouble(parameter, CultureInfo.InvariantCulture);
return new SolidColorBrush(brush.Color)
{
Opacity = opacity
};
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
=> Binding.DoNothing;
}
}

View File

@@ -14,27 +14,32 @@ namespace AIStudio.Wpf.DiagramDesigner
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (values == null || values.Length < 1)
if (values == null || values.Length < 2)
{
throw new NotImplementedException();
}
if (values[0] is double && values[1] is ValueTypePoint)
if (values[0] is double && values[2] is ConnectorValueType)
{
double connectorValue = (double)values[0];
ValueTypePoint valueTypePoint = (ValueTypePoint)values[1];
string connectorString = values[1] as string;
ConnectorValueType valueTypePoint = (ConnectorValueType)values[2];
if (valueTypePoint == ValueTypePoint.Bool)
if (valueTypePoint == ConnectorValueType.Bool)
{
return (connectorValue == 0) ? "F" : "T";
}
else if (valueTypePoint == ValueTypePoint.Int)
else if (valueTypePoint == ConnectorValueType.Int)
{
return connectorValue.ToString("0");
}
else
else if (valueTypePoint == ConnectorValueType.Real)
{
return connectorValue.ToString("f3");
}
else
{
return connectorString;
}
}
return null;
}

View File

@@ -0,0 +1,67 @@
using System;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Data;
namespace AIStudio.Wpf.DiagramDesigner
{
public class GridLengthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var length = value?.ToString();
try
{
double add = 0;
double.TryParse(parameter?.ToString(), out add);
return new GridLength(double.Parse(length) + add, GridUnitType.Pixel);
}
catch
{
return new GridLength(1, GridUnitType.Auto);
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
}
public class GridLengthAutoConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var length = value?.ToString();
try
{
if (Regex.IsMatch(length, @"^\d+(\.\d+)?$"))
{
return new GridLength(double.Parse(length), GridUnitType.Pixel);
}
else if (length == "*")
{
return new GridLength(1, GridUnitType.Star);
}
else if (Regex.IsMatch(length, @"^\d+(\.\d+)?\*$"))
{
return new GridLength(double.Parse(length.Substring(0, length.Length - 1)), GridUnitType.Star);
}
else
{
return new GridLength(1, GridUnitType.Auto);
}
}
catch
{
return new GridLength(1, GridUnitType.Auto);
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
}
}

View File

@@ -1,24 +1,25 @@
using System;
using System.Windows;
using System.Windows.Data;
namespace AIStudio.Wpf.DiagramDesigner.Converters
{
public class IntToBoolConverter : IValueConverter
public class IntToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (object.Equals(value, 0d))
return false;
if (value == null || object.Equals(value, 0))
return Visibility.Collapsed;
else
return true;
return Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (object.Equals(value, false))
return 0d;
if (object.Equals(value, Visibility.Collapsed))
return 0;
else
return 1d;
return 1;
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Windows.Data;
namespace AIStudio.Wpf.DiagramDesigner.Converters
{
public class IntToBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (object.Equals(value, 0d))
return false;
else
return true;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (object.Equals(value, false))
return 0d;
else
return 1d;
}
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;
using System.Windows;
namespace AIStudio.Wpf.DiagramDesigner
{
public class NullableToVisibilityConverter : IValueConverter
{
public Visibility NullValue { get; set; } = Visibility.Collapsed;
public Visibility NotNullValue { get; set; } = Visibility.Visible;
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return string.IsNullOrEmpty(value?.ToString()) ? NullValue : NotNullValue;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Binding.DoNothing;
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
namespace AIStudio.Wpf.DiagramDesigner
{
/// <summary>
/// CommandParameter 多参数传递
/// </summary>
public class ObjectConverter : IMultiValueConverter
{
#region IMultiValueConverter Members
public object Convert(object[] values, Type targetType,
object parameter, System.Globalization.CultureInfo culture)
{
return values?.ToArray();
}
public object[] ConvertBack(object value, Type[] targetTypes,
object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
}

View File

@@ -10,6 +10,7 @@ namespace AIStudio.Wpf.DiagramDesigner
FlowChart,
Logical,
SFC,
Mind
Mind,
Script
}
}

View File

@@ -7,6 +7,7 @@ namespace AIStudio.Wpf.DiagramDesigner
public enum RouterMode
{
RouterNormal,
RouterOrthogonal
RouterOrthogonal,
RouterFishBone
}
}

View File

@@ -4,10 +4,11 @@ using System.Text;
namespace AIStudio.Wpf.DiagramDesigner
{
public enum ValueTypePoint
public enum ConnectorValueType
{
Real = 0,
Int = 1,
Bool = 2,
String = 3,
}
}

View File

@@ -143,7 +143,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Geometrys
return;
}
// Calculate first Bezier control points
// CalculateOutput first Bezier control points
// Right hand side vector
double[] rhs = new double[n];

View File

@@ -181,8 +181,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Geometrys
/// <param name='point2'>The second PointBase to compare</param>
public static bool Equals(PointBase point1, PointBase point2)
{
return point1.X.Equals(point2.X) &&
point1.Y.Equals(point2.Y);
return Math.Abs(point1.X - point2.X) < 0.01f &&
Math.Abs(point1.Y - point2.Y) < 0.01f;
}
/// <summary>

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Windows;
namespace AIStudio.Wpf.DiagramDesigner.Geometrys
{
@@ -1069,6 +1070,16 @@ namespace AIStudio.Wpf.DiagramDesigner.Geometrys
// return value;
//}
public static implicit operator RectangleBase(Rect rect)
{
return new RectangleBase(rect.Left, rect.Top, rect.Width, rect.Height);
}
public static implicit operator Rect(RectangleBase rect)
{
return new Rect(rect.Left, rect.Top, rect.Width, rect.Height);
}
#endregion Public Methods
}

View File

@@ -76,6 +76,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Geometrys
public SizeBase Add(double value) => new SizeBase(Width + value, Height + value);
public SizeBase Add(double width, double height) => new SizeBase(Width + width, Height + height);
//public bool Equals(Size size) => size != null && Width == size.Width && Height == size.Height;
//public override string ToString() => $"Size(width={Width}, height={Height})";

View File

@@ -1,16 +1,13 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Xml.Serialization;
namespace AIStudio.Wpf.DiagramDesigner
{
public class CopyHelper
public static class CopyHelper
{
public static T DeepCopyByReflect<T>(T obj)
{
@@ -140,7 +137,41 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
public static ColorViewModel Mapper(IColorViewModel s)
/// <summary>
/// 该拷贝不完整,只适应于工具栏使用
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="s"></param>
/// <returns></returns>
public static T Mapper<T>(T s) where T : SelectableViewModelBase
{
if (s == null)
return null;
T d = Activator.CreateInstance(s.GetType()) as T;
d.IsLoaded = false;
var properties = s.GetType().GetProperties();
foreach (var propertie in properties)
{
//循环遍历属性
if (propertie.CanRead && propertie.CanWrite)
{
//进行属性拷贝
propertie.SetValue(d, propertie.GetValue(s, null), null);
}
}
d.ColorViewModel = CopyHelper.Mapper(s.ColorViewModel);
d.FontViewModel = CopyHelper.Mapper(s.FontViewModel);
d.ShapeViewModel = CopyHelper.Mapper(s.ShapeViewModel);
d.LockObjectViewModel = CopyHelper.Mapper<LockObjectViewModel, ILockObjectViewModel>(s.LockObjectViewModel);
d.IsLoaded = true;
return d;
}
public static IColorViewModel Mapper(IColorViewModel s)
{
var d = CopyHelper.Mapper<ColorViewModel, IColorViewModel>(s);
d.LineColor = CopyHelper.Mapper<ColorObject, IColorObject>(s.LineColor);
@@ -160,7 +191,7 @@ namespace AIStudio.Wpf.DiagramDesigner
return d;
}
public static ShapeViewModel Mapper(IShapeViewModel s)
public static IShapeViewModel Mapper(IShapeViewModel s)
{
var d = CopyHelper.Mapper<ShapeViewModel, IShapeViewModel>(s);
d.SourceMarker = CopyHelper.Mapper<LinkMarker, ILinkMarker>(s.SourceMarker);
@@ -176,6 +207,18 @@ namespace AIStudio.Wpf.DiagramDesigner
return d;
}
public static IFontViewModel Mapper(IFontViewModel s)
{
var d = CopyHelper.Mapper<FontViewModel, IFontViewModel>(s);
return d;
}
public static T Mapper<T>(IFontViewModel s) where T : IFontViewModel
{
var d = CopyHelper.Mapper<T, IFontViewModel>(s);
return d;
}
public static void CopyPropertyValue(IColorViewModel s, IColorViewModel d, string propertyName = null)
{
if (propertyName == "LineColor")

View File

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace AIStudio.Wpf.DiagramDesigner
{
class DoCommandManager
public class DoCommandManager
{
#region Command定义
public class Command
@@ -24,9 +24,18 @@ namespace AIStudio.Wpf.DiagramDesigner
this.clearAction = clearAction;
}
internal void Do() { action(); }
internal void UnDo() { unDoAction(); }
internal void Clear() { if (clearAction != null) clearAction(); }
internal void Do()
{
action();
}
internal void UnDo()
{
unDoAction();
}
internal void Clear()
{
if (clearAction != null) clearAction();
}
public override string ToString()
{
@@ -35,35 +44,63 @@ namespace AIStudio.Wpf.DiagramDesigner
}
#endregion
public Stack<Command> ReDoActionStack { get; private set; }
public Stack<Command> UnDoActionStack { get; private set; }
public Stack<Command> ReDoActionStack
{
get; private set;
}
public Stack<Command> UnDoActionStack
{
get; private set;
}
public int Capacity { get; set; } = 10;
public int Capacity { get; set; } = 100;
public DoCommandManager()
{
Init();
}
public void Init()
{
ReDoActionStack = new Stack<Command>();
UnDoActionStack = new Stack<Command>();
}
public int BeginDo;
private bool _undoing;
public void DoNewCommand(string name, Action action, Action unDoAction, Action clearAction = null, bool doit = true)
{
if (UnDoActionStack.Count >= Capacity)
{
//清理
var clear = UnDoActionStack.LastOrDefault();
clear.Clear();
UnDoActionStack = new Stack<Command>(UnDoActionStack.Take(Capacity - 1).Reverse());
}
var cmd = new Command(name, action, unDoAction, clearAction);
UnDoActionStack.Push(cmd);
ReDoActionStack.Clear();
if (doit)
if (BeginDo > 0)
return;
if (_undoing == true)
return;
try
{
cmd.Do();
_undoing = true;
if (UnDoActionStack.Count >= Capacity)
{
//清理
var clear = UnDoActionStack.LastOrDefault();
clear.Clear();
UnDoActionStack = new Stack<Command>(UnDoActionStack.Take(Capacity - 1).Reverse());
}
var cmd = new Command(name, action, unDoAction, clearAction);
UnDoActionStack.Push(cmd);
ReDoActionStack.Clear();
if (doit)
{
cmd.Do();
}
}
finally
{
_undoing = false;
}
}
@@ -72,9 +109,20 @@ namespace AIStudio.Wpf.DiagramDesigner
if (!CanUnDo)
return;
var cmd = UnDoActionStack.Pop();
ReDoActionStack.Push(cmd);
cmd.UnDo();
if (_undoing == true)
return;
try
{
_undoing = true;
var cmd = UnDoActionStack.Pop();
ReDoActionStack.Push(cmd);
cmd.UnDo();
}
finally
{
_undoing = false;
}
}
public void ReDo()
@@ -82,13 +130,35 @@ namespace AIStudio.Wpf.DiagramDesigner
if (!CanReDo)
return;
var cmd = ReDoActionStack.Pop();
UnDoActionStack.Push(cmd);
cmd.Do();
if (_undoing == true)
return;
try
{
_undoing = true;
var cmd = ReDoActionStack.Pop();
UnDoActionStack.Push(cmd);
cmd.Do();
}
finally
{
_undoing = false;
}
}
public bool CanUnDo { get { return UnDoActionStack.Count != 0; } }
public bool CanReDo { get { return ReDoActionStack.Count != 0; } }
public bool CanUnDo
{
get
{
return UnDoActionStack.Count != 0;
}
}
public bool CanReDo
{
get
{
return ReDoActionStack.Count != 0;
}
}
//public IEnumerable<Command> Actions { get { return ReDoActionStack.Reverse().Concat(UnDoActionStack); } }
}
}

View File

@@ -1,13 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using AIStudio.Wpf.DiagramDesigner;
namespace AIStudio.Wpf.DiagramDesigner.Additionals
namespace AIStudio.Wpf.DiagramDesigner
{
public class EnumHelper : DependencyObject
{

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Media;
using System.Windows;
using System.Windows.Controls;
namespace AIStudio.Wpf.DiagramDesigner.Helpers
{
public class GetTextDisplayWidthHelper
{
public static Double GetTextDisplayWidth(Label label)
{
return GetTextDisplayWidth(label.Content.ToString(), label.FontFamily, label.FontStyle, label.FontWeight, label.FontStretch, label.FontSize);
}
public static Double GetTextDisplayWidth(string str, FontFamily fontFamily, FontStyle fontStyle, FontWeight fontWeight, FontStretch fontStretch, double fontSize)
{
var formattedText = new FormattedText(
str,
CultureInfo.CurrentUICulture,
FlowDirection.LeftToRight,
new Typeface(fontFamily, fontStyle, fontWeight, fontStretch),
fontSize,
Brushes.Black
);
Size size = new Size(formattedText.Width, formattedText.Height);
return size.Width;
}
}
}

View File

@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AIStudio.Wpf.DiagramDesigner.Helpers
{
public static class IEnumerableExtensions
{
/// <summary>
/// Invokes a transform function on each element of a sequence and returns the minimum Double value
/// if the sequence is not empty; otherwise returns the specified default value.
/// </summary>
/// <typeparam name="TSource"> The type of the elements of source. </typeparam>
/// <param name="source"> A sequence of values to determine the minimum value of. </param>
/// <param name="selector"> A transform function to apply to each element. </param>
/// <param name="defaultValue"> The default value. </param>
/// <returns> The minimum value in the sequence or default value if sequence is empty. </returns>
public static double MinOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector, double defaultValue=default(double))
{
if (source.Any<TSource>())
return source.Min<TSource>(selector);
return defaultValue;
}
/// <summary>
/// Invokes a transform function on each element of a sequence and returns the maximum Double value
/// if the sequence is not empty; otherwise returns the specified default value.
/// </summary>
/// <typeparam name="TSource"> The type of the elements of source. </typeparam>
/// <param name="source"> A sequence of values to determine the maximum value of. </param>
/// <param name="selector"> A transform function to apply to each element. </param>
/// <param name="defaultValue"> The default value. </param>
/// <returns> The maximum value in the sequence or default value if sequence is empty. </returns>
public static double MaxOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector, double defaultValue=default(double))
{
if (source.Any<TSource>())
return source.Max<TSource>(selector);
return defaultValue;
}
public static TResult MinOrDefault<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector, TResult defaultValue)
{
if (source.Any())
{
return source.Min(selector);
}
return defaultValue;
}
public static TResult MaxOrDefault<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector, TResult defaultValue)
{
if (source.Any())
{
return source.Max(selector);
}
return defaultValue;
}
/// <summary>
/// Invokes a transform function on each element of a sequence and returns the minimum Double value
/// if the sequence is not empty; otherwise returns the specified default value.
/// </summary>
/// <typeparam name="TSource"> The type of the elements of source. </typeparam>
/// <param name="source"> A sequence of values to determine the minimum value of. </param>
/// <param name="selector"> A transform function to apply to each element. </param>
/// <param name="defaultValue"> The default value. </param>
/// <returns> The minimum value in the sequence or default value if sequence is empty. </returns>
public static double SumOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector, double defaultValue=default(double))
{
if (source.Any<TSource>())
return source.Sum<TSource>(selector);
return defaultValue;
}
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace AIStudio.Wpf.DiagramDesigner.Helpers
{
public class MemberInfoGettingHelper
{
public static string GetMemberName<T>(Expression<Func<T>> memberExpression)
{
MemberExpression expressionBody = (MemberExpression)memberExpression.Body;
return expressionBody.Member.Name;
}
}
}

View File

@@ -14,12 +14,20 @@ namespace AIStudio.Wpf.DiagramDesigner
{
static GlobalType()
{
string rootPath = System.AppDomain.CurrentDomain.BaseDirectory;
AllAssemblies = Directory.GetFiles(rootPath, "*.dll")
.Where(x => AssemblyPattern.Any(y => new FileInfo(x).Name.Contains(y)))
.Select(x => Assembly.LoadFrom(x))
.Where(x => !x.IsDynamic)
.ToList();
//string rootPath = System.AppDomain.CurrentDomain.BaseDirectory;
//AllAssemblies = Directory.GetFiles(rootPath, "*.dll")
// .Where(x => AssemblyPattern.Any(y => new FileInfo(x).Name.Contains(y)))
// .Select(x => Assembly.LoadFrom(x))
// .Where(x => !x.IsDynamic)
// .ToList();
//var refAssembyNames = Assembly.GetEntryAssembly().GetReferencedAssemblies();
//foreach (var asslembyNames in refAssembyNames)
//{
// Assembly.Load(asslembyNames);
//}
AllAssemblies = AppDomain.CurrentDomain.GetReferanceAssemblies().Where(x => x.FullName.StartsWith("AIStudio")).ToList();
AllAssemblies.ForEach(aAssembly => {
try
@@ -33,6 +41,29 @@ namespace AIStudio.Wpf.DiagramDesigner
});
}
public static List<Assembly> GetReferanceAssemblies(this AppDomain domain)
{
var list = new List<Assembly>();
domain.GetAssemblies().ToList().ForEach(i =>
{
GetReferanceAssemblies(i, list);
});
return list;
}
static void GetReferanceAssemblies(Assembly assembly, List<Assembly> list)
{
assembly.GetReferencedAssemblies().ToList().ForEach(i =>
{
var ass = Assembly.Load(i);
if (!list.Contains(ass))
{
list.Add(ass);
GetReferanceAssemblies(ass, list);
}
});
}
/// <summary>
/// 解决方案程序集匹配名
/// </summary>

View File

@@ -20,12 +20,13 @@ namespace AIStudio.Wpf.DiagramDesigner
public LogicalConnectorInfoItem(LogicalConnectorInfo viewmodel) : base(viewmodel)
{
ValueTypePoint = viewmodel.ValueTypePoint;
ConnectorValueType = viewmodel.ConnectorValueType;
ConnectorValue = viewmodel.ConnectorValue;
ConnectorString = viewmodel.ConnectorString;
}
[XmlAttribute]
public ValueTypePoint ValueTypePoint
public ConnectorValueType ConnectorValueType
{
get; set;
}
@@ -35,6 +36,12 @@ namespace AIStudio.Wpf.DiagramDesigner
{
get; set;
}
[XmlAttribute]
public string ConnectorString
{
get; set;
}
}

View File

@@ -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,10 @@ namespace AIStudio.Wpf.DiagramDesigner
this.ItemTypeName = viewmodel.GetType().FullName;
this.Margin = viewmodel.Margin;
this.Reserve = reserve;
this.CornerRadius = viewmodel.CornerRadius;
this.BorderThickness = viewmodel.BorderThickness;
Connectors = new List<FullyCreatedConnectorInfoItem>(viewmodel.Connectors.Select(p => new FullyCreatedConnectorInfoItem(p)));
}
[XmlAttribute("Left")]
@@ -102,6 +107,51 @@ namespace AIStudio.Wpf.DiagramDesigner
get; set;
}
[XmlIgnore]
public CornerRadius CornerRadius
{
get; set;
}
[JsonIgnore]
[XmlElement("CornerRadius")]
public string XmlCornerRadius
{
get
{
return SerializeHelper.SerializeCornerRadius(CornerRadius);
}
set
{
CornerRadius = SerializeHelper.DeserializeCornerRadius(value);
}
}
[XmlIgnore]
public Thickness BorderThickness
{
get; set;
}
[JsonIgnore]
[XmlElement("BorderThickness")]
public string XmlBorderThickness
{
get
{
return SerializeHelper.SerializeThickness(BorderThickness);
}
set
{
BorderThickness = SerializeHelper.DeserializeThickness(value);
}
}
[XmlArray]
public List<FullyCreatedConnectorInfoItem> Connectors
{
get; set;
}
}

View File

@@ -15,20 +15,18 @@ namespace AIStudio.Wpf.DiagramDesigner
}
public LogicalGateDesignerItemBase(LogicalGateItemViewModelBase item) : base(item)
{
this.Connectors = new List<LogicalConnectorInfoItem>();
foreach (var fullyCreatedConnectorInfo in item.Connectors.OfType<LogicalConnectorInfo>())
{
LogicalConnectorInfoItem connector = new LogicalConnectorInfoItem(fullyCreatedConnectorInfo);
this.Connectors.Add(connector);
}
this.OrderNumber = item.OrderNumber;
this.LogicalType = item.LogicalType;
this.Value = item.Value;
this.IsEnabled = item.IsEnabled;
LogicalConnectors = new List<LogicalConnectorInfoItem>(item.Connectors.OfType<LogicalConnectorInfo>().Select(p => new LogicalConnectorInfoItem(p)));
}
[XmlArray]
public List<LogicalConnectorInfoItem> Connectors { get; set; }
public List<LogicalConnectorInfoItem> LogicalConnectors
{
get; set;
}
[XmlAttribute]
public int OrderNumber { get; set; }

View File

@@ -12,26 +12,13 @@ namespace AIStudio.Wpf.DiagramDesigner
public MediaDesignerItem(GifImageItemViewModel item) : base(item)
{
Connectors = new List<FullyCreatedConnectorInfoItem>();
foreach (var fullyCreatedConnectorInfo in item.Connectors)
{
FullyCreatedConnectorInfoItem connector = new FullyCreatedConnectorInfoItem(fullyCreatedConnectorInfo);
Connectors.Add(connector);
}
}
public MediaDesignerItem(MediaItemViewModel item) : base(item)
{
Connectors = new List<FullyCreatedConnectorInfoItem>();
foreach (var fullyCreatedConnectorInfo in item.Connectors)
{
FullyCreatedConnectorInfoItem connector = new FullyCreatedConnectorInfoItem(fullyCreatedConnectorInfo);
Connectors.Add(connector);
}
}
[XmlArray]
public List<FullyCreatedConnectorInfoItem> Connectors { get; set; }
}
}
}

View File

@@ -1,4 +1,5 @@
using AIStudio.Wpf.DiagramDesigner.Helpers;
using AIStudio.Wpf.DiagramDesigner.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -6,6 +7,7 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -32,6 +34,7 @@ namespace AIStudio.Wpf.DiagramDesigner
this.IsGroup = viewmodel.IsGroup;
this.ParentId = viewmodel.ParentId;
this.Text = viewmodel.Text;
this.Name = viewmodel.Name;
ColorItem = CopyHelper.Mapper<ColorItem>(viewmodel.ColorViewModel);
FontItem = CopyHelper.Mapper<FontItem, IFontViewModel>(viewmodel.FontViewModel);
@@ -62,6 +65,12 @@ namespace AIStudio.Wpf.DiagramDesigner
get; set;
}
[XmlAttribute]
public string Name
{
get; set;
}
[XmlAttribute]
public string Text
{
@@ -518,6 +527,28 @@ namespace AIStudio.Wpf.DiagramDesigner
return new Size(double.Parse(pieces[0]), double.Parse(pieces[1]));
}
public static string SerializeCornerRadius(CornerRadius cornerRadius)
{
return string.Format("{0},{1},{2},{3}", cornerRadius.TopLeft, cornerRadius.TopRight, cornerRadius.BottomRight, cornerRadius.BottomLeft);
}
public static CornerRadius DeserializeCornerRadius(string cornerRadius)
{
string[] pieces = cornerRadius.Split(new char[] { ',' });
return new CornerRadius(double.Parse(pieces[0]), double.Parse(pieces[1]), double.Parse(pieces[2]), double.Parse(pieces[3]));
}
public static string SerializeThickness(Thickness thickness)
{
return string.Format("{0},{1},{2},{3}", thickness.Left, thickness.Top, thickness.Right, thickness.Bottom);
}
public static Thickness DeserializeThickness(string thickness)
{
string[] pieces = thickness.Split(new char[] { ',' });
return new Thickness(double.Parse(pieces[0]), double.Parse(pieces[1]), double.Parse(pieces[2]), double.Parse(pieces[3]));
}
public static string SerializeDoubleNull(double? point)
{
return point?.ToString();
@@ -533,7 +564,7 @@ namespace AIStudio.Wpf.DiagramDesigner
return value;
}
public static string SerializeObject(object obj, string serializableType)
public static string SerializeObject(object obj, string serializableType = null)
{
if (serializableType?.ToLower() == ".xml")
{
@@ -559,7 +590,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
public static SelectableItemBase DeserializeObject(Type type, string serializableString, string serializableType)
public static SelectableItemBase DeserializeObject(Type type, string serializableString, string serializableType = null)
{
if (serializableType?.ToLower() == ".xml")
{
@@ -575,7 +606,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
public static SelectableItemBase DeserializeObject(string typename, string serializableString, string serializableType)
public static SelectableItemBase DeserializeObject(string typename, string serializableString, string serializableType = null)
{
Type type = TypeHelper.GetType(typename);
if (serializableType?.ToLower() == ".xml")
@@ -591,6 +622,11 @@ namespace AIStudio.Wpf.DiagramDesigner
return JsonConvert.DeserializeObject(serializableString, type) as SelectableItemBase;
}
}
public static SelectableItemBase DeserializeObject(SerializableItem serializableItem, string serializableType = null)
{
return DeserializeObject(serializableItem.SerializableTypeName, serializableItem.SerializableString, serializableType);
}
}
public struct XmlFont

View File

@@ -66,8 +66,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Models
Type itemtype = TypeHelper.GetType(connection.SerializableTypeName);
var connectionItem = SerializeHelper.DeserializeObject(itemtype, connection.SerializableString, ".json") as ConnectionItem;
connectionItem.SourceType = System.Type.GetType(connectionItem.SourceTypeName);
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
connectionItem.SourceType = TypeHelper.GetType(connectionItem.SourceTypeName);
connectionItem.SinkType = TypeHelper.GetType(connectionItem.SinkTypeName);
DesignerItemViewModelBase sourceItem = DiagramViewModelHelper.GetConnectorDataItem(items, connectionItem.SourceId, connectionItem.SourceType);
if (sourceItem == null)
continue;
@@ -81,6 +81,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Models
FullyCreatedConnectorInfo sinkConnectorInfo = sinkItem.GetFullConnectorInfo(connectionItem.Id, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint, connectionItem.SinkInnerPoint);
ConnectionViewModel connectionVM = new ConnectionViewModel(null, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
connectionVM.Id = Guid.NewGuid();
connects.Add(connectionVM);
}

View File

@@ -53,12 +53,12 @@ namespace AIStudio.Wpf.DiagramDesigner
var p0 = GetFirstSegment(source, sourceOrientation, gridCellSize, gridMargin);
var p1 = GetFirstSegment(sink, sinkOrientation, gridCellSize, gridMargin);
if (p0 == p1)
if (p0.Equals(p1))
return points;
var p2 = new PointBase(GetNearestCross(p0.X, p1.X, gridCellSize.Width, gridMargin.Width), GetNearestCross(p0.Y, p1.Y, gridCellSize.Height, gridMargin.Height));
var p3 = new PointBase(GetNearestCross(p1.X, p0.X, gridCellSize.Width, gridMargin.Width), GetNearestCross(p1.Y, p0.Y, gridCellSize.Height, gridMargin.Height));
if (p2 == p3)
if (p2.Equals(p3))
{
points.Add(p0);
points.Add(p2);
@@ -93,12 +93,12 @@ namespace AIStudio.Wpf.DiagramDesigner
public static double GetNearestCross(double a, double b, double cellSize, double margin)
{
if (Math.Abs(a - b) < 0.0001 && (int)((a - margin)/ cellSize) == ((a - margin) / cellSize))
if (Math.Abs(a - b) < 0.0001 && (int)(Math.Round((a - margin)/ cellSize, 3)) == (Math.Round((a - margin) / cellSize,3)))
return a;
else if (a < b)
return Math.Ceiling((a - margin) / cellSize) * cellSize + margin;
return Math.Ceiling(Math.Round((a - margin) / cellSize, 3)) * cellSize + margin;
else
return Math.Floor((a - margin) / cellSize) * cellSize + margin;
return Math.Floor(Math.Round((a - margin) / cellSize, 3)) * cellSize + margin;
}
public static PointBase SegmentMiddlePoint(PointBase p1, PointBase p2)

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
namespace AIStudio.Wpf.DiagramDesigner
{
public static partial class PathGenerators
{
public static PathGeneratorResult Straight(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route, PointBase source, PointBase target)
{
route = ConcatRouteAndSourceAndTarget(route, source, target);
double sourceAngle = SourceMarkerAdjustement(route, link.GetSourceMarkerWidth(), link.GetSourceMarkerHeight());
double targetAngle = TargetMarkerAdjustement(route, link.GetSinkMarkerWidth(), link.GetSinkMarkerHeight());
DoShift(route, link);
var paths = new string[route.Length - 1];
for (var i = 0; i < route.Length - 1; i++)
{
paths[i] = FormattableString.Invariant($"M {route[i].X} {route[i].Y} L {route[i + 1].X} {route[i + 1].Y}");
}
return new PathGeneratorResult(paths, sourceAngle, route[0], targetAngle, route[route.Length - 1]);
}
}
}

View File

@@ -6,7 +6,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
public static partial class PathGenerators
{
private const double _margin = 125;
public static PathGeneratorResult Smooth(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route, PointBase source, PointBase target)
{
@@ -69,15 +69,44 @@ namespace AIStudio.Wpf.DiagramDesigner
{
var cX = (route[0].X + route[1].X) / 2;
var cY = (route[0].Y + route[1].Y) / 2;
var curvePointA = GetCurvePoint(route[0].X, route[0].Y, cX, cY, link.SourceConnectorInfo?.Orientation);
var curvePointB = GetCurvePoint(route[1].X, route[1].Y, cX, cY, link.SinkConnectorInfo?.Orientation);
var sourceOrientation = link.SourceConnectorInfo?.Orientation;
if (sourceOrientation == ConnectorOrientation.None)//按照线条的四象限来处理。
{
var slope = (route[1].Y - route[0].Y) / (route[1].X - route[0].X);
if (Math.Abs(slope) < link.SmoothAutoSlope)
{
if (route[1].X > route[0].X)
{
sourceOrientation = ConnectorOrientation.Right;
}
else
{
sourceOrientation = ConnectorOrientation.Left;
}
}
else
{
if (route[1].Y > route[0].Y)//Y轴方向是反的
{
sourceOrientation = ConnectorOrientation.Bottom;
}
else
{
sourceOrientation = ConnectorOrientation.Top;
}
}
}
var curvePointA = GetCurvePoint(route[0].X, route[0].Y, cX, cY, link.SmoothMargin, sourceOrientation);
var curvePointB = GetCurvePoint(route[1].X, route[1].Y, cX, cY, link.SmoothMargin, link.SinkConnectorInfo?.Orientation);
return new[] { route[0], curvePointA, curvePointB, route[1] };
}
}
private static PointBase GetCurvePoint(double pX, double pY, double cX, double cY, ConnectorOrientation? alignment)
private static PointBase GetCurvePoint(double pX, double pY, double cX, double cY, double smoothMargin, ConnectorOrientation? alignment)
{
var margin = Math.Min(_margin, Math.Pow(Math.Pow(pX - cX, 2) + Math.Pow(pY - cY, 2), .5));
var margin = Math.Min(smoothMargin, Math.Pow(Math.Pow(pX - cX, 2) + Math.Pow(pY - cY, 2), .5));
switch (alignment)
{
case ConnectorOrientation.Top: return new PointBase(pX, Math.Min(pY - margin, cY));

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
namespace AIStudio.Wpf.DiagramDesigner
{
public class RouterFishBone : IRouter
{
public PointBase[] Get(IDiagramViewModel _, ConnectionViewModel link)
{
return Routers.FishBone(_, link);
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
// Implementation taken from the JS version: https://gist.github.com/menendezpoo/4a8894c152383b9d7a870c24a04447e4
// Todo: Make it more c#, Benchmark A* vs Dijkstra, Add more options
namespace AIStudio.Wpf.DiagramDesigner
{
public static partial class Routers
{
public static PointBase[] FishBone(IDiagramViewModel _, ConnectionViewModel link)
{
if (link.IsPortless)
throw new Exception("Orthogonal router doesn't work with portless links yet");
if (link.IsFullConnection == false)
return Normal(_, link);
double x2 = link.SourceConnectorInfo.MiddlePosition.X < link.SinkConnectorInfoFully.MiddlePosition.X ?
link.SinkConnectorInfoFully.MiddlePosition.X - Math.Abs(link.SourceConnectorInfo.MiddlePosition.Y - link.SinkConnectorInfoFully.MiddlePosition.Y)
: link.SinkConnectorInfoFully.MiddlePosition.X + Math.Abs(link.SourceConnectorInfo.MiddlePosition.Y - link.SinkConnectorInfoFully.MiddlePosition.Y);
double y2 = link.SourceConnectorInfo.MiddlePosition.Y;
return new PointBase[] { new PointBase(x2, y2) };
}
}
}

View File

@@ -18,8 +18,8 @@ namespace AIStudio.Wpf.DiagramDesigner
if (link.IsFullConnection == false)
return Normal(_, link);
var shapeMargin = 10;
var globalBoundsMargin = 50;
var shapeMargin = link.OrthogonalShapeMargin;
var globalBoundsMargin = link.OrthogonalGlobalBoundsMargin;
var spots = new List<PointBase>();
var verticals = new List<double>();
var horizontals = new List<double>();
@@ -38,6 +38,7 @@ namespace AIStudio.Wpf.DiagramDesigner
{
shapeMargin = 0;
inflatedA = shapeA;
inflatedB = shapeB;
}
@@ -539,9 +540,10 @@ namespace AIStudio.Wpf.DiagramDesigner
var nodeB = Get(b);
if (nodeA == null || nodeB == null)
return;
return;
nodeA.AdjacentNodes.Add(nodeB, a.DistanceTo(b));
if (!nodeA.AdjacentNodes.ContainsKey(nodeB))
nodeA.AdjacentNodes.Add(nodeB, a.DistanceTo(b));
}
public bool Has(PointBase p)

View File

@@ -1,6 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner">
xmlns:dd="clr-namespace:AIStudio.Wpf.DiagramDesigner">
<!--TextBox水印样式-->
<Style TargetType="{x:Type TextBox}" x:Key="WaterTextBox">
<Setter Property="Background" Value="Transparent"/>
@@ -29,7 +29,7 @@
</ScrollViewer>
<!--水印-->
<TextBlock x:Name="Message" Padding="{TemplateBinding Padding}" Visibility="Collapsed"
Text="{TemplateBinding s:ControlAttachProperty.Watermark}" Grid.Column="1"
Text="{TemplateBinding dd:ControlAttachProperty.Watermark}" Grid.Column="1"
Foreground="{TemplateBinding Foreground}" IsHitTestVisible="False" Opacity="0.5"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="5,2,5,2" />
@@ -78,7 +78,7 @@
</ScrollViewer>
<!--水印-->
<TextBlock x:Name="Message" Padding="{TemplateBinding Padding}" Visibility="Collapsed"
Text="{TemplateBinding s:ControlAttachProperty.Watermark}" Grid.Column="1"
Text="{TemplateBinding dd:ControlAttachProperty.Watermark}" Grid.Column="1"
Foreground="{TemplateBinding Foreground}" IsHitTestVisible="False" Opacity="0.5"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="5,2,5,2" />

View File

@@ -1,10 +1,10 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner">
xmlns:dd="clr-namespace:AIStudio.Wpf.DiagramDesigner">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Shared.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type s:ZoomBox}">
<Style TargetType="{x:Type dd:ZoomBox}">
<Style.Resources>
@@ -165,7 +165,7 @@
Value="true" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type s:ZoomBox}">
<ControlTemplate TargetType="{x:Type dd:ZoomBox}">
<Border CornerRadius="1"
BorderThickness="1"
Background="#EEE"
@@ -205,34 +205,24 @@
<Expander.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Slider Name="PART_ZoomSlider"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Margin="0"
Ticks="25,50,75,100,125,150,200,300,400,500"
Minimum="25"
Maximum="500"
SmallChange="25"
LargeChange="25"
Value="100"
MinWidth="104"
MinHeight="21"
Ticks="0.25,0.50,0.75,1,1.25,1.50,2.00,3.00,4.00,5.00"
Minimum="{Binding MinimumZoomValue,RelativeSource={RelativeSource Mode=TemplatedParent},Mode=TwoWay}"
Maximum="{Binding MaximumZoomValue,RelativeSource={RelativeSource Mode=TemplatedParent},Mode=TwoWay}"
SmallChange="0.25"
LargeChange="0.25"
Value="{Binding ZoomValue,RelativeSource={RelativeSource Mode=TemplatedParent},Mode=TwoWay,Delay=500}"
IsSnapToTickEnabled="True"
IsMoveToPointEnabled="False" />
<TextBlock Text="{Binding ElementName=PART_ZoomSlider, Path=Value}"
<TextBlock Text="{Binding ElementName=PART_ZoomSlider, Path=Value, StringFormat={}{0:P}}"
Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="0,0,14,0" />
<TextBlock Text="%"
Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="1,0,2,0" />
Margin="0,0,2,0" />
</Grid>
</Expander.Header>
</Expander>

View File

@@ -1,12 +1,12 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner"
xmlns:dd="clr-namespace:AIStudio.Wpf.DiagramDesigner"
xmlns:c="clr-namespace:AIStudio.Wpf.DiagramDesigner.Controls">
<s:ColorBrushConverter x:Key="ColorBrushConverter" />
<s:ConectorOrientationConverter x:Key="ConectorOrientationConverter" />
<s:ConectorValueConverter x:Key="ConectorValueConverter"/>
<dd:ColorBrushConverter x:Key="ColorBrushConverter" />
<dd:ConectorOrientationConverter x:Key="ConectorOrientationConverter" />
<dd:ConectorValueConverter x:Key="ConectorValueConverter"/>
<DataTemplate DataType="{x:Type s:FullyCreatedConnectorInfo}">
<DataTemplate DataType="{x:Type dd:FullyCreatedConnectorInfo}">
<Grid Width="{Binding ConnectorWidth}" Height="{Binding ConnectorHeight}">
<Grid.ContextMenu>
<ContextMenu ItemsSource="{Binding MenuOptions}" >
@@ -29,9 +29,9 @@
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type s:LogicalConnectorInfo}">
<Grid>
<Grid Width="{Binding ConnectorWidth}" Height="{Binding ConnectorHeight}" HorizontalAlignment="Left" VerticalAlignment="Top">
<DataTemplate DataType="{x:Type dd:LogicalConnectorInfo}">
<Grid ToolTip="{Binding Name}">
<Grid Width="{Binding ConnectorWidth}" Height="{Binding ConnectorHeight}" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid.ContextMenu>
<ContextMenu ItemsSource="{Binding MenuOptions}">
<ContextMenu.ItemContainerStyle>
@@ -59,7 +59,8 @@
<TextBlock.Text>
<MultiBinding Converter="{StaticResource ConectorValueConverter}">
<Binding Path="ConnectorValue" />
<Binding Path="ValueTypePoint"/>
<Binding Path="ConnectorString" />
<Binding Path="ConnectorValueType"/>
</MultiBinding>
</TextBlock.Text>
<TextBlock.RenderTransform>
@@ -85,7 +86,8 @@
<TextBlock.Text>
<MultiBinding Converter="{StaticResource ConectorValueConverter}">
<Binding Path="ConnectorValue" />
<Binding Path="ValueTypePoint"/>
<Binding Path="ConnectorString" />
<Binding Path="ConnectorValueType"/>
</MultiBinding>
</TextBlock.Text>
<TextBlock.RenderTransform>

View File

@@ -1,36 +1,31 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner"
xmlns:dd="clr-namespace:AIStudio.Wpf.DiagramDesigner"
xmlns:c="clr-namespace:AIStudio.Wpf.DiagramDesigner.Controls"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:gif="http://wpfanimatedgif.codeplex.com" >
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<s:ColorBrushConverter x:Key="ColorBrushConverter" />
<s:ConectorOrientationConverter x:Key="ConectorOrientationConverter" />
<s:ConectorValueConverter x:Key="ConectorValueConverter"/>
<s:ArrowPathConverter x:Key="ArrowPathConverter"/>
<s:ArrowSizeConverter x:Key="ArrowSizeConverter"/>
<s:LineDashConverter x:Key="LineDashConverter"/>
<s:ClipConverter x:Key="ClipConverter"/>
<dd:ColorBrushConverter x:Key="ColorBrushConverter" />
<dd:ClipConverter x:Key="ClipConverter"/>
<DataTemplate DataType="{x:Type s:DefaultDesignerItemViewModel}">
<DataTemplate DataType="{x:Type dd:DefaultDesignerItemViewModel}">
<Grid IsHitTestVisible="False">
<Rectangle StrokeThickness="1" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" />
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type s:TextDesignerItemViewModel}">
<DataTemplate DataType="{x:Type dd:TextDesignerItemViewModel}">
<Grid >
<Border Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" IsHitTestVisible="False"/>
<Grid Margin="5">
<s:TextControl s:ControlAttachProperty.Watermark="{Binding Watermark}" />
<dd:TextControl dd:ControlAttachProperty.Watermark="{Binding Watermark}" />
</Grid>
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type s:ShapeDesignerItemViewModel}">
<DataTemplate DataType="{x:Type dd:ShapeDesignerItemViewModel}">
<Grid IsHitTestVisible="False" Background="White">
<Grid.ContextMenu>
<ContextMenu>
@@ -84,7 +79,7 @@
<Setter.Value>
<ControlTemplate>
<Polyline
Points="{Binding ConnectionPoints, Converter={x:Static s:ConnectionPointConverter.Instance}}"
Points="{Binding ConnectionPoints, Converter={x:Static dd:ConnectionPointConverter.Instance}}"
Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
StrokeThickness="{Binding ColorViewModel.LineWidth}"
Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
@@ -99,7 +94,7 @@
<Setter.Value>
<ControlTemplate>
<Polygon
Points="{Binding ConnectionPoints, Converter={x:Static s:ConnectionPointConverter.Instance}}"
Points="{Binding ConnectionPoints, Converter={x:Static dd:ConnectionPointConverter.Instance}}"
Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
StrokeThickness="{Binding ColorViewModel.LineWidth}"
Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
@@ -114,7 +109,7 @@
<Setter.Value>
<ControlTemplate>
<Polyline
Points="{Binding ConnectionPoints, Converter={x:Static s:ConnectionPointConverter.Instance}}"
Points="{Binding ConnectionPoints, Converter={x:Static dd:ConnectionPointConverter.Instance}}"
Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
StrokeThickness="{Binding ColorViewModel.LineWidth}"
Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
@@ -129,13 +124,13 @@
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type s:GroupDesignerItemViewModel}">
<DataTemplate DataType="{x:Type dd:GroupDesignerItemViewModel}">
<Grid IsHitTestVisible="False">
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type s:GifImageItemViewModel}">
<DataTemplate DataType="{x:Type dd:GifImageItemViewModel}">
<Grid IsHitTestVisible="False">
<Image Name="PART_Image_run" gif:ImageBehavior.AnimatedSource="{Binding Icon}" gif:ImageBehavior.AutoStart="True" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Visible"/>
<Control x:Name="control" />
@@ -147,13 +142,13 @@
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type s:VideoItemViewModel}">
<DataTemplate DataType="{x:Type dd:VideoItemViewModel}">
<Grid IsHitTestVisible="False">
<MediaElement x:Name="MediaPlayer" LoadedBehavior="Play" Source="{Binding Icon}" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Visible"/>
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type s:ImageItemViewModel}">
<DataTemplate DataType="{x:Type dd:ImageItemViewModel}">
<Grid ToolTip="{Binding Icon}">
<Grid IsHitTestVisible="False" ClipToBounds="True">
<Image x:Name="image" Source="{Binding Icon}" Stretch="Fill"

View File

@@ -1,10 +1,5 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner"
xmlns:c="clr-namespace:AIStudio.Wpf.DiagramDesigner.Controls"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:gif="http://wpfanimatedgif.codeplex.com" >
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/AIStudio.Wpf.DiagramDesigner;component/Themes/DesignerItem.xaml" />

View File

@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner"
xmlns:dd="clr-namespace:AIStudio.Wpf.DiagramDesigner"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<ItemsControl.ItemsPanel>

View File

@@ -32,16 +32,19 @@ namespace AIStudio.Wpf.DiagramDesigner
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach(var item in e.NewItems)
foreach (var item in e.NewItems)
{
FullyCreatedConnectorInfo vm = item as FullyCreatedConnectorInfo;
var connector = ItemContainerGenerator.ContainerFromItem(item) as ContentPresenter;
Canvas.SetLeft(connector, vm.DataItem.ItemWidth * vm.XRatio - vm.ConnectorWidth / 2);
Canvas.SetTop(connector, vm.DataItem.ItemHeight * vm.YRatio - vm.ConnectorHeight / 2);
if (connector != null)
{
Canvas.SetLeft(connector, vm.DataItem.ItemWidth * vm.XRatio - vm.ConnectorWidth / 2);
Canvas.SetTop(connector, vm.DataItem.ItemHeight * vm.YRatio - vm.ConnectorHeight / 2);
}
}
//SetConnectorLocation();
}
}
void ConnectorContainer_SizeChanged(object sender, SizeChangedEventArgs e)

File diff suppressed because it is too large Load Diff

View File

@@ -28,7 +28,12 @@ namespace AIStudio.Wpf.DiagramDesigner
this.Resources.MergedDictionaries.Add(ResourceDictionary);
}
this.Focusable = true;
this.IsVisibleChanged += DiagramControl_IsVisibleChanged;
}
private void DiagramControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
}
public static readonly DependencyProperty ResourceDictionaryProperty = DependencyProperty.Register(nameof(ResourceDictionary), typeof(ResourceDictionary), typeof(DiagramControl), new UIPropertyMetadata(null, OnResourceDictionaryChanged));
@@ -56,32 +61,6 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
public static readonly DependencyProperty ZoomValueProperty = DependencyProperty.Register(nameof(ZoomValue), typeof(double), typeof(DiagramControl), new UIPropertyMetadata(1d));
public double ZoomValue
{
get
{
return (double)GetValue(ZoomValueProperty);
}
set
{
SetValue(ZoomValueProperty, value);
}
}
private void DesignerCanvas_Loaded(object sender, RoutedEventArgs e)
{
//DesignerCanvas myDesignerCanvas = sender as DesignerCanvas;
//zoomBox.DesignerCanvas = myDesignerCanvas;
}
private async void ScaleTransform_Changed(object sender, EventArgs e)
{
await System.Threading.Tasks.Task.Delay(100);
ZoomValue = scale.ScaleX;
}
private IDiagramViewModel DiagramViewModel
{
get
@@ -90,28 +69,6 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
protected override void OnPreviewKeyDown(KeyEventArgs e)
{
base.OnPreviewKeyDown(e);
e.Handled = DiagramViewModel.ExecuteShortcut(e);
}
protected override void OnPreviewMouseWheel(MouseWheelEventArgs e)
{
base.OnPreviewMouseWheel(e);
if (Keyboard.IsKeyDown(Key.LeftCtrl) == false
&& Keyboard.IsKeyDown(Key.RightCtrl) == false)
{
return;
}
var newZoomValue = DiagramViewModel.ZoomValue + (e.Delta > 0 ? 0.1 : -0.1);
DiagramViewModel.ZoomValue = Math.Max(Math.Min(newZoomValue, 10), 0.5);
e.Handled = true;
}
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
namespace AIStudio.Wpf.DiagramDesigner
{
public class GridControl : Grid
{
public IDiagramViewModel DiagramViewModel
{
get
{
return (this.DataContext as SelectableDesignerItemViewModelBase)?.Root;
}
}
//protected override void OnPreviewKeyDown(KeyEventArgs e)
//{
// base.OnPreviewKeyDown(e);
// e.Handled = DiagramViewModel?.ExecuteShortcut(e) ?? false;
//}
}
}

Some files were not shown because too many files have changed in this diff Show More