mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-18 23:46:37 +08:00
C# 脚本模块正式发布
This commit is contained in:
73
Extensions/AIStudio.Wpf.Script/AIStudio.Wpf.Script.csproj
Normal file
73
Extensions/AIStudio.Wpf.Script/AIStudio.Wpf.Script.csproj
Normal file
@@ -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.
BIN
Extensions/AIStudio.Wpf.Script/Dlls/net461/HL.dll
Normal file
BIN
Extensions/AIStudio.Wpf.Script/Dlls/net461/HL.dll
Normal file
Binary file not shown.
BIN
Extensions/AIStudio.Wpf.Script/Dlls/net461/TextEditLib.dll
Normal file
BIN
Extensions/AIStudio.Wpf.Script/Dlls/net461/TextEditLib.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
Extensions/AIStudio.Wpf.Script/Dlls/net5.0-windows/HL.dll
Normal file
BIN
Extensions/AIStudio.Wpf.Script/Dlls/net5.0-windows/HL.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Extensions/AIStudio.Wpf.Script/Dlls/net6.0-windows/HL.dll
Normal file
BIN
Extensions/AIStudio.Wpf.Script/Dlls/net6.0-windows/HL.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Extensions/AIStudio.Wpf.Script/Dlls/netcoreapp3.1/HL.dll
Normal file
BIN
Extensions/AIStudio.Wpf.Script/Dlls/netcoreapp3.1/HL.dll
Normal file
Binary file not shown.
Binary file not shown.
16
Extensions/AIStudio.Wpf.Script/Properties/AssemblyInfo.cs
Normal file
16
Extensions/AIStudio.Wpf.Script/Properties/AssemblyInfo.cs
Normal file
@@ -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