2021-07-29 13:55:18 +08:00
|
|
|
|
using AIStudio.Wpf.Flowchart;
|
2021-07-30 18:26:35 +08:00
|
|
|
|
using AIStudio.Wpf.SFC;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Windows.Media;
|
2022-10-28 22:45:39 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner;
|
|
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
2023-01-25 23:55:30 +08:00
|
|
|
|
using System.Windows;
|
2023-02-03 18:23:53 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Security.Cryptography.X509Certificates;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2022-10-28 22:45:39 +08:00
|
|
|
|
namespace AIStudio.Wpf.DiagramApp.Models
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
public class PathToolBoxData : ToolBoxData
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
public PathToolBoxData(string icon, Type type, double width = 32, double height = 32, Size? desiredSize = null, Size? desiredMinSize = null, string description = null) : base(null, icon, type, width, height, desiredSize, desiredMinSize, description)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
ColorViewModel.FillColor.Color = Colors.Orange;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class TextToolBoxData : ToolBoxData
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
public TextToolBoxData(string text, Type type, double width = 32, double height = 32, Size? desiredSize = null, Size? desiredMinSize = null, string description = null) : base(text, null, type, width, height, desiredSize, desiredMinSize, description)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
ColorViewModel.FillColor.Color = Colors.Orange;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class EllipseTextToolBoxData : ToolBoxData
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
public EllipseTextToolBoxData(string text, Type type, double width = 32, double height = 32, Size? desiredSize = null, Size? desiredMinSize = null, string description = null) : base(text, null, type, width, height, desiredSize, desiredMinSize, description)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
ColorViewModel.FillColor.Color = Colors.Orange;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ImageToolBoxData : ToolBoxData
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
public ImageToolBoxData(string icon, Type type, double width = 32, double height = 32, Size? desiredSize = null, Size? desiredMinSize = null, string description = null) : base(null, icon, type, width, height, desiredSize, desiredMinSize, description)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class DesignerItemToolBoxData : ToolBoxData
|
|
|
|
|
|
{
|
2023-02-03 22:25:03 +08:00
|
|
|
|
public string FileName
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
public DesignerItemViewModelBase DesignerItemViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
2023-06-11 23:58:22 +08:00
|
|
|
|
public DesignerItemToolBoxData(DesignerItemBase designerItemBase, string filename, Type type, double width = 32, double height = 32, Size? desiredSize = null, Size? desiredMinSize = null, string description = null) : base(null, null, type, width, height, desiredSize, desiredMinSize, description)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
Addition = designerItemBase;
|
2023-01-24 23:10:57 +08:00
|
|
|
|
DesignerItemViewModel = Activator.CreateInstance(type, null, designerItemBase) as DesignerItemViewModelBase;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
FileName = filename;
|
2023-02-03 18:23:53 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class MultipleDesignerItemToolBoxData : ToolBoxData
|
|
|
|
|
|
{
|
|
|
|
|
|
public string FileName
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
2023-02-03 22:25:03 +08:00
|
|
|
|
public List<SelectableDesignerItemViewModelBase> SelectableDesignerItemViewModels
|
2023-02-03 18:23:53 +08:00
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
2023-02-03 22:25:03 +08:00
|
|
|
|
public double CanvasWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
public double CanvasHeight
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
2023-06-11 23:58:22 +08:00
|
|
|
|
public MultipleDesignerItemToolBoxData(SerializableObject designerItemBase, string filename, double width = 32, double height = 32, Size? desiredSize = null, Size? desiredMinSize = null, string description = null) : base(null, null, typeof(List<SelectableDesignerItemViewModelBase>), width, height, desiredSize, desiredMinSize, description)
|
2023-02-03 22:25:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
SelectableDesignerItemViewModels = designerItemBase.ToObject();
|
|
|
|
|
|
|
|
|
|
|
|
var minleft = SelectableDesignerItemViewModels.OfType<DesignerItemViewModelBase>().Min(p => p.Left);
|
|
|
|
|
|
var mintop = SelectableDesignerItemViewModels.OfType<DesignerItemViewModelBase>().Min(p => p.Top);
|
|
|
|
|
|
var maxright = SelectableDesignerItemViewModels.OfType<DesignerItemViewModelBase>().Max(p => p.Left + p.ItemWidth);
|
|
|
|
|
|
var maxbottom = SelectableDesignerItemViewModels.OfType<DesignerItemViewModelBase>().Max(p => p.Top + p.ItemHeight);
|
2023-02-03 18:23:53 +08:00
|
|
|
|
|
2023-02-03 22:25:03 +08:00
|
|
|
|
foreach (var item in SelectableDesignerItemViewModels.OfType<DesignerItemViewModelBase>())
|
2023-02-03 18:23:53 +08:00
|
|
|
|
{
|
|
|
|
|
|
item.Left -= minleft;
|
|
|
|
|
|
item.Top -= mintop;
|
|
|
|
|
|
}
|
2023-02-03 22:25:03 +08:00
|
|
|
|
CanvasWidth = maxright - minleft;
|
|
|
|
|
|
CanvasHeight = maxbottom - mintop;
|
2023-02-03 18:23:53 +08:00
|
|
|
|
|
2023-02-03 22:25:03 +08:00
|
|
|
|
designerItemBase.DesignerItems = SelectableDesignerItemViewModels.OfType<DesignerItemViewModelBase>().Select(p => p.ToSerializableItem(".json")).Where(p => p != null).ToList();
|
|
|
|
|
|
designerItemBase.Connections = SelectableDesignerItemViewModels.OfType<ConnectionViewModel>().Select(p => p.ToSerializableItem(".json")).Where(p => p != null).ToList();
|
2023-02-03 18:23:53 +08:00
|
|
|
|
|
2023-02-03 22:25:03 +08:00
|
|
|
|
Addition = designerItemBase;
|
2023-02-03 18:23:53 +08:00
|
|
|
|
FileName = filename;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class SvgToolBoxData : ToolBoxData
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
public SvgToolBoxData(string filename, Type type, double width = 32, double height = 32, Size? desiredSize = null, Size? desiredMinSize = null, string description = null) : base(null, filename, type, width, height, desiredSize, desiredMinSize, description)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
ColorViewModel.FillColor.Color = Colors.Blue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class MediaToolBoxData : ToolBoxData
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
public MediaToolBoxData(string icon, Type type, double width = 32, double height = 32, Size? desiredSize = null, Size? desiredMinSize = null, string description = null) : base(icon, null, type, width, height, desiredSize, desiredMinSize, description)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-02-03 18:23:53 +08:00
|
|
|
|
|
2023-02-03 22:25:03 +08:00
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|