mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-06-06 18:08:20 +08:00
C# 脚本模块正式发布
This commit is contained in:
@@ -19,7 +19,6 @@ 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("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2BE1891E-16C9-4191-998A-45AEEEEA1F0D}"
|
||||
@@ -34,6 +33,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demos", "Demos", "{62DC8608
|
||||
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
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIStudio.Wpf.Script", "Extensions\AIStudio.Wpf.Script\AIStudio.Wpf.Script.csproj", "{27A4C86D-3792-4D14-BAEE-3B103A709872}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -76,6 +77,10 @@ Global
|
||||
{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
|
||||
{27A4C86D-3792-4D14-BAEE-3B103A709872}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{27A4C86D-3792-4D14-BAEE-3B103A709872}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{27A4C86D-3792-4D14-BAEE-3B103A709872}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{27A4C86D-3792-4D14-BAEE-3B103A709872}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -86,6 +91,7 @@ Global
|
||||
{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}
|
||||
{27A4C86D-3792-4D14-BAEE-3B103A709872} = {4959F170-02FB-4B7F-8F53-93DAF22713F9}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {D30FC641-F06C-4E35-AEA5-48A9B6E59CE0}
|
||||
|
||||
@@ -131,9 +131,34 @@
|
||||
<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.Script\AIStudio.Wpf.Script.csproj" />
|
||||
<ProjectReference Include="..\Extensions\AIStudio.Wpf.SFC\AIStudio.Wpf.SFC.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0-windows'">
|
||||
<Reference Include="AIStudio.Wpf.Script.Core">
|
||||
<HintPath>..\Extensions\AIStudio.Wpf.Script\Dlls\net5.0-windows\AIStudio.Wpf.Script.Core.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-windows'">
|
||||
<Reference Include="AIStudio.Wpf.Script.Core">
|
||||
<HintPath>..\Extensions\AIStudio.Wpf.Script\Dlls\net6.0-windows\AIStudio.Wpf.Script.Core.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<Reference Include="AIStudio.Wpf.Script.Core">
|
||||
<HintPath>..\Extensions\AIStudio.Wpf.Script\Dlls\netcoreapp3.1\AIStudio.Wpf.Script.Core.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
|
||||
<Reference Include="AIStudio.Wpf.Script.Core">
|
||||
<HintPath>..\Extensions\AIStudio.Wpf.Script\Dlls\net461\AIStudio.Wpf.Script.Core.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="Icons\App.ico" />
|
||||
<Resource Include="Images\AlignObjectsBottom.png" />
|
||||
|
||||
@@ -8,12 +8,15 @@
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Fluent;component/Themes/Generic.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/Dragablz;component/Themes/Generic.xaml" />
|
||||
<ResourceDictionary Source="/AIStudio.Wpf.DiagramApp;component/Themes/Generic.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramApp;component/Themes/Generic.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/Themes/FlowNode.xaml"/>
|
||||
<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 Source="pack://application:,,,/AIStudio.Wpf.Script.Core;component/Themes/RoslynScriptViewModel.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Script;component/Themes/ColorBoxFactoryScriptViewModel.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Script;component/Themes/ColorBoxCollectorScriptViewModel.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
@@ -1,15 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramApp.Models;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.Script.Core.Helpers;
|
||||
using AIStudio.Wpf.Script.Core.Models;
|
||||
using AIStudio.Wpf.Script.Core.ViewModels;
|
||||
using AIStudio.Wpf.Script.ViewModels;
|
||||
using AIStudio.Wpf.SFC;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
public class ScriptViewModel : PageViewModel
|
||||
{
|
||||
static ScriptViewModel()
|
||||
{
|
||||
TextEditorThemeHelper.SetCurrentTheme("VS2019_Dark");
|
||||
}
|
||||
|
||||
public ScriptViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
|
||||
{
|
||||
Init(true);
|
||||
@@ -19,17 +34,177 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
if (DiagramViewModel != null)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
readDataTimer.Elapsed += timeCycle;
|
||||
readDataTimer.Interval = 1000;
|
||||
readDataTimer.AutoReset = false;
|
||||
readDataTimer.Start();
|
||||
}
|
||||
|
||||
protected override void InitDiagramViewModel()
|
||||
{
|
||||
base.InitDiagramViewModel();
|
||||
|
||||
DiagramViewModel.PageSizeType = PageSizeType.Custom;
|
||||
DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
|
||||
DiagramViewModel.ColorViewModel = new ColorViewModel();
|
||||
DiagramViewModel.ColorViewModel.FillColor.Color = System.Windows.Media.Colors.Orange;
|
||||
}
|
||||
|
||||
private System.Timers.Timer readDataTimer = new System.Timers.Timer();
|
||||
protected override void Init(bool initNew)
|
||||
{
|
||||
base.Init(initNew);
|
||||
|
||||
ConsoleLogViewModel logNode = new ConsoleLogViewModel(DiagramViewModel) { Name = "Log", Left = 150, Top = 420 };
|
||||
DiagramViewModel.Add(logNode);
|
||||
|
||||
IntScriptViewModel intLog = new IntScriptViewModel(DiagramViewModel) { Name = "Int", Left = 40, Top = 220 };
|
||||
DiagramViewModel.Add(intLog);
|
||||
|
||||
ColorBoxFactoryScriptViewModel factoryNode = new ColorBoxFactoryScriptViewModel(DiagramViewModel) { Name = "ColorBoxFactory", Left = 150, Top = 150 };
|
||||
DiagramViewModel.Add(factoryNode);
|
||||
|
||||
BoolScriptViewModel boolNode = new BoolScriptViewModel(DiagramViewModel) { Name = "Bool", TrueString = "形状", FalseString = "颜色", Left = 410, Top = 190 };
|
||||
DiagramViewModel.Add(boolNode);
|
||||
|
||||
ColorBoxSwitchScriptViewModel switchNode = new ColorBoxSwitchScriptViewModel(DiagramViewModel) { Name = "ColorBoxSwitch", Left = 500, Top = 150 };
|
||||
DiagramViewModel.Add(switchNode);
|
||||
|
||||
TextScriptViewModel textNode = new TextScriptViewModel(DiagramViewModel) { Name = "Text", Text = "AIStudio Diagram", Left = 150, Top = 50, ItemWidth = 450, ItemHeight = 60 };
|
||||
DiagramViewModel.Add(textNode);
|
||||
|
||||
ColorBoxIfScriptViewModel ifNode = new ColorBoxIfScriptViewModel(DiagramViewModel) { Name = "ColorBoxIf", Left = 660, Top = 60 };
|
||||
DiagramViewModel.Add(ifNode);
|
||||
|
||||
ColorBoxCollectorScriptViewModel collectorNode1_1 = new ColorBoxCollectorScriptViewModel(DiagramViewModel) { Name = "Collector1_1", Left = 790, Top = 40 };
|
||||
collectorNode1_1.Tag = new ColorBoxModel("红色|圆形", "M 10,20 A 20,20 0 1 1 50,20 A 20,20 0 1 1 10,20", Colors.Red);
|
||||
DiagramViewModel.Add(collectorNode1_1);
|
||||
|
||||
ColorBoxCollectorScriptViewModel collectorNode1_2 = new ColorBoxCollectorScriptViewModel(DiagramViewModel) { Name = "Collector1_2", Left = 790, Top = 120 };
|
||||
collectorNode1_2.Tag = new ColorBoxModel("红色|圆形", "M 10,20 A 20,20 0 1 1 50,20 A 20,20 0 1 1 10,20", Colors.Red);
|
||||
DiagramViewModel.Add(collectorNode1_2);
|
||||
|
||||
ColorBoxCollectorScriptViewModel collectorNode2 = new ColorBoxCollectorScriptViewModel(DiagramViewModel) { Name = "Collector2", Left = 790, Top = 220 };
|
||||
collectorNode2.Tag = new ColorBoxModel("橙色|三角形", "M1,21H23L12,2", Colors.Orange);
|
||||
DiagramViewModel.Add(collectorNode2);
|
||||
|
||||
ColorBoxCollectorScriptViewModel collectorNode3 = new ColorBoxCollectorScriptViewModel(DiagramViewModel) { Name = "Collector3", Left = 790, Top = 305 };
|
||||
collectorNode3.Tag = new ColorBoxModel("黄色|方形", "M3,3V21H21V3", Colors.Yellow);
|
||||
DiagramViewModel.Add(collectorNode3);
|
||||
|
||||
ColorBoxCollectorScriptViewModel collectorNode4 = new ColorBoxCollectorScriptViewModel(DiagramViewModel) { Name = "Collector4", Left = 790, Top = 390 };
|
||||
collectorNode4.Tag = new ColorBoxModel("绿色|菱形", "M 0,20 L 30 0 L 60,20 L 30,40 Z", Colors.Green);
|
||||
DiagramViewModel.Add(collectorNode4);
|
||||
|
||||
ColorBoxCollectorScriptViewModel collectorNode5 = new ColorBoxCollectorScriptViewModel(DiagramViewModel) { Name = "Collector5", Left = 790, Top = 475 };
|
||||
collectorNode5.Tag = new ColorBoxModel("青色|梯形", "M 0 0 H 60 L 50 40 H 10 Z", Colors.Cyan);
|
||||
DiagramViewModel.Add(collectorNode5);
|
||||
|
||||
ColorBoxCollectorScriptViewModel collectorNode6 = new ColorBoxCollectorScriptViewModel(DiagramViewModel) { Name = "Collector6", Left = 790, Top = 560 };
|
||||
collectorNode6.Tag = new ColorBoxModel("蓝色|五角星", "M 9,2 11,7 17,7 12,10 14,15 9,12 4,15 6,10 1,7 7,7 Z", Colors.Blue);
|
||||
DiagramViewModel.Add(collectorNode6);
|
||||
|
||||
ColorBoxCollectorScriptViewModel collectorNode7 = new ColorBoxCollectorScriptViewModel(DiagramViewModel) { Name = "Collector7", Left = 790, Top = 645 };
|
||||
collectorNode7.Tag = new ColorBoxModel("紫色|六边形", "M 0,20 L 10,0 H 50 L 60,20 L 50,40 H10 Z", Colors.Purple);
|
||||
DiagramViewModel.Add(collectorNode7);
|
||||
|
||||
ConnectionViewModel int_factoryConnector = new ConnectionViewModel(DiagramViewModel, intLog.Output[0], factoryNode.Input[0], DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
DiagramViewModel.Add(int_factoryConnector);
|
||||
|
||||
ConnectionViewModel bool_switchConnector = new ConnectionViewModel(DiagramViewModel, boolNode.Output[0], switchNode.Input[0], DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
DiagramViewModel.Add(bool_switchConnector);
|
||||
|
||||
ConnectionViewModel factory_switchConnector = new ConnectionViewModel(DiagramViewModel, factoryNode.Output[0], switchNode.Input[1], DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
factory_switchConnector.AnimationViewModel.Repeat = false;
|
||||
factory_switchConnector.AnimationViewModel.Animation = LineAnimation.PathAnimation;
|
||||
DiagramViewModel.Add(factory_switchConnector);
|
||||
|
||||
ConnectionViewModel switch_textConnector = new ConnectionViewModel(DiagramViewModel, switchNode.Output[0], textNode.Input[0], DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
switch_textConnector.SetPathGeneratorParameter(null, null, 5, 10);
|
||||
DiagramViewModel.Add(switch_textConnector);
|
||||
|
||||
ConnectionViewModel switch_ifConnector = new ConnectionViewModel(DiagramViewModel, switchNode.Output[1], ifNode.Input[2], DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
switch_ifConnector.AnimationViewModel.Repeat = false;
|
||||
switch_ifConnector.AnimationViewModel.Animation = LineAnimation.PathAnimation;
|
||||
DiagramViewModel.Add(switch_ifConnector);
|
||||
|
||||
ConnectionViewModel if_collector1_1Connector = new ConnectionViewModel(DiagramViewModel, ifNode.Output[0], collectorNode1_1.Input[0], DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
if_collector1_1Connector.AnimationViewModel.Repeat = false;
|
||||
if_collector1_1Connector.AnimationViewModel.Animation = LineAnimation.PathAnimation;
|
||||
DiagramViewModel.Add(if_collector1_1Connector);
|
||||
|
||||
ConnectionViewModel if_collector1_2Connector = new ConnectionViewModel(DiagramViewModel, ifNode.Output[1], collectorNode1_2.Input[0], DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
if_collector1_2Connector.AnimationViewModel.Repeat = false;
|
||||
if_collector1_2Connector.AnimationViewModel.Animation = LineAnimation.PathAnimation;
|
||||
DiagramViewModel.Add(if_collector1_2Connector);
|
||||
|
||||
ConnectionViewModel collector1_1_if_Connector = new ConnectionViewModel(DiagramViewModel, collectorNode1_1.Output[0], ifNode.Input[0], DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
collector1_1_if_Connector.SetPathGeneratorParameter(null, null, 5, 30);
|
||||
DiagramViewModel.Add(collector1_1_if_Connector);
|
||||
|
||||
ConnectionViewModel collector1_2_if_Connector = new ConnectionViewModel(DiagramViewModel, collectorNode1_2.Output[0], ifNode.Input[1], DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
collector1_2_if_Connector.SetPathGeneratorParameter(null, null, 5, 10);
|
||||
DiagramViewModel.Add(collector1_2_if_Connector);
|
||||
|
||||
ConnectionViewModel switch_collector2Connector = new ConnectionViewModel(DiagramViewModel, switchNode.Output[2], collectorNode2.Input[0], DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
switch_collector2Connector.AnimationViewModel.Repeat = false;
|
||||
switch_collector2Connector.AnimationViewModel.Animation = LineAnimation.PathAnimation;
|
||||
DiagramViewModel.Add(switch_collector2Connector);
|
||||
|
||||
ConnectionViewModel switch_collector3Connector = new ConnectionViewModel(DiagramViewModel, switchNode.Output[3], collectorNode3.Input[0], DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
switch_collector3Connector.AnimationViewModel.Repeat = false;
|
||||
switch_collector3Connector.AnimationViewModel.Animation = LineAnimation.PathAnimation;
|
||||
DiagramViewModel.Add(switch_collector3Connector);
|
||||
|
||||
ConnectionViewModel switch_collector4Connector = new ConnectionViewModel(DiagramViewModel, switchNode.Output[4], collectorNode4.Input[0], DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
switch_collector4Connector.AnimationViewModel.Repeat = false;
|
||||
switch_collector4Connector.AnimationViewModel.Animation = LineAnimation.PathAnimation;
|
||||
DiagramViewModel.Add(switch_collector4Connector);
|
||||
|
||||
ConnectionViewModel switch_collector5Connector = new ConnectionViewModel(DiagramViewModel, switchNode.Output[5], collectorNode5.Input[0], DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
switch_collector5Connector.AnimationViewModel.Repeat = false;
|
||||
switch_collector5Connector.AnimationViewModel.Animation = LineAnimation.PathAnimation;
|
||||
DiagramViewModel.Add(switch_collector5Connector);
|
||||
|
||||
ConnectionViewModel switch_collector6Connector = new ConnectionViewModel(DiagramViewModel, switchNode.Output[6], collectorNode6.Input[0], DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
switch_collector6Connector.AnimationViewModel.Repeat = false;
|
||||
switch_collector6Connector.AnimationViewModel.Animation = LineAnimation.PathAnimation;
|
||||
DiagramViewModel.Add(switch_collector6Connector);
|
||||
|
||||
ConnectionViewModel switch_collector7Connector = new ConnectionViewModel(DiagramViewModel, switchNode.Output[7], collectorNode7.Input[0], DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
switch_collector7Connector.AnimationViewModel.Repeat = false;
|
||||
switch_collector7Connector.AnimationViewModel.Animation = LineAnimation.PathAnimation;
|
||||
DiagramViewModel.Add(switch_collector7Connector);
|
||||
|
||||
readDataTimer.Elapsed += timeCycle;
|
||||
readDataTimer.Interval = 1000;
|
||||
readDataTimer.AutoReset = false;
|
||||
readDataTimer.Start();
|
||||
}
|
||||
|
||||
private void timeCycle(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
foreach (var item in DiagramViewModel.Items.OfType<LogicalGateItemViewModelBase>().OrderBy(p => p.OrderNumber).ToList())
|
||||
{
|
||||
item.Execute();
|
||||
}
|
||||
readDataTimer.Start();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
|
||||
readDataTimer.Stop();
|
||||
readDataTimer.Dispose();
|
||||
|
||||
foreach (var item in DiagramViewModel.Items.OfType<LogicalGateItemViewModelBase>().OrderBy(p => p.OrderNumber).ToList())
|
||||
{
|
||||
item.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<PackageIcon>A.png</PackageIcon>
|
||||
<PackageIconUrl />
|
||||
<NeutralLanguage />
|
||||
<Version>1.1.4</Version>
|
||||
<Version>1.1.5</Version>
|
||||
<Description>一个Wpf的Diagram控件基础库</Description>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@
|
||||
BorderThickness="1"
|
||||
Background="#EEE"
|
||||
BorderBrush="DimGray">
|
||||
<Expander IsExpanded="True"
|
||||
<Expander IsExpanded="False"
|
||||
Background="Transparent">
|
||||
<Border BorderBrush="DimGray"
|
||||
BorderThickness="0,1,0,0"
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
await DoAnimation();
|
||||
break;
|
||||
case nameof(AnimationViewModel.Start):
|
||||
await Application.Current.Dispatcher.BeginInvoke(async () => {
|
||||
await Application.Current.Dispatcher.Invoke(async () => {
|
||||
await DoAnimation();
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<!-- Project properties -->
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0-windows</TargetFrameworks>
|
||||
<TargetFrameworks>net461;netcoreapp3.1;net5.0-windows;net6.0-windows</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<UseWPF>true</UseWPF>
|
||||
<Company>AIStudio.Wpf.Controls</Company>
|
||||
<Authors>akwkevin</Authors>
|
||||
<PackageProjectUrl>https://gitee.com/akwkevin</PackageProjectUrl>
|
||||
<PackageIcon>A.png</PackageIcon>
|
||||
<PackageIconUrl />
|
||||
<NeutralLanguage />
|
||||
<Version>1.0.6</Version>
|
||||
<Description>一个Wpf的脚本生成模块</Description>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\AIStudio.Wpf.DiagramDesigner\AIStudio.Wpf.DiagramDesigner.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.5.0" />
|
||||
<PackageReference Include="AvalonEdit" Version="6.1.2.30" />
|
||||
<PackageReference Include="System.ServiceModel.Primitives" Version="4.10.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0-windows'">
|
||||
<Reference Include="AIStudio.Wpf.Script.Core">
|
||||
<HintPath>Dlls\net5.0-windows\AIStudio.Wpf.Script.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HL">
|
||||
<HintPath>Dlls\net5.0-windows\HL.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="TextEditLib">
|
||||
<HintPath>Dlls\net5.0-windows\TextEditLib.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-windows'">
|
||||
<Reference Include="AIStudio.Wpf.Script.Core">
|
||||
<HintPath>Dlls\net6.0-windows\AIStudio.Wpf.Script.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HL">
|
||||
<HintPath>Dlls\net6.0-windows\HL.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="TextEditLib">
|
||||
<HintPath>Dlls\net6.0-windows\TextEditLib.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<Reference Include="AIStudio.Wpf.Script.Core">
|
||||
<HintPath>Dlls\netcoreapp3.1\AIStudio.Wpf.Script.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HL">
|
||||
<HintPath>Dlls\netcoreapp3.1\HL.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="TextEditLib">
|
||||
<HintPath>Dlls\netcoreapp3.1\TextEditLib.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
|
||||
<Reference Include="AIStudio.Wpf.Script.Core">
|
||||
<HintPath>Dlls\net461\AIStudio.Wpf.Script.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HL">
|
||||
<HintPath>Dlls\net461\HL.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="TextEditLib">
|
||||
<HintPath>Dlls\net461\TextEditLib.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
[assembly: XmlnsDefinition("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "AIStudio.Wpf.Script")]
|
||||
|
||||
|
||||
[assembly: XmlnsPrefix("https://gitee.com/akwkevin/aistudio.-wpf.-diagram", "dd")]
|
||||
@@ -0,0 +1,64 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.Script.ViewModels"
|
||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||
xmlns:avEditEx="clr-namespace:TextEditLib;assembly=TextEditLib"
|
||||
xmlns:reskeys="clr-namespace:TextEditLib.Themes;assembly=TextEditLib"
|
||||
xmlns:helper="clr-namespace:AIStudio.Wpf.Script.Helpers"
|
||||
xmlns:controls="clr-namespace:AIStudio.Wpf.Script.Controls">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/TextEditLib;component/Themes/Icons.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<dd:ColorBrushConverter x:Key="ColorBrushConverter"/>
|
||||
|
||||
<DataTemplate DataType="{x:Type viewmodel:ColorBoxCollectorScriptViewModel}">
|
||||
<Grid IsHitTestVisible="False">
|
||||
<Border BorderThickness="{Binding BorderThickness}"
|
||||
BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
|
||||
Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
|
||||
CornerRadius="{Binding CornerRadius}"
|
||||
IsHitTestVisible="False">
|
||||
</Border>
|
||||
<ItemsControl ItemsSource="{Binding ItemsSource}" Margin="5">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="1">
|
||||
<Path
|
||||
Data="{Binding Path}"
|
||||
Fill="{Binding Color,Converter={StaticResource ColorBrushConverter}}"
|
||||
Stretch="Fill"
|
||||
Width="20"
|
||||
Height="20"/>
|
||||
<TextBlock
|
||||
Text="{Binding Text}"
|
||||
FontSize="9"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<TextBlock Text="{Binding OrderNumber,StringFormat={}{0}#}" Foreground="Blue" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="2"/>
|
||||
<StackPanel Margin="-45,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center">
|
||||
<Path
|
||||
Data="{Binding Tag.Path}"
|
||||
Fill="{Binding Tag.Color,Converter={StaticResource ColorBrushConverter}}"
|
||||
Stretch="Fill"
|
||||
Width="16"
|
||||
Height="16"/>
|
||||
<TextBlock
|
||||
Text="{Binding Tag.Text}"
|
||||
FontSize="9"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,51 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.Script.ViewModels"
|
||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||
xmlns:avEditEx="clr-namespace:TextEditLib;assembly=TextEditLib"
|
||||
xmlns:reskeys="clr-namespace:TextEditLib.Themes;assembly=TextEditLib"
|
||||
xmlns:helper="clr-namespace:AIStudio.Wpf.Script.Core.Helpers;assembly=AIStudio.Wpf.Script.Core"
|
||||
xmlns:controls="clr-namespace:AIStudio.Wpf.Script.Core.Controls;assembly=AIStudio.Wpf.Script.Core">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/TextEditLib;component/Themes/Icons.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<dd:ColorBrushConverter x:Key="ColorBrushConverter"/>
|
||||
|
||||
<DataTemplate DataType="{x:Type viewmodel:ColorBoxFactoryScriptViewModel}">
|
||||
<Grid IsHitTestVisible="False">
|
||||
<Border BorderThickness="{Binding BorderThickness}"
|
||||
BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
|
||||
Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"
|
||||
CornerRadius="{Binding CornerRadius}"
|
||||
IsHitTestVisible="False">
|
||||
</Border>
|
||||
<ItemsControl ItemsSource="{Binding ItemsSource}" Margin="5">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="1">
|
||||
<Path
|
||||
Data="{Binding Path}"
|
||||
Fill="{Binding Color,Converter={StaticResource ColorBrushConverter}}"
|
||||
Stretch="Fill"
|
||||
Width="20"
|
||||
Height="20"/>
|
||||
<TextBlock
|
||||
Text="{Binding Text}"
|
||||
FontSize="9"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<TextBlock Text="{Binding OrderNumber,StringFormat={}{0}#}" Foreground="Blue" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="2"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,78 @@
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
using AIStudio.Wpf.Script.Core.Models;
|
||||
using AIStudio.Wpf.Script.Core.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AIStudio.Wpf.Script.ViewModels
|
||||
{
|
||||
public class ColorBoxCollectorScriptViewModel : RoslynScriptViewModel
|
||||
{
|
||||
public ColorBoxCollectorScriptViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public ColorBoxCollectorScriptViewModel(IDiagramViewModel root) : base(root)
|
||||
{
|
||||
}
|
||||
|
||||
public ColorBoxCollectorScriptViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
}
|
||||
|
||||
public ColorBoxCollectorScriptViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitNew()
|
||||
{
|
||||
base.InitNew();
|
||||
|
||||
ItemWidth = 230;
|
||||
ItemHeight = 76;
|
||||
Code = @"using System;
|
||||
using System.Collections.Generic;
|
||||
using AIStudio.Wpf.Script.Core.Models;
|
||||
using System.Windows.Media;
|
||||
using System.Linq;
|
||||
|
||||
namespace AIStudio.Wpf.CSharpScript
|
||||
{
|
||||
public class ColorBoxFactory
|
||||
{
|
||||
private List<ColorBoxModel> ItemsSource { get; set;} = new List<ColorBoxModel>();
|
||||
public ColorBoxModel Input {private get; set;}
|
||||
public int Count{ get; private set;}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
if (Input != null)
|
||||
{
|
||||
ItemsSource.Add(Input);
|
||||
Input = null;
|
||||
Console.WriteLine($""收集到{Input.Text}号Box"");
|
||||
}
|
||||
|
||||
Count = ItemsSource.Count;
|
||||
}
|
||||
}
|
||||
}";
|
||||
}
|
||||
|
||||
private List<ColorBoxModel> _itemsSource;
|
||||
public List<ColorBoxModel> ItemsSource
|
||||
{
|
||||
get
|
||||
{
|
||||
return _itemsSource;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _itemsSource, value);
|
||||
}
|
||||
}
|
||||
|
||||
public ColorBoxModel Tag { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
using AIStudio.Wpf.Script.Core.Models;
|
||||
using AIStudio.Wpf.Script.Core.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AIStudio.Wpf.Script.ViewModels
|
||||
{
|
||||
public class ColorBoxFactoryScriptViewModel : RoslynScriptViewModel
|
||||
{
|
||||
public ColorBoxFactoryScriptViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public ColorBoxFactoryScriptViewModel(IDiagramViewModel root) : base(root)
|
||||
{
|
||||
}
|
||||
|
||||
public ColorBoxFactoryScriptViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
}
|
||||
|
||||
public ColorBoxFactoryScriptViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitNew()
|
||||
{
|
||||
base.InitNew();
|
||||
|
||||
ItemWidth = 230;
|
||||
ItemHeight = 230;
|
||||
Code = @"using System;
|
||||
using System.Collections.Generic;
|
||||
using AIStudio.Wpf.Script.Core.Models;
|
||||
using System.Windows.Media;
|
||||
using System.Linq;
|
||||
|
||||
namespace AIStudio.Wpf.CSharpScript
|
||||
{
|
||||
public class ColorBoxFactory
|
||||
{
|
||||
public int Count{private get;set;} = 100;
|
||||
private List<ColorBoxModel> ItemsSource { get; set;} = new List<ColorBoxModel>();
|
||||
public ColorBoxModel Output {get;private set;}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
if (ItemsSource.Count == 0)
|
||||
{
|
||||
Random random = new Random();
|
||||
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
var sharpindex = random.Next(0, 8);
|
||||
if (sharpindex == 7)
|
||||
{
|
||||
sharpindex = 0;
|
||||
}
|
||||
|
||||
var colorindex = random.Next(0, 8);
|
||||
if (colorindex == 7)
|
||||
{
|
||||
colorindex = 0;
|
||||
}
|
||||
string sharp = ColorBoxModel.SettingSharps[sharpindex];
|
||||
Color color = ColorBoxModel.SettingColors[colorindex];
|
||||
|
||||
ColorBoxModel colorBoxModel = new ColorBoxModel(i.ToString(), sharp, color);
|
||||
ItemsSource.Add(colorBoxModel);
|
||||
}
|
||||
Console.WriteLine($""初始化完成,一共初始化Box{Count}个"");
|
||||
}
|
||||
else if (Output == null)
|
||||
{
|
||||
Output = ItemsSource.FirstOrDefault();
|
||||
ItemsSource.RemoveAt(0);
|
||||
Console.WriteLine($""装配{Output.Text}号Box"");
|
||||
}
|
||||
}
|
||||
}
|
||||
}";
|
||||
}
|
||||
|
||||
private List<ColorBoxModel> _itemsSource;
|
||||
public List<ColorBoxModel> ItemsSource
|
||||
{
|
||||
get
|
||||
{
|
||||
return _itemsSource;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _itemsSource, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
using AIStudio.Wpf.Script.Core.Models;
|
||||
using AIStudio.Wpf.Script.Core.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AIStudio.Wpf.Script.ViewModels
|
||||
{
|
||||
public class ColorBoxIfScriptViewModel : RoslynScriptViewModel
|
||||
{
|
||||
public ColorBoxIfScriptViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public ColorBoxIfScriptViewModel(IDiagramViewModel root) : base(root)
|
||||
{
|
||||
}
|
||||
|
||||
public ColorBoxIfScriptViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
}
|
||||
|
||||
public ColorBoxIfScriptViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitNew()
|
||||
{
|
||||
base.InitNew();
|
||||
|
||||
ItemWidth = 80;
|
||||
ItemHeight = 80;
|
||||
Text = "均衡分配器";
|
||||
Code = @"using System;
|
||||
using System.Collections.Generic;
|
||||
using AIStudio.Wpf.Script.Core.Models;
|
||||
using System.Windows.Media;
|
||||
using System.Linq;
|
||||
|
||||
namespace AIStudio.Wpf.CSharpScript
|
||||
{
|
||||
public class ColorBoxIfScript
|
||||
{
|
||||
public int Count1 {private get;set;}
|
||||
public int Count2 {private get;set;}
|
||||
public ColorBoxModel Input {private get; set;}
|
||||
public ColorBoxModel Output1 {get;private set;}
|
||||
public ColorBoxModel Output2 {get;private set;}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
if (Input != null)
|
||||
{
|
||||
Console.WriteLine($""等待均衡负载{Input.Text}号Box"");
|
||||
if (Count1 <= Count2)
|
||||
{
|
||||
if (Output1 == null)
|
||||
{
|
||||
Output1 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output1.Text}号Box均衡负载完毕,送往1号出口"");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Output2 == null)
|
||||
{
|
||||
Output2 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output2.Text}号Box均衡负载完毕,送往2号出口"");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}";
|
||||
}
|
||||
|
||||
private List<ColorBoxModel> _itemsSource;
|
||||
public List<ColorBoxModel> ItemsSource
|
||||
{
|
||||
get
|
||||
{
|
||||
return _itemsSource;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _itemsSource, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
using AIStudio.Wpf.Script.Core.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.Script.ViewModels
|
||||
{
|
||||
public class ColorBoxSwitchScriptViewModel : RoslynScriptViewModel
|
||||
{
|
||||
public ColorBoxSwitchScriptViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public ColorBoxSwitchScriptViewModel(IDiagramViewModel root) : base(root)
|
||||
{
|
||||
}
|
||||
|
||||
public ColorBoxSwitchScriptViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
}
|
||||
|
||||
public ColorBoxSwitchScriptViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitNew()
|
||||
{
|
||||
base.InitNew();
|
||||
|
||||
Text = "ColorBox分配器";
|
||||
ItemWidth = 100;
|
||||
ItemHeight = 230;
|
||||
Code = @"using AIStudio.Wpf.Script.Core.Models;
|
||||
using System;
|
||||
|
||||
namespace AIStudio.Wpf.CSharpScript
|
||||
{
|
||||
public class ColorBoxSwitch
|
||||
{
|
||||
public bool Mode { private get; set; }
|
||||
public string Description { get; private set; }
|
||||
public ColorBoxModel Input { private get; set; }
|
||||
public ColorBoxModel Output1 { get; private set; }
|
||||
public ColorBoxModel Output2 { get; private set; }
|
||||
public ColorBoxModel Output3 { get; private set; }
|
||||
public ColorBoxModel Output4 { get; private set; }
|
||||
public ColorBoxModel Output5 { get; private set; }
|
||||
public ColorBoxModel Output6 { get; private set; }
|
||||
public ColorBoxModel Output7 { get; private set; }
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
if (Input == null)
|
||||
return;
|
||||
|
||||
if (Mode == false)
|
||||
{
|
||||
Console.WriteLine($""正在使用按颜色分配,等待分配{Input.Text}号Box"");
|
||||
Description = ""欢迎来到AIStudio Diagream Box装配工厂,正在使用按颜色分配Box"";
|
||||
switch (Input.Color.ToString())
|
||||
{
|
||||
case ""#FFFF0000"":
|
||||
if (Output1 == null)
|
||||
{
|
||||
Output1 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output1.Text}号Box分配完毕,送往1号出口"");
|
||||
}
|
||||
break;
|
||||
case ""#FFFFA500"":
|
||||
if (Output2 == null)
|
||||
{
|
||||
Output2 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output2.Text}号Box分配完毕,送往2号出口"");
|
||||
}
|
||||
break;
|
||||
case ""#FFFFFF00"":
|
||||
if (Output3 == null)
|
||||
{
|
||||
Output3 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output3.Text}号Box分配完毕,送往3号出口"");
|
||||
}
|
||||
break;
|
||||
case ""#FF008000"":
|
||||
if (Output4 == null)
|
||||
{
|
||||
Output4 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output4.Text}号Box分配完毕,送往4号出口"");
|
||||
}
|
||||
break;
|
||||
case ""#FF00FFFF"":
|
||||
if (Output5 == null)
|
||||
{
|
||||
Output5 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output5.Text}号Box分配完毕,送往5号出口"");
|
||||
}
|
||||
break;
|
||||
case ""#FF0000FF"":
|
||||
if (Output6 == null)
|
||||
{
|
||||
Output6 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output6.Text}号Box分配完毕,送往6号出口"");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (Output7 == null)
|
||||
{
|
||||
Output7 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output7.Text}号Box分配完毕,送往7号出口"");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($""正在使用按形状分配,等待分配{Input.Text}号Box"");
|
||||
Description = ""欢迎来到AIStudio Diagream Box装配工厂,正在使用按形状分配Box"";
|
||||
switch (Input.Path)
|
||||
{
|
||||
case ""M 10,20 A 20,20 0 1 1 50,20 A 20,20 0 1 1 10,20"":
|
||||
if (Output1 == null)
|
||||
{
|
||||
Output1 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output1.Text}号Box分配完毕,送往1号出口"");
|
||||
}
|
||||
break;
|
||||
case ""M1,21H23L12,2"":
|
||||
if (Output2 == null)
|
||||
{
|
||||
Output2 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output2.Text}号Box分配完毕,送往2号出口"");
|
||||
}
|
||||
break;
|
||||
case ""M3,3V21H21V3"":
|
||||
if (Output3 == null)
|
||||
{
|
||||
Output3 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output3.Text}号Box分配完毕,送往3号出口"");
|
||||
}
|
||||
break;
|
||||
case ""M 0,20 L 30 0 L 60,20 L 30,40 Z"":
|
||||
if (Output4 == null)
|
||||
{
|
||||
Output4 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output4.Text}号Box分配完毕,送往4号出口"");
|
||||
}
|
||||
break;
|
||||
case ""M 0 0 H 60 L 50 40 H 10 Z"":
|
||||
if (Output5 == null)
|
||||
{
|
||||
Output5 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output5.Text}号Box分配完毕,送往5号出口"");
|
||||
}
|
||||
break;
|
||||
case ""M 9,2 11,7 17,7 12,10 14,15 9,12 4,15 6,10 1,7 7,7 Z"":
|
||||
if (Output6 == null)
|
||||
{
|
||||
Output6 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output6.Text}号Box分配完毕,送往6号出口"");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (Output7 == null)
|
||||
{
|
||||
Output7 = Input;
|
||||
Input = null;
|
||||
Console.WriteLine($""{Output7.Text}号Box分配完毕,送往7号出口"");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user