mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-27 03:33:25 +08:00
保存SFC数据到xml,json完成,
This commit is contained in:
@@ -13,6 +13,10 @@ using AIStudio.Wpf.BaseDiagram.Extensions.Models;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using AIStudio.Wpf.Flowchart.Models;
|
using AIStudio.Wpf.Flowchart.Models;
|
||||||
using AIStudio.Wpf.Flowchart.ViewModels;
|
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||||
|
using AIStudio.Wpf.SFC.Models;
|
||||||
|
using AIStudio.Wpf.SFC.ViewModels;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.ADiagram.Models
|
namespace AIStudio.Wpf.ADiagram.Models
|
||||||
{
|
{
|
||||||
@@ -20,7 +24,7 @@ namespace AIStudio.Wpf.ADiagram.Models
|
|||||||
public class DiagramItem
|
public class DiagramItem
|
||||||
{
|
{
|
||||||
public DiagramItem()
|
public DiagramItem()
|
||||||
{
|
{
|
||||||
this.ConnectionIds = new List<Guid>();
|
this.ConnectionIds = new List<Guid>();
|
||||||
this.Connections = new List<ConnectionItem>();
|
this.Connections = new List<ConnectionItem>();
|
||||||
}
|
}
|
||||||
@@ -31,6 +35,75 @@ namespace AIStudio.Wpf.ADiagram.Models
|
|||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
public DiagramType DiagramType { get; set; }
|
public DiagramType DiagramType { get; set; }
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public bool ShowGrid { get; set; }
|
||||||
|
|
||||||
|
[XmlIgnore]
|
||||||
|
public Size GridCellSize { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[XmlAttribute("GridCellSize")]
|
||||||
|
public string XmlGridCellSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return SerializeHelper.SerializeSize(GridCellSize);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
GridCellSize = SerializeHelper.DeserializeSize(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public CellHorizontalAlignment CellHorizontalAlignment { get; set; }
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public CellVerticalAlignment CellVerticalAlignment { get; set; }
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public PageSizeOrientation PageSizeOrientation { get; set; }
|
||||||
|
|
||||||
|
[XmlIgnore]
|
||||||
|
public Size PageSize { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[XmlAttribute("PageSize")]
|
||||||
|
public string XmlPageSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return SerializeHelper.SerializeSize(PageSize);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
PageSize = SerializeHelper.DeserializeSize(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public PageSizeType PageSizeType { get; set; }
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public double GridMargin { get; set; }
|
||||||
|
|
||||||
|
[XmlIgnore]
|
||||||
|
public Color GridColor { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[XmlAttribute("GridColor")]
|
||||||
|
public string XmlGridColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return SerializeHelper.SerializeColor(GridColor);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
GridColor = SerializeHelper.DeserializeColor(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[XmlArray]
|
[XmlArray]
|
||||||
public List<DesignerItemBase> DesignerItems { get; set; } = new List<DesignerItemBase>();
|
public List<DesignerItemBase> DesignerItems { get; set; } = new List<DesignerItemBase>();
|
||||||
|
|
||||||
@@ -58,21 +131,31 @@ namespace AIStudio.Wpf.ADiagram.Models
|
|||||||
[XmlArray]
|
[XmlArray]
|
||||||
public List<FlowNodeDesignerItem> FlowNodeDesignerItems { get; set; } = new List<FlowNodeDesignerItem>();
|
public List<FlowNodeDesignerItem> FlowNodeDesignerItems { get; set; } = new List<FlowNodeDesignerItem>();
|
||||||
|
|
||||||
|
[XmlArray]
|
||||||
|
public List<SFCNodeDesignerItem> SFCNodeDesignerItems { get; set; } = new List<SFCNodeDesignerItem>();
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public List<DesignerItemBase> AllDesignerItems { get { return
|
public List<DesignerItemBase> AllDesignerItems
|
||||||
DesignerItems.OfType<DesignerItemBase>()
|
{
|
||||||
.Union(TextDesignerItems.OfType<DesignerItemBase>())
|
get
|
||||||
.Union(LogicalGateItems.OfType<DesignerItemBase>())
|
{
|
||||||
.Union(MediaDesignerItems.OfType<DesignerItemBase>())
|
return
|
||||||
.Union(ImageDesignerItems.OfType<DesignerItemBase>())
|
DesignerItems.OfType<DesignerItemBase>()
|
||||||
.Union(PathDesignerItems.OfType<DesignerItemBase>())
|
.Union(TextDesignerItems.OfType<DesignerItemBase>())
|
||||||
.Union(PersistDesignerItems.OfType<DesignerItemBase>())
|
.Union(LogicalGateItems.OfType<DesignerItemBase>())
|
||||||
.Union(SettingsDesignerItems.OfType<DesignerItemBase>())
|
.Union(MediaDesignerItems.OfType<DesignerItemBase>())
|
||||||
.Union(FlowNodeDesignerItems.OfType<FlowNodeDesignerItem>())
|
.Union(ImageDesignerItems.OfType<DesignerItemBase>())
|
||||||
.ToList(); } }
|
.Union(PathDesignerItems.OfType<DesignerItemBase>())
|
||||||
|
.Union(PersistDesignerItems.OfType<DesignerItemBase>())
|
||||||
|
.Union(SettingsDesignerItems.OfType<DesignerItemBase>())
|
||||||
|
.Union(FlowNodeDesignerItems.OfType<DesignerItemBase>())
|
||||||
|
.Union(SFCNodeDesignerItems.OfType<DesignerItemBase>())
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[XmlArray]
|
[XmlArray]
|
||||||
public List<Guid> ConnectionIds { get; set; }
|
public List<Guid> ConnectionIds { get; set; }
|
||||||
|
|
||||||
[XmlArray]
|
[XmlArray]
|
||||||
@@ -113,11 +196,15 @@ namespace AIStudio.Wpf.ADiagram.Models
|
|||||||
else if (item is LogicalGateItemViewModelBase)
|
else if (item is LogicalGateItemViewModelBase)
|
||||||
{
|
{
|
||||||
LogicalGateItems.Add(new LogicalGateDesignerItemBase(item as LogicalGateItemViewModelBase));
|
LogicalGateItems.Add(new LogicalGateDesignerItemBase(item as LogicalGateItemViewModelBase));
|
||||||
}
|
}
|
||||||
else if (item is FlowNode)
|
else if (item is FlowNode)
|
||||||
{
|
{
|
||||||
FlowNodeDesignerItems.Add(new FlowNodeDesignerItem(item as FlowNode));
|
FlowNodeDesignerItems.Add(new FlowNodeDesignerItem(item as FlowNode));
|
||||||
}
|
}
|
||||||
|
else if (item is SFCNode)
|
||||||
|
{
|
||||||
|
SFCNodeDesignerItems.Add(new SFCNodeDesignerItem(item as SFCNode));
|
||||||
|
}
|
||||||
else if (item is BarcodeDesignerItemViewModel)
|
else if (item is BarcodeDesignerItemViewModel)
|
||||||
{
|
{
|
||||||
DesignerItems.Add(new DesignerItemBase(item, (item as BarcodeDesignerItemViewModel).Format.ToString()));
|
DesignerItems.Add(new DesignerItemBase(item, (item as BarcodeDesignerItemViewModel).Format.ToString()));
|
||||||
@@ -133,7 +220,7 @@ namespace AIStudio.Wpf.ADiagram.Models
|
|||||||
{
|
{
|
||||||
if (item is PersistDesignerItemViewModel)
|
if (item is PersistDesignerItemViewModel)
|
||||||
{
|
{
|
||||||
return new PersistDesignerItem(item as PersistDesignerItemViewModel);
|
return new PersistDesignerItem(item as PersistDesignerItemViewModel);
|
||||||
}
|
}
|
||||||
else if (item is SettingsDesignerItemViewModel)
|
else if (item is SettingsDesignerItemViewModel)
|
||||||
{
|
{
|
||||||
@@ -167,6 +254,10 @@ namespace AIStudio.Wpf.ADiagram.Models
|
|||||||
{
|
{
|
||||||
return new FlowNodeDesignerItem(item as FlowNode);
|
return new FlowNodeDesignerItem(item as FlowNode);
|
||||||
}
|
}
|
||||||
|
else if (item is SFCNode)
|
||||||
|
{
|
||||||
|
return new SFCNodeDesignerItem(item as SFCNode);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new DesignerItemBase(item as DesignerItemViewModelBase);
|
return new DesignerItemBase(item as DesignerItemViewModelBase);
|
||||||
@@ -191,6 +282,8 @@ namespace AIStudio.Wpf.ADiagram.Models
|
|||||||
return typeof(LogicalGateDesignerItemBase);
|
return typeof(LogicalGateDesignerItemBase);
|
||||||
if (vmType is FlowNode)
|
if (vmType is FlowNode)
|
||||||
return typeof(FlowNodeDesignerItem);
|
return typeof(FlowNodeDesignerItem);
|
||||||
|
if (vmType is SFCNode)
|
||||||
|
return typeof(SFCNodeDesignerItem);
|
||||||
throw new InvalidOperationException(string.Format("Unknown diagram type. Currently only {0} and {1} are supported",
|
throw new InvalidOperationException(string.Format("Unknown diagram type. Currently only {0} and {1} are supported",
|
||||||
typeof(PersistDesignerItem).AssemblyQualifiedName,
|
typeof(PersistDesignerItem).AssemblyQualifiedName,
|
||||||
typeof(SettingsDesignerItemViewModel).AssemblyQualifiedName
|
typeof(SettingsDesignerItemViewModel).AssemblyQualifiedName
|
||||||
|
|||||||
@@ -41,7 +41,14 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
|||||||
public DiagramsViewModel(string filename)
|
public DiagramsViewModel(string filename)
|
||||||
{
|
{
|
||||||
FileName = filename;
|
FileName = filename;
|
||||||
OpenFile(filename);
|
var diagramDocument = OpenFile(filename);
|
||||||
|
OpenFile(diagramDocument);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DiagramsViewModel(string filename, DiagramDocument diagramDocument)
|
||||||
|
{
|
||||||
|
FileName = filename;
|
||||||
|
OpenFile(diagramDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void InitDiagramViewModel()
|
protected virtual void InitDiagramViewModel()
|
||||||
@@ -189,7 +196,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
|||||||
DiagramViewModel.SelectAllCommand.Execute(null);
|
DiagramViewModel.SelectAllCommand.Execute(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenFile(string filename)
|
public static DiagramDocument OpenFile(string filename)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -210,44 +217,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
|||||||
diagramDocument = JsonConvert.DeserializeObject<DiagramDocument>(File.ReadAllText(filename));
|
diagramDocument = JsonConvert.DeserializeObject<DiagramDocument>(File.ReadAllText(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
Title = diagramDocument.Title;
|
return diagramDocument;
|
||||||
DiagramType = diagramDocument.DiagramType;
|
|
||||||
|
|
||||||
List<DiagramViewModel> viewModels = new List<DiagramViewModel>();
|
|
||||||
foreach (var diagramitem in diagramDocument.DiagramItems)
|
|
||||||
{
|
|
||||||
var viewModel = new DiagramViewModel();
|
|
||||||
viewModel.Name = diagramitem.Name;
|
|
||||||
viewModel.DiagramType = diagramitem.DiagramType;
|
|
||||||
|
|
||||||
foreach (DesignerItemBase diagramItemData in diagramitem.AllDesignerItems)
|
|
||||||
{
|
|
||||||
Type type = TypeHelper.GetType(diagramItemData.ItemTypeName);
|
|
||||||
|
|
||||||
DesignerItemViewModelBase itemBase = (DesignerItemViewModelBase)Activator.CreateInstance(type, viewModel, diagramItemData);
|
|
||||||
viewModel.Items.Add(itemBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var connection in diagramitem.Connections)
|
|
||||||
{
|
|
||||||
connection.SourceType = System.Type.GetType(connection.SourceTypeName);
|
|
||||||
connection.SinkType = System.Type.GetType(connection.SinkTypeName);
|
|
||||||
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(viewModel, connection.SourceId, connection.SourceType);
|
|
||||||
ConnectorOrientation sourceConnectorOrientation = connection.SourceOrientation;
|
|
||||||
FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connection.Id, sourceItem, sourceConnectorOrientation, connection.SourceXRatio, connection.SourceYRatio, connection.SourceInnerPoint);
|
|
||||||
|
|
||||||
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(viewModel, connection.SinkId, connection.SinkType);
|
|
||||||
ConnectorOrientation sinkConnectorOrientation = connection.SinkOrientation;
|
|
||||||
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connection.Id, sinkItem, sinkConnectorOrientation, connection.SinkXRatio, connection.SinkYRatio, connection.SinkInnerPoint);
|
|
||||||
|
|
||||||
ConnectorViewModel connectionVM = new ConnectorViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connection);
|
|
||||||
viewModel.Items.Add(connectionVM);
|
|
||||||
}
|
|
||||||
|
|
||||||
viewModels.Add(viewModel);
|
|
||||||
}
|
|
||||||
DiagramViewModels = new ObservableCollection<IDiagramViewModel>(viewModels);
|
|
||||||
DiagramViewModel = DiagramViewModels.FirstOrDefault();
|
|
||||||
}
|
}
|
||||||
catch (System.IO.FileNotFoundException fnfe)
|
catch (System.IO.FileNotFoundException fnfe)
|
||||||
{
|
{
|
||||||
@@ -276,6 +246,57 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OpenFile(DiagramDocument diagramDocument)
|
||||||
|
{
|
||||||
|
Title = diagramDocument.Title;
|
||||||
|
DiagramType = diagramDocument.DiagramType;
|
||||||
|
|
||||||
|
List<DiagramViewModel> viewModels = new List<DiagramViewModel>();
|
||||||
|
foreach (var diagramItem in diagramDocument.DiagramItems)
|
||||||
|
{
|
||||||
|
var viewModel = new DiagramViewModel();
|
||||||
|
viewModel.Name = diagramItem.Name;
|
||||||
|
viewModel.DiagramType = diagramItem.DiagramType;
|
||||||
|
viewModel.ShowGrid = diagramItem.ShowGrid;
|
||||||
|
viewModel.GridCellSize = diagramItem.GridCellSize;
|
||||||
|
viewModel.CellHorizontalAlignment = diagramItem.CellHorizontalAlignment;
|
||||||
|
viewModel.CellVerticalAlignment = diagramItem.CellVerticalAlignment;
|
||||||
|
viewModel.PageSizeOrientation = diagramItem.PageSizeOrientation;
|
||||||
|
viewModel.PageSize = diagramItem.PageSize;
|
||||||
|
viewModel.PageSizeType = diagramItem.PageSizeType;
|
||||||
|
viewModel.GridMargin = diagramItem.GridMargin;
|
||||||
|
viewModel.GridColor = diagramItem.GridColor;
|
||||||
|
|
||||||
|
foreach (DesignerItemBase diagramItemData in diagramItem.AllDesignerItems)
|
||||||
|
{
|
||||||
|
Type type = TypeHelper.GetType(diagramItemData.ItemTypeName);
|
||||||
|
|
||||||
|
DesignerItemViewModelBase itemBase = (DesignerItemViewModelBase)Activator.CreateInstance(type, viewModel, diagramItemData);
|
||||||
|
viewModel.Items.Add(itemBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var connection in diagramItem.Connections)
|
||||||
|
{
|
||||||
|
connection.SourceType = System.Type.GetType(connection.SourceTypeName);
|
||||||
|
connection.SinkType = System.Type.GetType(connection.SinkTypeName);
|
||||||
|
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(viewModel, connection.SourceId, connection.SourceType);
|
||||||
|
ConnectorOrientation sourceConnectorOrientation = connection.SourceOrientation;
|
||||||
|
FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connection.Id, sourceItem, sourceConnectorOrientation, connection.SourceXRatio, connection.SourceYRatio, connection.SourceInnerPoint);
|
||||||
|
|
||||||
|
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(viewModel, connection.SinkId, connection.SinkType);
|
||||||
|
ConnectorOrientation sinkConnectorOrientation = connection.SinkOrientation;
|
||||||
|
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connection.Id, sinkItem, sinkConnectorOrientation, connection.SinkXRatio, connection.SinkYRatio, connection.SinkInnerPoint);
|
||||||
|
|
||||||
|
ConnectorViewModel connectionVM = new ConnectorViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connection);
|
||||||
|
viewModel.Items.Add(connectionVM);
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModels.Add(viewModel);
|
||||||
|
}
|
||||||
|
DiagramViewModels = new ObservableCollection<IDiagramViewModel>(viewModels);
|
||||||
|
DiagramViewModel = DiagramViewModels.FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
public bool SaveFile(bool isSaveAs = false)
|
public bool SaveFile(bool isSaveAs = false)
|
||||||
{
|
{
|
||||||
string filter = "Files (*.xml)|*.xml|Files (*.json)|*.json|All Files (*.*)|*.*";
|
string filter = "Files (*.xml)|*.xml|Files (*.json)|*.json|All Files (*.*)|*.*";
|
||||||
@@ -307,6 +328,15 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
|||||||
DiagramItem diagramItem = new DiagramItem();
|
DiagramItem diagramItem = new DiagramItem();
|
||||||
diagramItem.Name = viewModel.Name;
|
diagramItem.Name = viewModel.Name;
|
||||||
diagramItem.DiagramType = viewModel.DiagramType;
|
diagramItem.DiagramType = viewModel.DiagramType;
|
||||||
|
diagramItem.ShowGrid = viewModel.ShowGrid;
|
||||||
|
diagramItem.GridCellSize = viewModel.GridCellSize;
|
||||||
|
diagramItem.CellHorizontalAlignment = viewModel.CellHorizontalAlignment;
|
||||||
|
diagramItem.CellVerticalAlignment = viewModel.CellVerticalAlignment;
|
||||||
|
diagramItem.PageSizeOrientation = viewModel.PageSizeOrientation;
|
||||||
|
diagramItem.PageSize = viewModel.PageSize;
|
||||||
|
diagramItem.PageSizeType = viewModel.PageSizeType;
|
||||||
|
diagramItem.GridMargin = viewModel.GridMargin;
|
||||||
|
diagramItem.GridColor = viewModel.GridColor;
|
||||||
|
|
||||||
diagramItem.AddItems(DiagramViewModel.Items);
|
diagramItem.AddItems(DiagramViewModel.Items);
|
||||||
|
|
||||||
@@ -891,6 +921,15 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
|||||||
DiagramItem diagramItem = new DiagramItem();
|
DiagramItem diagramItem = new DiagramItem();
|
||||||
diagramItem.Name = viewModel.Name;
|
diagramItem.Name = viewModel.Name;
|
||||||
diagramItem.DiagramType = viewModel.DiagramType;
|
diagramItem.DiagramType = viewModel.DiagramType;
|
||||||
|
diagramItem.ShowGrid = viewModel.ShowGrid;
|
||||||
|
diagramItem.GridCellSize = viewModel.GridCellSize;
|
||||||
|
diagramItem.CellHorizontalAlignment = viewModel.CellHorizontalAlignment;
|
||||||
|
diagramItem.CellVerticalAlignment = viewModel.CellVerticalAlignment;
|
||||||
|
diagramItem.PageSizeOrientation = viewModel.PageSizeOrientation;
|
||||||
|
diagramItem.PageSize = viewModel.PageSize;
|
||||||
|
diagramItem.PageSizeType = viewModel.PageSizeType;
|
||||||
|
diagramItem.GridMargin = viewModel.GridMargin;
|
||||||
|
diagramItem.GridColor = viewModel.GridColor;
|
||||||
|
|
||||||
diagramItem.AddItems(DiagramViewModel.Items);
|
diagramItem.AddItems(DiagramViewModel.Items);
|
||||||
|
|
||||||
@@ -920,6 +959,15 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
|||||||
viewModel = new DiagramViewModel();
|
viewModel = new DiagramViewModel();
|
||||||
viewModel.Name = NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-");
|
viewModel.Name = NewNameHelper.GetNewName(DiagramViewModels.Select(p => p.Name), "页-");
|
||||||
viewModel.DiagramType = diagramItem.DiagramType;
|
viewModel.DiagramType = diagramItem.DiagramType;
|
||||||
|
viewModel.ShowGrid = diagramItem.ShowGrid;
|
||||||
|
viewModel.GridCellSize = diagramItem.GridCellSize;
|
||||||
|
viewModel.CellHorizontalAlignment = diagramItem.CellHorizontalAlignment;
|
||||||
|
viewModel.CellVerticalAlignment = diagramItem.CellVerticalAlignment;
|
||||||
|
viewModel.PageSizeOrientation = diagramItem.PageSizeOrientation;
|
||||||
|
viewModel.PageSize = diagramItem.PageSize;
|
||||||
|
viewModel.PageSizeType = diagramItem.PageSizeType;
|
||||||
|
viewModel.GridMargin = diagramItem.GridMargin;
|
||||||
|
viewModel.GridColor = diagramItem.GridColor;
|
||||||
|
|
||||||
foreach (DesignerItemBase diagramItemData in diagramItem.AllDesignerItems)
|
foreach (DesignerItemBase diagramItemData in diagramItem.AllDesignerItems)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using AIStudio.Wpf.ADiagram.ViewModels;
|
using AIStudio.Wpf.ADiagram.Models;
|
||||||
|
using AIStudio.Wpf.ADiagram.ViewModels;
|
||||||
using AIStudio.Wpf.Flowchart.ViewModels;
|
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -18,9 +19,12 @@ namespace AIStudio.Wpf.Flowchart
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public FlowchartViewModel(string filename) : base(filename)
|
public FlowchartViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
|
||||||
{
|
{
|
||||||
|
if (DiagramViewModel != null)
|
||||||
|
{
|
||||||
|
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectorViewModel>().ToList(), DiagramViewModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void InitDiagramViewModel()
|
protected override void InitDiagramViewModel()
|
||||||
@@ -101,6 +105,14 @@ namespace AIStudio.Wpf.Flowchart
|
|||||||
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectorViewModel>().ToList(), DiagramViewModel);
|
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectorViewModel>().ToList(), DiagramViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
base.Dispose();
|
||||||
|
|
||||||
|
foreach (var viewModel in DiagramViewModels)
|
||||||
|
{
|
||||||
|
FlowchartService.DisposeData(viewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using AIStudio.Wpf.ADiagram.ViewModels;
|
using AIStudio.Wpf.ADiagram.Models;
|
||||||
|
using AIStudio.Wpf.ADiagram.ViewModels;
|
||||||
using AIStudio.Wpf.Logical.ViewModels;
|
using AIStudio.Wpf.Logical.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -14,7 +15,7 @@ namespace AIStudio.Wpf.Logical
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public LogicalViewModel(string filename) : base(filename)
|
public LogicalViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -786,7 +786,24 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var flow = new DiagramsViewModel(filename);
|
var diagram = DiagramsViewModel.OpenFile(filename);
|
||||||
|
DiagramsViewModel flow;
|
||||||
|
if (diagram.DiagramType == DiagramType.FlowChart)
|
||||||
|
{
|
||||||
|
flow = new FlowchartViewModel(filename, diagram);
|
||||||
|
}
|
||||||
|
else if (diagram.DiagramType == DiagramType.Logical)
|
||||||
|
{
|
||||||
|
flow = new LogicalViewModel(filename, diagram);
|
||||||
|
}
|
||||||
|
else if (diagram.DiagramType == DiagramType.SFC)
|
||||||
|
{
|
||||||
|
flow = new SFCViewModel(filename, diagram);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flow = new DiagramsViewModel(filename, diagram);
|
||||||
|
}
|
||||||
DiagramsViewModels.Add(flow);
|
DiagramsViewModels.Add(flow);
|
||||||
DiagramsViewModel = flow;
|
DiagramsViewModel = flow;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using AIStudio.Wpf.ADiagram.ViewModels;
|
using AIStudio.Wpf.ADiagram.Models;
|
||||||
|
using AIStudio.Wpf.ADiagram.ViewModels;
|
||||||
using AIStudio.Wpf.Flowchart.ViewModels;
|
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||||
using AIStudio.Wpf.SFC;
|
using AIStudio.Wpf.SFC;
|
||||||
using AIStudio.Wpf.SFC.ViewModels;
|
using AIStudio.Wpf.SFC.ViewModels;
|
||||||
@@ -21,9 +22,16 @@ namespace AIStudio.Wpf.Flowchart
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public SFCViewModel(string filename) : base(filename)
|
public SFCViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
|
||||||
{
|
{
|
||||||
|
if (DiagramViewModel != null)
|
||||||
|
{
|
||||||
|
SFCService.InitData(DiagramViewModel.Items.OfType<SFCNode>().ToList(), DiagramViewModel.Items.OfType<ConnectorViewModel>().ToList(), DiagramViewModel);
|
||||||
|
}
|
||||||
|
readDataTimer.Elapsed += timeCycle;
|
||||||
|
readDataTimer.Interval = 1000;
|
||||||
|
readDataTimer.AutoReset = false;
|
||||||
|
readDataTimer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void InitDiagramViewModel()
|
protected override void InitDiagramViewModel()
|
||||||
@@ -285,6 +293,11 @@ namespace AIStudio.Wpf.Flowchart
|
|||||||
|
|
||||||
readDataTimer.Stop();
|
readDataTimer.Stop();
|
||||||
readDataTimer.Dispose();
|
readDataTimer.Dispose();
|
||||||
|
|
||||||
|
foreach (var viewModel in DiagramViewModels)
|
||||||
|
{
|
||||||
|
SFCService.DisposeData(viewModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -363,5 +363,10 @@ namespace AIStudio.Wpf.Flowchart
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void DisposeData(IDiagramViewModel viewModel)
|
||||||
|
{
|
||||||
|
FlowNodes.Remove(viewModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,6 @@
|
|||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Models\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MathParser.org-mXparser" Version="4.4.2" />
|
<PackageReference Include="MathParser.org-mXparser" Version="4.4.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
91
AIStudio.Wpf.SFC/Models/SFCNodeDesignerItem.cs
Normal file
91
AIStudio.Wpf.SFC/Models/SFCNodeDesignerItem.cs
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
using AIStudio.Wpf.SFC.ViewModels;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using Util.DiagramDesigner;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.SFC.Models
|
||||||
|
{
|
||||||
|
public class SFCNodeDesignerItem : DesignerItemBase
|
||||||
|
{
|
||||||
|
public SFCNodeDesignerItem()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public SFCNodeDesignerItem(SFCNode item) : base(item)
|
||||||
|
{
|
||||||
|
this.Connectors = new List<ConnectorItem>();
|
||||||
|
foreach (var fullyCreatedConnectorInfo in item.Connectors)
|
||||||
|
{
|
||||||
|
ConnectorItem connector = new ConnectorItem()
|
||||||
|
{
|
||||||
|
XRatio = fullyCreatedConnectorInfo.XRatio,
|
||||||
|
YRatio = fullyCreatedConnectorInfo.YRatio,
|
||||||
|
ConnectorWidth = fullyCreatedConnectorInfo.ConnectorWidth,
|
||||||
|
ConnectorHeight = fullyCreatedConnectorInfo.ConnectorHeight,
|
||||||
|
Orientation = fullyCreatedConnectorInfo.Orientation,
|
||||||
|
IsInnerPoint = fullyCreatedConnectorInfo.IsInnerPoint,
|
||||||
|
ValueTypePoint = fullyCreatedConnectorInfo.ValueTypePoint,
|
||||||
|
ConnectorValue = fullyCreatedConnectorInfo.ConnectorValue
|
||||||
|
};
|
||||||
|
this.Connectors.Add(connector);
|
||||||
|
}
|
||||||
|
Kind = item.Kind;
|
||||||
|
Expression = item.Expression;
|
||||||
|
|
||||||
|
if (item is SFCActionNode actionNode)
|
||||||
|
{
|
||||||
|
LinkPoints = new List<LinkPoint> { actionNode.LinkPoint };
|
||||||
|
}
|
||||||
|
else if (item is SFCConditionNode sFCConditionNode)
|
||||||
|
{
|
||||||
|
LinkPoints = new List<LinkPoint>(sFCConditionNode.LinkPoint);
|
||||||
|
}
|
||||||
|
else if (item is Simulate_SolenoidViewModel simulate_SolenoidViewModel)
|
||||||
|
{
|
||||||
|
LinkPoints = new List<LinkPoint> { simulate_SolenoidViewModel.DILinkPoint, simulate_SolenoidViewModel.DOLinkPoint };
|
||||||
|
}
|
||||||
|
else if (item is Simulate_StartViewModel simulate_StartViewModel)
|
||||||
|
{
|
||||||
|
LinkPoints = new List<LinkPoint> { simulate_StartViewModel.LinkPoint };
|
||||||
|
}
|
||||||
|
else if (item is Simulate_TankViewModel simulate_TankViewModel)
|
||||||
|
{
|
||||||
|
LinkPoints = new List<LinkPoint> { simulate_TankViewModel.LinkPoint };
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlArray]
|
||||||
|
public List<ConnectorItem> Connectors { get; set; }
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public SFCNodeKinds Kind { get; set; }
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public string Expression { get; set; }
|
||||||
|
|
||||||
|
[XmlIgnore]
|
||||||
|
public List<LinkPoint> LinkPoints { get; set; } = new List<LinkPoint>();
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[XmlElement("LinkPoint")]
|
||||||
|
public string XmlLinkPoints
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return SFCService.SerializeLinkPoint(LinkPoints);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
LinkPoints = SFCService.DeserializeLinkPoint(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,18 +16,18 @@ namespace AIStudio.Wpf.SFC
|
|||||||
{
|
{
|
||||||
LinkPoint = new List<LinkPoint>();
|
LinkPoint = new List<LinkPoint>();
|
||||||
|
|
||||||
LinkPoint.Add(new LinkPoint { Id = Guid.NewGuid(), Name = "S0", Despcription = "启动按钮", Value = 0 });
|
LinkPoint.Add(new LinkPoint { Id = Guid.Parse("9943AC3B-5E19-4AF4-8CB0-26998FC31545"), Name = "S0", Despcription = "启动按钮", Value = 0 });
|
||||||
LinkPoint.Add(new LinkPoint { Id = Guid.NewGuid(), Name = "K1_DI", Despcription = "阀门1输入", Value = 0 });
|
LinkPoint.Add(new LinkPoint { Id = Guid.Parse("F60007E3-913B-43C4-B80B-9624B4BD95AC"), Name = "K1_DI", Despcription = "阀门1输入", Value = 0 });
|
||||||
LinkPoint.Add(new LinkPoint { Id = Guid.NewGuid(), Name = "K2_DI", Despcription = "阀门2输入", Value = 0 });
|
LinkPoint.Add(new LinkPoint { Id = Guid.Parse("8B2CBA04-A9C8-4FF0-BE95-27546292FB90"), Name = "K2_DI", Despcription = "阀门2输入", Value = 0 });
|
||||||
LinkPoint.Add(new LinkPoint { Id = Guid.NewGuid(), Name = "K3_DI", Despcription = "阀门3输入", Value = 0 });
|
LinkPoint.Add(new LinkPoint { Id = Guid.Parse("F213B720-ADC2-41C9-82B7-D77B56B99CB7"), Name = "K3_DI", Despcription = "阀门3输入", Value = 0 });
|
||||||
LinkPoint.Add(new LinkPoint { Id = Guid.NewGuid(), Name = "K4_DI", Despcription = "阀门4输入", Value = 0 });
|
LinkPoint.Add(new LinkPoint { Id = Guid.Parse("48BB7F62-A476-4A68-9DB4-5BD4201C1C26"), Name = "K4_DI", Despcription = "阀门4输入", Value = 0 });
|
||||||
LinkPoint.Add(new LinkPoint { Id = Guid.NewGuid(), Name = "K1_DO", Despcription = "阀门1反馈", Value = 0 });
|
LinkPoint.Add(new LinkPoint { Id = Guid.Parse("5E52ACA8-8DB4-4D39-A3BF-73EE3A551253"), Name = "K1_DO", Despcription = "阀门1反馈", Value = 0 });
|
||||||
LinkPoint.Add(new LinkPoint { Id = Guid.NewGuid(), Name = "K2_DO", Despcription = "阀门2反馈", Value = 0 });
|
LinkPoint.Add(new LinkPoint { Id = Guid.Parse("5B8C53FF-A4CA-40BA-9F36-5C228D9D0C5A"), Name = "K2_DO", Despcription = "阀门2反馈", Value = 0 });
|
||||||
LinkPoint.Add(new LinkPoint { Id = Guid.NewGuid(), Name = "K3_DO", Despcription = "阀门3反馈", Value = 0 });
|
LinkPoint.Add(new LinkPoint { Id = Guid.Parse("29496600-74CF-4AB0-88D1-4C5BFAD4C405"), Name = "K3_DO", Despcription = "阀门3反馈", Value = 0 });
|
||||||
LinkPoint.Add(new LinkPoint { Id = Guid.NewGuid(), Name = "K4_DO", Despcription = "阀门4反馈", Value = 0 });
|
LinkPoint.Add(new LinkPoint { Id = Guid.Parse("15733895-96E5-4F90-9BC2-3C7FF0A2B048"), Name = "K4_DO", Despcription = "阀门4反馈", Value = 0 });
|
||||||
LinkPoint.Add(new LinkPoint { Id = Guid.NewGuid(), Name = "T1", Despcription = "容器1液位", Value = 100, });
|
LinkPoint.Add(new LinkPoint { Id = Guid.Parse("BD593101-C759-4077-A3F2-F86AA2FC6DF8"), Name = "T1", Despcription = "容器1液位", Value = 100, });
|
||||||
LinkPoint.Add(new LinkPoint { Id = Guid.NewGuid(), Name = "T2", Despcription = "容器2液位", Value = 0 });
|
LinkPoint.Add(new LinkPoint { Id = Guid.Parse("2BCBD2C9-9BCE-4F10-B115-088DEE1F4E08"), Name = "T2", Despcription = "容器2液位", Value = 0 });
|
||||||
LinkPoint.Add(new LinkPoint { Id = Guid.NewGuid(), Name = "T3", Despcription = "容器3液位", Value = 20 });
|
LinkPoint.Add(new LinkPoint { Id = Guid.Parse("DBD10A3C-7E2E-4DAE-9CB0-A2132DC469DF"), Name = "T3", Despcription = "容器3液位", Value = 20 });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -165,7 +165,7 @@ namespace AIStudio.Wpf.SFC
|
|||||||
SetStatus(next, 1);
|
SetStatus(next, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,5 +192,27 @@ namespace AIStudio.Wpf.SFC
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static string SerializeLinkPoint(List<LinkPoint> points)
|
||||||
|
{
|
||||||
|
return string.Join(",", points.Select(p => p.Id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<LinkPoint> DeserializeLinkPoint(string point)
|
||||||
|
{
|
||||||
|
List<LinkPoint> links = new List<LinkPoint>();
|
||||||
|
string[] pieces = point.Split(new char[] { ',' });
|
||||||
|
foreach (var piece in pieces)
|
||||||
|
{
|
||||||
|
links.Add(LinkPoint.FirstOrDefault(p => p.Id.ToString() == piece));
|
||||||
|
}
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DisposeData(IDiagramViewModel viewModel)
|
||||||
|
{
|
||||||
|
SFCNodes.Remove(viewModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,19 +21,6 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _expression;
|
|
||||||
public string Expression
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _expression;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
SetProperty(ref _expression, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private LinkPoint _linkPoint;
|
private LinkPoint _linkPoint;
|
||||||
public LinkPoint LinkPoint
|
public LinkPoint LinkPoint
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,32 +42,6 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _expression;
|
|
||||||
public string Expression
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _expression;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
SetProperty(ref _expression, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string _para;
|
|
||||||
public string Para
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _para;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_para = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ObservableCollection<LinkPoint> _linkPoint = new ObservableCollection<LinkPoint>();
|
private ObservableCollection<LinkPoint> _linkPoint = new ObservableCollection<LinkPoint>();
|
||||||
public ObservableCollection<LinkPoint> LinkPoint
|
public ObservableCollection<LinkPoint> LinkPoint
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using AIStudio.Wpf.BaseDiagram;
|
using AIStudio.Wpf.BaseDiagram;
|
||||||
using AIStudio.Wpf.BaseDiagram.Services;
|
using AIStudio.Wpf.BaseDiagram.Services;
|
||||||
|
using AIStudio.Wpf.SFC.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Util.DiagramDesigner;
|
using Util.DiagramDesigner;
|
||||||
@@ -18,7 +20,7 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
ColorViewModel.FillColor.Color = Colors.Blue;
|
ColorViewModel.FillColor.Color = Colors.Blue;
|
||||||
Kind = kind;
|
Kind = kind;
|
||||||
ItemWidth = 80;
|
ItemWidth = 80;
|
||||||
ItemHeight = 40;
|
ItemHeight = 40;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SFCNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
public SFCNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||||
@@ -37,12 +39,60 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
base.Init();
|
base.Init();
|
||||||
|
|
||||||
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
|
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel parent, SelectableDesignerItemBase designerbase)
|
protected override void LoadDesignerItemViewModel(IDiagramViewModel parent, SelectableDesignerItemBase designerbase)
|
||||||
{
|
{
|
||||||
base.LoadDesignerItemViewModel(parent, designerbase);
|
base.LoadDesignerItemViewModel(parent, designerbase);
|
||||||
|
|
||||||
|
SFCNodeDesignerItem designer = designerbase as SFCNodeDesignerItem;
|
||||||
|
this.Kind = designer.Kind;
|
||||||
|
this.Expression = designer.Expression;
|
||||||
|
|
||||||
|
foreach (var connector in designer.Connectors)
|
||||||
|
{
|
||||||
|
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this, connector.Orientation, true);
|
||||||
|
fullyCreatedConnectorInfo.XRatio = connector.XRatio;
|
||||||
|
fullyCreatedConnectorInfo.YRatio = connector.YRatio;
|
||||||
|
fullyCreatedConnectorInfo.ConnectorWidth = connector.ConnectorWidth;
|
||||||
|
fullyCreatedConnectorInfo.ConnectorHeight = connector.ConnectorHeight;
|
||||||
|
fullyCreatedConnectorInfo.Orientation = connector.Orientation;
|
||||||
|
fullyCreatedConnectorInfo.IsInnerPoint = connector.IsInnerPoint;
|
||||||
|
fullyCreatedConnectorInfo.ValueTypePoint = connector.ValueTypePoint;
|
||||||
|
fullyCreatedConnectorInfo.ConnectorValue = connector.ConnectorValue;
|
||||||
|
|
||||||
|
if (fullyCreatedConnectorInfo.Orientation == ConnectorOrientation.Left)
|
||||||
|
{
|
||||||
|
Input.Add(Input.Count, fullyCreatedConnectorInfo);
|
||||||
|
}
|
||||||
|
else if (fullyCreatedConnectorInfo.Orientation == ConnectorOrientation.Right)
|
||||||
|
{
|
||||||
|
Output.Add(Output.Count, fullyCreatedConnectorInfo);
|
||||||
|
}
|
||||||
|
AddConnector(fullyCreatedConnectorInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this is SFCActionNode actionNode)
|
||||||
|
{
|
||||||
|
actionNode.LinkPoint = designer.LinkPoints.FirstOrDefault();
|
||||||
|
}
|
||||||
|
else if (this is SFCConditionNode sFCConditionNode)
|
||||||
|
{
|
||||||
|
sFCConditionNode.LinkPoint = new System.Collections.ObjectModel.ObservableCollection<LinkPoint>(designer.LinkPoints);
|
||||||
|
}
|
||||||
|
else if (this is Simulate_SolenoidViewModel simulate_SolenoidViewModel)
|
||||||
|
{
|
||||||
|
simulate_SolenoidViewModel.DILinkPoint = designer.LinkPoints.FirstOrDefault();
|
||||||
|
simulate_SolenoidViewModel.DOLinkPoint = designer.LinkPoints.LastOrDefault();
|
||||||
|
}
|
||||||
|
else if (this is Simulate_StartViewModel simulate_StartViewModel)
|
||||||
|
{
|
||||||
|
simulate_StartViewModel.LinkPoint = designer.LinkPoints.FirstOrDefault();
|
||||||
|
}
|
||||||
|
else if (this is Simulate_TankViewModel simulate_TankViewModel)
|
||||||
|
{
|
||||||
|
simulate_TankViewModel.LinkPoint = designer.LinkPoints.FirstOrDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void InitConnector()
|
protected override void InitConnector()
|
||||||
@@ -136,6 +186,20 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string _expression;
|
||||||
|
public string Expression
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _expression;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _expression, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 暂不保存
|
||||||
private int _status;
|
private int _status;
|
||||||
|
|
||||||
public int Status
|
public int Status
|
||||||
@@ -149,5 +213,6 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
|
|
||||||
public List<SFCNode> NextNode { get; set; } = new List<SFCNode>();
|
public List<SFCNode> NextNode { get; set; } = new List<SFCNode>();
|
||||||
public List<SFCNode> PreNode { get; set; } = new List<SFCNode>();
|
public List<SFCNode> PreNode { get; set; } = new List<SFCNode>();
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -348,6 +348,17 @@ namespace Util.DiagramDesigner
|
|||||||
string[] pieces = point.Split(new char[] { ',' });
|
string[] pieces = point.Split(new char[] { ',' });
|
||||||
return new Point(double.Parse(pieces[0]), double.Parse(pieces[1]));
|
return new Point(double.Parse(pieces[0]), double.Parse(pieces[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string SerializeSize(Size size)
|
||||||
|
{
|
||||||
|
return string.Format("{0},{1}", size.Width, size.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Size DeserializeSize(string size)
|
||||||
|
{
|
||||||
|
string[] pieces = size.Split(new char[] { ',' });
|
||||||
|
return new Size(double.Parse(pieces[0]), double.Parse(pieces[1]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,20 +44,20 @@ namespace Util.DiagramDesigner
|
|||||||
bool BelongToSameGroup(IGroupable item1, IGroupable item2);
|
bool BelongToSameGroup(IGroupable item1, IGroupable item2);
|
||||||
Rect GetBoundingRectangle(IEnumerable<DesignerItemViewModelBase> items);
|
Rect GetBoundingRectangle(IEnumerable<DesignerItemViewModelBase> items);
|
||||||
void UpdateZIndex();
|
void UpdateZIndex();
|
||||||
Size PageSize { get;}
|
|
||||||
|
Size PageSize { get; set; }
|
||||||
PageSizeType PageSizeType { get; set; }
|
PageSizeType PageSizeType { get; set; }
|
||||||
bool ShowGrid { get; set; }
|
bool ShowGrid { get; set; }
|
||||||
Size GridCellSize { get; set; }
|
Size GridCellSize { get; set; }
|
||||||
PageSizeOrientation PageSizeOrientation { get; set; }
|
PageSizeOrientation PageSizeOrientation { get; set; }
|
||||||
double GridMargin { get; set; }
|
|
||||||
Color GridColor { get; set; }
|
|
||||||
Point CurrentPoint { get; set; }
|
|
||||||
Color CurrentColor { get; set; }
|
|
||||||
|
|
||||||
DiagramType DiagramType { get; set; }
|
|
||||||
|
|
||||||
CellHorizontalAlignment CellHorizontalAlignment { get; set; }
|
CellHorizontalAlignment CellHorizontalAlignment { get; set; }
|
||||||
CellVerticalAlignment CellVerticalAlignment { get; set; }
|
CellVerticalAlignment CellVerticalAlignment { get; set; }
|
||||||
|
double GridMargin { get; set; }
|
||||||
|
Color GridColor { get; set; }
|
||||||
|
DiagramType DiagramType { get; set; }
|
||||||
|
|
||||||
|
Point CurrentPoint { get; set; }
|
||||||
|
Color CurrentColor { get; set; }
|
||||||
|
|
||||||
event PropertyChangedEventHandler PropertyChanged;
|
event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user