bug修复

This commit is contained in:
艾竹
2023-08-26 21:30:31 +08:00
parent 045a724ee2
commit d50ec045ea
8 changed files with 130 additions and 33 deletions

View File

@@ -23,6 +23,7 @@ namespace AIStudio.Wpf.DiagramDesigner
this.ChildFlag = viewmodel.ChildFlag;
this.PhysicalItemWidth = viewmodel.PhysicalItemWidth;
this.PhysicalItemHeight = viewmodel.PhysicalItemHeight;
this.Parameter = new ConstParameterItem(viewmodel.Parameter);
Children = new List<BlockDesignerItem>(viewmodel.Children.Select(p => new BlockDesignerItem(p)));
}
@@ -52,10 +53,16 @@ namespace AIStudio.Wpf.DiagramDesigner
get; set;
}
[XmlElement]
public ConstParameterItem Parameter
{
get; set;
}
[XmlArray]
public List<BlockDesignerItem> Children
{
get; set;
}
}
}
}

View File

@@ -0,0 +1,31 @@
using AIStudio.Wpf.DiagramDesigner;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace AIStudio.Wpf.DiagramDesigner
{
[XmlInclude(typeof(ConstParameterItem))]
public class ConstParameterItem
{
[XmlAttribute]
public string Text { get; set; }
[XmlAttribute]
public virtual string Value { get; set; }
public ConstParameterItem()
{
}
public ConstParameterItem(ConstParameter viewmodel)
{
Text = viewmodel.Text;
Value = viewmodel.Value?.ToString();
}
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Media;
using System.Xml;
@@ -17,7 +18,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
public DiagramItem(IDiagramViewModel diagramView)
public DiagramItem(IDiagramViewModel diagramView, string ext = ".json")
{
Name = diagramView.Name;
DiagramType = diagramView.DiagramType;
@@ -30,9 +31,16 @@ namespace AIStudio.Wpf.DiagramDesigner
PageSizeType = diagramView.DiagramOption.LayoutOption.PageSizeType;
PhysicalGridMarginSize = diagramView.DiagramOption.LayoutOption.PhysicalGridMarginSize;
GridColor = diagramView.DiagramOption.LayoutOption.GridColor;
PageBackground = diagramView.DiagramOption.LayoutOption.PageBackground;
AllowDrop = diagramView.DiagramOption.LayoutOption.AllowDrop;
Thumbnail = diagramView.Thumbnail.ToBase64String();
var selectedDesignerItems = diagramView.Items.OfType<DesignerItemViewModelBase>();
var selectedConnections = diagramView.Items.OfType<ConnectionViewModel>();
DesignerItems = selectedDesignerItems.Select(p => p.ToSerializableItem(ext)).Where(p => p != null).ToList();
Connections = selectedConnections.Select(p => p.ToSerializableItem(ext)).Where(p => p != null).ToList();
}
[XmlAttribute]
@@ -157,6 +165,26 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
[XmlIgnore]
public Color PageBackground
{
get; set;
}
[JsonIgnore]
[XmlAttribute("PageBackground")]
public string XmlPageBackground
{
get
{
return SerializeHelper.SerializeColor(PageBackground);
}
set
{
PageBackground = SerializeHelper.DeserializeColor(value);
}
}
[XmlAttribute]
public bool AllowDrop
{

View File

@@ -4,7 +4,15 @@ namespace AIStudio.Wpf.DiagramDesigner
{
public class ConstParameter : BindableBase, IParameter
{
public ConstParameter()
{
}
public ConstParameter(ConstParameterItem item)
{
Text = item.Text;
Value = item.Value.ToString();
}
private string _text;