mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-05-02 14:01:29 +08:00
调整了一下各种命令的位置,便于其他应用调用
This commit is contained in:
@@ -163,132 +163,50 @@ DesignerItems.OfType<DesignerItemBase>()
|
|||||||
|
|
||||||
public void AddItems(IEnumerable<SelectableDesignerItemViewModelBase> selectedDesignerItems)
|
public void AddItems(IEnumerable<SelectableDesignerItemViewModelBase> selectedDesignerItems)
|
||||||
{
|
{
|
||||||
foreach (var item in selectedDesignerItems.OfType<DesignerItemViewModelBase>())
|
var items = selectedDesignerItems.OfType<DesignerItemViewModelBase>().Select(p => p.ToXmlObject());
|
||||||
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
if (item is PersistDesignerItemViewModel)
|
if (item is PersistDesignerItem persistDesignerItem)
|
||||||
{
|
{
|
||||||
PersistDesignerItems.Add(new PersistDesignerItem(item as PersistDesignerItemViewModel));
|
PersistDesignerItems.Add(persistDesignerItem);
|
||||||
}
|
}
|
||||||
else if (item is SettingsDesignerItemViewModel)
|
else if (item is SettingsDesignerItem settingsDesignerItem)
|
||||||
{
|
{
|
||||||
SettingsDesignerItems.Add(new SettingsDesignerItem(item as SettingsDesignerItemViewModel));
|
SettingsDesignerItems.Add(settingsDesignerItem);
|
||||||
}
|
}
|
||||||
else if (item is PathItemViewModel)
|
else if (item is PathDesignerItem pathDesignerItem)
|
||||||
{
|
{
|
||||||
PathDesignerItems.Add(new PathDesignerItem(item));
|
PathDesignerItems.Add(pathDesignerItem);
|
||||||
}
|
}
|
||||||
else if (item is GifImageItemViewModel)
|
else if (item is MediaDesignerItem mediaDesignerItem)
|
||||||
{
|
{
|
||||||
MediaDesignerItems.Add(new MediaDesignerItem(item as GifImageItemViewModel));
|
MediaDesignerItems.Add(mediaDesignerItem);
|
||||||
}
|
}
|
||||||
else if (item is MediaItemViewModel)
|
else if (item is ImageDesignerItem imageDesignerItem)
|
||||||
{
|
{
|
||||||
MediaDesignerItems.Add(new MediaDesignerItem(item as MediaItemViewModel));
|
ImageDesignerItems.Add(imageDesignerItem);
|
||||||
}
|
}
|
||||||
else if (item is ImageItemViewModel)
|
else if (item is TextDesignerItem textDesignerItem)
|
||||||
{
|
{
|
||||||
ImageDesignerItems.Add(new ImageDesignerItem(item as ImageItemViewModel));
|
TextDesignerItems.Add(textDesignerItem);
|
||||||
}
|
}
|
||||||
else if (item is TextDesignerItemViewModel)
|
else if (item is LogicalGateDesignerItemBase logicalGateDesignerItemBase)
|
||||||
{
|
{
|
||||||
TextDesignerItems.Add(new TextDesignerItem(item as TextDesignerItemViewModel));
|
LogicalGateItems.Add(logicalGateDesignerItemBase);
|
||||||
}
|
}
|
||||||
else if (item is LogicalGateItemViewModelBase)
|
else if (item is FlowNodeDesignerItem flowNodeDesignerItem)
|
||||||
{
|
{
|
||||||
LogicalGateItems.Add(new LogicalGateDesignerItemBase(item as LogicalGateItemViewModelBase));
|
FlowNodeDesignerItems.Add(flowNodeDesignerItem);
|
||||||
}
|
}
|
||||||
else if (item is FlowNode)
|
else if (item is SFCNodeDesignerItem sFCNodeDesignerItem)
|
||||||
{
|
{
|
||||||
FlowNodeDesignerItems.Add(new FlowNodeDesignerItem(item as FlowNode));
|
SFCNodeDesignerItems.Add(sFCNodeDesignerItem);
|
||||||
}
|
}
|
||||||
else if (item is SFCNode)
|
else if (item is DesignerItemBase designerItemBase)
|
||||||
{
|
{
|
||||||
SFCNodeDesignerItems.Add(new SFCNodeDesignerItem(item as SFCNode));
|
DesignerItems.Add(designerItemBase);
|
||||||
}
|
|
||||||
else if (item is BarcodeDesignerItemViewModel)
|
|
||||||
{
|
|
||||||
DesignerItems.Add(new DesignerItemBase(item, (item as BarcodeDesignerItemViewModel).Format.ToString()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DesignerItems.Add(new DesignerItemBase(item));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DesignerItemBase ToXmlObject(SelectableDesignerItemViewModelBase item)
|
|
||||||
{
|
|
||||||
if (item is PersistDesignerItemViewModel)
|
|
||||||
{
|
|
||||||
return new PersistDesignerItem(item as PersistDesignerItemViewModel);
|
|
||||||
}
|
|
||||||
else if (item is SettingsDesignerItemViewModel)
|
|
||||||
{
|
|
||||||
return new SettingsDesignerItem(item as SettingsDesignerItemViewModel);
|
|
||||||
}
|
|
||||||
else if (item is PathItemViewModel)
|
|
||||||
{
|
|
||||||
return new PathDesignerItem(item as PathItemViewModel);
|
|
||||||
}
|
|
||||||
else if (item is GifImageItemViewModel)
|
|
||||||
{
|
|
||||||
return new MediaDesignerItem(item as GifImageItemViewModel);
|
|
||||||
}
|
|
||||||
else if (item is MediaItemViewModel)
|
|
||||||
{
|
|
||||||
return new MediaDesignerItem(item as MediaItemViewModel);
|
|
||||||
}
|
|
||||||
else if (item is ImageItemViewModel)
|
|
||||||
{
|
|
||||||
return new ImageDesignerItem(item as ImageItemViewModel);
|
|
||||||
}
|
|
||||||
else if (item is TextDesignerItemViewModel)
|
|
||||||
{
|
|
||||||
return new TextDesignerItem(item as TextDesignerItemViewModel);
|
|
||||||
}
|
|
||||||
else if (item is LogicalGateItemViewModelBase)
|
|
||||||
{
|
|
||||||
return new LogicalGateDesignerItemBase(item as LogicalGateItemViewModelBase);
|
|
||||||
}
|
|
||||||
else if (item is FlowNode)
|
|
||||||
{
|
|
||||||
return new FlowNodeDesignerItem(item as FlowNode);
|
|
||||||
}
|
|
||||||
else if (item is SFCNode)
|
|
||||||
{
|
|
||||||
return new SFCNodeDesignerItem(item as SFCNode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new DesignerItemBase(item as DesignerItemViewModelBase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type GetTypeOfDiagramItem(DesignerItemViewModelBase vmType)
|
|
||||||
{
|
|
||||||
if (vmType is PersistDesignerItemViewModel)
|
|
||||||
return typeof(PersistDesignerItem);
|
|
||||||
if (vmType is SettingsDesignerItemViewModel)
|
|
||||||
return typeof(SettingsDesignerItem);
|
|
||||||
if (vmType is PathItemViewModel)
|
|
||||||
return typeof(PathToolBoxData);
|
|
||||||
if (vmType is GifImageItemViewModel)
|
|
||||||
return typeof(MediaDesignerItem);
|
|
||||||
if (vmType is MediaItemViewModel)
|
|
||||||
return typeof(MediaDesignerItem);
|
|
||||||
if (vmType is ImageItemViewModel)
|
|
||||||
return typeof(ImageDesignerItem);
|
|
||||||
if (vmType is LogicalGateItemViewModelBase)
|
|
||||||
return typeof(LogicalGateDesignerItemBase);
|
|
||||||
if (vmType is FlowNode)
|
|
||||||
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",
|
|
||||||
typeof(PersistDesignerItem).AssemblyQualifiedName,
|
|
||||||
typeof(SettingsDesignerItemViewModel).AssemblyQualifiedName
|
|
||||||
));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ using System.Windows.Media;
|
|||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using AIStudio.Wpf.DiagramDesigner;
|
using AIStudio.Wpf.DiagramDesigner;
|
||||||
using ZXing;
|
using ZXing;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramApp.ViewModels
|
namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||||
{
|
{
|
||||||
@@ -181,21 +182,6 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReDoExecuted()
|
|
||||||
{
|
|
||||||
DiagramViewModel.RedoCommand.Execute(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UnDoExecuted()
|
|
||||||
{
|
|
||||||
DiagramViewModel.UndoCommand.Execute(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SelectedAllExecuted()
|
|
||||||
{
|
|
||||||
DiagramViewModel.SelectAllCommand.Execute(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DiagramDocument OpenFile(string filename)
|
public static DiagramDocument OpenFile(string filename)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -289,7 +275,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
|
|
||||||
|
|
||||||
ConnectorViewModel connectionVM = new ConnectorViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connection, connection.VectorLineDrawMode);
|
ConnectorViewModel connectionVM = new ConnectorViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connection, connection.VectorLineDrawMode);
|
||||||
DesignerItemViewModelBase textItem = viewModel.Items.OfType<DesignerItemViewModelBase>().Single(x => x.ParentId == connection.Id);
|
DesignerItemViewModelBase textItem = viewModel.Items.OfType<DesignerItemViewModelBase>().FirstOrDefault(x => x.ParentId == connection.Id);
|
||||||
if (textItem != null)
|
if (textItem != null)
|
||||||
{
|
{
|
||||||
connectionVM.OutTextItem = textItem;
|
connectionVM.OutTextItem = textItem;
|
||||||
@@ -354,15 +340,15 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
ConnectionItem connection = new ConnectionItem(
|
ConnectionItem connection = new ConnectionItem(
|
||||||
connectionVM.SourceConnectorInfo.DataItem.Id,
|
connectionVM.SourceConnectorInfo.DataItem.Id,
|
||||||
connectionVM.SourceConnectorInfo.Orientation,
|
connectionVM.SourceConnectorInfo.Orientation,
|
||||||
DiagramItem.GetTypeOfDiagramItem(connectionVM.SourceConnectorInfo.DataItem),
|
connectionVM.SourceConnectorInfo.DataItem.GetType(),
|
||||||
GetXRatioFromConnector(connectionVM.SourceConnectorInfo),
|
connectionVM.GetXRatioFromConnector(connectionVM.SourceConnectorInfo),
|
||||||
GetYRatioFromConnector(connectionVM.SourceConnectorInfo),
|
connectionVM.GetYRatioFromConnector(connectionVM.SourceConnectorInfo),
|
||||||
connectionVM.SourceConnectorInfo.IsInnerPoint,
|
connectionVM.SourceConnectorInfo.IsInnerPoint,
|
||||||
sinkConnector.DataItem.Id,
|
sinkConnector.DataItem.Id,
|
||||||
sinkConnector.Orientation,
|
sinkConnector.Orientation,
|
||||||
DiagramItem.GetTypeOfDiagramItem(sinkConnector.DataItem),
|
sinkConnector.DataItem.GetType(),
|
||||||
GetXRatioFromConnector(sinkConnector),
|
connectionVM.GetXRatioFromConnector(sinkConnector),
|
||||||
GetYRatioFromConnector(sinkConnector),
|
connectionVM.GetYRatioFromConnector(sinkConnector),
|
||||||
sinkConnector.IsInnerPoint,
|
sinkConnector.IsInnerPoint,
|
||||||
connectionVM);
|
connectionVM);
|
||||||
|
|
||||||
@@ -385,225 +371,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
Status = "";
|
Status = "";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Paste()
|
|
||||||
{
|
|
||||||
if (Clipboard.ContainsData(DataFormats.Xaml))
|
|
||||||
{
|
|
||||||
String clipboardData = Clipboard.GetData(DataFormats.Xaml) as String;
|
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(clipboardData))
|
|
||||||
return;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
List<SelectableDesignerItemViewModelBase> items = new List<SelectableDesignerItemViewModelBase>();
|
|
||||||
DiagramItem copyitem = XmlSerializeHelper.DESerializer<DiagramItem>(clipboardData);
|
|
||||||
|
|
||||||
|
|
||||||
Dictionary<Guid, Guid> mappingOldToNewIDs = new Dictionary<Guid, Guid>();
|
|
||||||
|
|
||||||
foreach (var diagramItemData in copyitem.AllDesignerItems)
|
|
||||||
{
|
|
||||||
DesignerItemViewModelBase newItem = null;
|
|
||||||
|
|
||||||
Guid newID = Guid.NewGuid();
|
|
||||||
mappingOldToNewIDs.Add(diagramItemData.Id, newID);
|
|
||||||
|
|
||||||
diagramItemData.Id = newID;
|
|
||||||
diagramItemData.Left += OffsetX;
|
|
||||||
|
|
||||||
diagramItemData.Top += OffsetY;
|
|
||||||
Type type = TypeHelper.GetType(diagramItemData.ItemTypeName);
|
|
||||||
|
|
||||||
DesignerItemViewModelBase itemBase = (DesignerItemViewModelBase)Activator.CreateInstance(type, DiagramViewModel, diagramItemData);
|
|
||||||
newItem = itemBase;
|
|
||||||
|
|
||||||
if (newItem != null)
|
|
||||||
{
|
|
||||||
if (newItem.ParentId != Guid.Empty)
|
|
||||||
{
|
|
||||||
newItem.ParentId = mappingOldToNewIDs[newItem.ParentId];
|
|
||||||
}
|
|
||||||
items.Add(newItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
OffsetX += 10;
|
|
||||||
OffsetY += 10;
|
|
||||||
|
|
||||||
foreach (var connection in copyitem.Connections)
|
|
||||||
{
|
|
||||||
Guid newID = Guid.NewGuid();
|
|
||||||
|
|
||||||
connection.SourceId = mappingOldToNewIDs[connection.SourceId];
|
|
||||||
connection.SinkId = mappingOldToNewIDs[connection.SinkId];
|
|
||||||
|
|
||||||
connection.SourceType = System.Type.GetType(connection.SourceTypeName);
|
|
||||||
connection.SinkType = System.Type.GetType(connection.SinkTypeName);
|
|
||||||
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(DiagramViewModel, connection.SourceId, connection.SourceType);
|
|
||||||
ConnectorOrientation sourceConnectorOrientation = connection.SourceOrientation;
|
|
||||||
FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connection.Id, sourceItem, sourceConnectorOrientation, connection.SourceXRatio, connection.SourceYRatio, connection.SourceInnerPoint);
|
|
||||||
|
|
||||||
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(DiagramViewModel, 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(DiagramViewModel, sourceConnectorInfo, sinkConnectorInfo, connection, connection.VectorLineDrawMode);
|
|
||||||
items.Add(connectionVM);
|
|
||||||
}
|
|
||||||
|
|
||||||
DiagramViewModel.DirectAddItemCommand.Execute(items);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
MessageBox.Show(e.StackTrace, e.Message, MessageBoxButton.OK, MessageBoxImage.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CopyCurrentSelection()
|
|
||||||
{
|
|
||||||
IEnumerable<SelectableDesignerItemViewModelBase> selectedDesignerItems =
|
|
||||||
DiagramViewModel.SelectedItems.OfType<SelectableDesignerItemViewModelBase>();
|
|
||||||
|
|
||||||
List<ConnectorViewModel> selectedConnections =
|
|
||||||
DiagramViewModel.SelectedItems.OfType<ConnectorViewModel>().ToList();
|
|
||||||
|
|
||||||
foreach (ConnectorViewModel connection in DiagramViewModel.Items.OfType<ConnectorViewModel>())
|
|
||||||
{
|
|
||||||
if (!selectedConnections.Contains(connection))
|
|
||||||
{
|
|
||||||
DesignerItemViewModelBase sourceItem = (from item in selectedDesignerItems.OfType<DesignerItemViewModelBase>()
|
|
||||||
where item.Id == connection.SourceConnectorInfo.DataItem.Id
|
|
||||||
select item).FirstOrDefault();
|
|
||||||
|
|
||||||
DesignerItemViewModelBase sinkItem = (from item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>()
|
|
||||||
where item.Id == ((connection.SinkConnectorInfo as FullyCreatedConnectorInfo).DataItem).Id
|
|
||||||
select item).FirstOrDefault();
|
|
||||||
|
|
||||||
if (sourceItem != null &&
|
|
||||||
sinkItem != null &&
|
|
||||||
DiagramViewModel.BelongToSameGroup(sourceItem, sinkItem))
|
|
||||||
{
|
|
||||||
selectedConnections.Add(connection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DiagramItem copyitem = new DiagramItem();
|
|
||||||
copyitem.AddItems(selectedDesignerItems);
|
|
||||||
|
|
||||||
foreach (var connectionVM in selectedConnections.OfType<ConnectorViewModel>())
|
|
||||||
{
|
|
||||||
FullyCreatedConnectorInfo sinkConnector = connectionVM.SinkConnectorInfo as FullyCreatedConnectorInfo;
|
|
||||||
|
|
||||||
ConnectionItem connection = new ConnectionItem(
|
|
||||||
connectionVM.SourceConnectorInfo.DataItem.Id,
|
|
||||||
connectionVM.SourceConnectorInfo.Orientation,
|
|
||||||
DiagramItem.GetTypeOfDiagramItem(connectionVM.SourceConnectorInfo.DataItem),
|
|
||||||
GetXRatioFromConnector(connectionVM.SourceConnectorInfo),
|
|
||||||
GetYRatioFromConnector(connectionVM.SourceConnectorInfo),
|
|
||||||
connectionVM.SourceConnectorInfo.IsInnerPoint,
|
|
||||||
sinkConnector.DataItem.Id,
|
|
||||||
sinkConnector.Orientation,
|
|
||||||
DiagramItem.GetTypeOfDiagramItem(sinkConnector.DataItem),
|
|
||||||
GetXRatioFromConnector(sinkConnector),
|
|
||||||
GetYRatioFromConnector(sinkConnector),
|
|
||||||
sinkConnector.IsInnerPoint,
|
|
||||||
connectionVM);
|
|
||||||
|
|
||||||
copyitem.ConnectionIds.Add(connectionVM.Id);
|
|
||||||
copyitem.Connections.Add(connection);
|
|
||||||
}
|
|
||||||
string xml = XmlSerializeHelper.XmlSerialize<DiagramItem>(copyitem);
|
|
||||||
|
|
||||||
OffsetX = 10;
|
|
||||||
OffsetY = 10;
|
|
||||||
Clipboard.Clear();
|
|
||||||
Clipboard.SetData(DataFormats.Xaml, xml);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteCurrentSelection()
|
|
||||||
{
|
|
||||||
List<SelectableDesignerItemViewModelBase> itemsToRemove = DiagramViewModel.SelectedItems.OfType<SelectableDesignerItemViewModelBase>().ToList();
|
|
||||||
List<SelectableDesignerItemViewModelBase> connectionsToAlsoRemove = new List<SelectableDesignerItemViewModelBase>();
|
|
||||||
|
|
||||||
foreach (var connector in DiagramViewModel.Items.OfType<ConnectorViewModel>())
|
|
||||||
{
|
|
||||||
if (ItemsToDeleteHasConnector(itemsToRemove, connector.SourceConnectorInfo))
|
|
||||||
{
|
|
||||||
connectionsToAlsoRemove.Add(connector);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ItemsToDeleteHasConnector(itemsToRemove, connector.SinkConnectorInfo))
|
|
||||||
{
|
|
||||||
connectionsToAlsoRemove.Add(connector);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
itemsToRemove.AddRange(connectionsToAlsoRemove);
|
|
||||||
|
|
||||||
DiagramViewModel.RemoveItemCommand.Execute(itemsToRemove);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CutCurrentSelection()
|
|
||||||
{
|
|
||||||
CopyCurrentSelection();
|
|
||||||
OffsetX = 0;
|
|
||||||
OffsetY = 0;
|
|
||||||
DeleteCurrentSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
private double GetXRatioFromConnector(FullyCreatedConnectorInfo info)
|
|
||||||
{
|
|
||||||
if (info.IsInnerPoint)
|
|
||||||
{
|
|
||||||
return info.XRatio;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (info.Orientation)
|
|
||||||
{
|
|
||||||
case ConnectorOrientation.Top:
|
|
||||||
return 0.5;
|
|
||||||
case ConnectorOrientation.Left:
|
|
||||||
return 0;
|
|
||||||
case ConnectorOrientation.Bottom:
|
|
||||||
return 0.5;
|
|
||||||
case ConnectorOrientation.Right:
|
|
||||||
return 1;
|
|
||||||
default: return info.XRatio;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double GetYRatioFromConnector(FullyCreatedConnectorInfo info)
|
|
||||||
{
|
|
||||||
if (info.IsInnerPoint)
|
|
||||||
{
|
|
||||||
return info.YRatio;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (info.Orientation)
|
|
||||||
{
|
|
||||||
case ConnectorOrientation.Top:
|
|
||||||
return 0;
|
|
||||||
case ConnectorOrientation.Left:
|
|
||||||
return 0.5;
|
|
||||||
case ConnectorOrientation.Bottom:
|
|
||||||
return 1;
|
|
||||||
case ConnectorOrientation.Right:
|
|
||||||
return 0.5;
|
|
||||||
default: return info.YRatio;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private DesignerItemViewModelBase GetConnectorDataItem(IDiagramViewModel diagramViewModel, Guid conectorDataItemId, Type connectorDataItemType)
|
private DesignerItemViewModelBase GetConnectorDataItem(IDiagramViewModel diagramViewModel, Guid conectorDataItemId, Type connectorDataItemType)
|
||||||
{
|
{
|
||||||
@@ -659,106 +427,6 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 布局
|
|
||||||
public void AlignTopExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.AlignTopCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void AlignVerticalCentersExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.AlignVerticalCentersCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void AlignBottomExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.AlignBottomCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void AlignLeftExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.AlignLeftCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void AlignHorizontalCentersExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.AlignHorizontalCentersCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void AlignRightExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.AlignRightCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void BringForwardExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.BringForwardCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void BringToFrontExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.BringToFrontCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void SendBackwardExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.SendBackwardCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void SendToBackExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.SendToBackCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void DistributeHorizontalExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.DistributeHorizontalCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void DistributeVerticalExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.DistributeVerticalCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void SelectAllExecuted(object para)
|
|
||||||
{
|
|
||||||
DiagramViewModel.SelectAllCommand.Execute(null);
|
|
||||||
}
|
|
||||||
public void GroupExecuted(object para)
|
|
||||||
{
|
|
||||||
var items = from item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>()
|
|
||||||
where item.ParentId == Guid.Empty
|
|
||||||
select item;
|
|
||||||
|
|
||||||
Rect rect = DiagramViewModel.GetBoundingRectangle(items);
|
|
||||||
|
|
||||||
GroupDesignerItemViewModel groupItem = new GroupDesignerItemViewModel();
|
|
||||||
groupItem.IsGroup = true;
|
|
||||||
groupItem.ItemWidth = rect.Width;
|
|
||||||
groupItem.ItemHeight = rect.Height;
|
|
||||||
groupItem.Left = rect.Left;
|
|
||||||
groupItem.Top = rect.Top;
|
|
||||||
groupItem.ZIndex = DiagramViewModel.Items.Count;
|
|
||||||
|
|
||||||
DiagramViewModel.DirectAddItemCommand.Execute(groupItem);
|
|
||||||
|
|
||||||
foreach (DesignerItemViewModelBase item in items)
|
|
||||||
item.ParentId = groupItem.Id;
|
|
||||||
|
|
||||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
|
||||||
//groupItem.IsSelected = true;
|
|
||||||
DiagramViewModel.SelectionService.AddToSelection(groupItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UngroupExecuted(object para)
|
|
||||||
{
|
|
||||||
var groups = (from item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>()
|
|
||||||
where item.IsGroup && item.ParentId == Guid.Empty
|
|
||||||
select item).ToArray();
|
|
||||||
|
|
||||||
foreach (DesignerItemViewModelBase groupRoot in groups)
|
|
||||||
{
|
|
||||||
var children = from child in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>()
|
|
||||||
where child.ParentId == groupRoot.Id
|
|
||||||
select child;
|
|
||||||
|
|
||||||
foreach (DesignerItemViewModelBase child in children)
|
|
||||||
child.ParentId = Guid.Empty;
|
|
||||||
|
|
||||||
DiagramViewModel.RemoveItemCommand.Execute(groupRoot);
|
|
||||||
DiagramViewModel.UpdateZIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 主题
|
#region 主题
|
||||||
public void SetPropertyValue(SelectableDesignerItemViewModelBase selectable, string propertyName)
|
public void SetPropertyValue(SelectableDesignerItemViewModelBase selectable, string propertyName)
|
||||||
{
|
{
|
||||||
@@ -806,93 +474,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
}
|
}
|
||||||
quickThemeViewModel.QuickTheme = null;
|
quickThemeViewModel.QuickTheme = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CenterMoveExecuted(object para)
|
|
||||||
{
|
|
||||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.Left = (DiagramViewModel.PageSize.Width - item.ItemWidth) / 2;
|
|
||||||
item.Top = (DiagramViewModel.PageSize.Height - item.ItemHeight) / 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LeftMoveExecuted(object para)
|
|
||||||
{
|
|
||||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.Left -= 0.5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RightMoveExecuted(object para)
|
|
||||||
{
|
|
||||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.Left += 0.5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpMoveExecuted(object para)
|
|
||||||
{
|
|
||||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.Top -= 0.5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DownMoveExecuted(object para)
|
|
||||||
{
|
|
||||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.Top += 0.5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SameWidthExecuted(object para)
|
|
||||||
{
|
|
||||||
if (para is DesignerItemViewModelBase designerItem)
|
|
||||||
{
|
|
||||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.ItemWidth = designerItem.ItemWidth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SameHeightExecuted(object para)
|
|
||||||
{
|
|
||||||
if (para is DesignerItemViewModelBase designerItem)
|
|
||||||
{
|
|
||||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.ItemHeight = designerItem.ItemHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SameAngleExecuted(object para)
|
|
||||||
{
|
|
||||||
if (para is DesignerItemViewModelBase designerItem)
|
|
||||||
{
|
|
||||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.Angle = designerItem.Angle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SameSizeExecuted(object para)
|
|
||||||
{
|
|
||||||
if (para is DesignerItemViewModelBase designerItem)
|
|
||||||
{
|
|
||||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.ItemWidth = designerItem.ItemWidth;
|
|
||||||
item.ItemHeight = designerItem.ItemHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LockAction(LockObject lockObject, string propertyName)
|
public void LockAction(LockObject lockObject, string propertyName)
|
||||||
{
|
{
|
||||||
@@ -946,15 +528,15 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
ConnectionItem connection = new ConnectionItem(
|
ConnectionItem connection = new ConnectionItem(
|
||||||
connectionVM.SourceConnectorInfo.DataItem.Id,
|
connectionVM.SourceConnectorInfo.DataItem.Id,
|
||||||
connectionVM.SourceConnectorInfo.Orientation,
|
connectionVM.SourceConnectorInfo.Orientation,
|
||||||
DiagramItem.GetTypeOfDiagramItem(connectionVM.SourceConnectorInfo.DataItem),
|
connectionVM.SourceConnectorInfo.DataItem.GetType(),
|
||||||
GetXRatioFromConnector(connectionVM.SourceConnectorInfo),
|
connectionVM.GetXRatioFromConnector(connectionVM.SourceConnectorInfo),
|
||||||
GetYRatioFromConnector(connectionVM.SourceConnectorInfo),
|
connectionVM.GetYRatioFromConnector(connectionVM.SourceConnectorInfo),
|
||||||
connectionVM.SourceConnectorInfo.IsInnerPoint,
|
connectionVM.SourceConnectorInfo.IsInnerPoint,
|
||||||
sinkConnector.DataItem.Id,
|
sinkConnector.DataItem.Id,
|
||||||
sinkConnector.Orientation,
|
sinkConnector.Orientation,
|
||||||
DiagramItem.GetTypeOfDiagramItem(sinkConnector.DataItem),
|
sinkConnector.DataItem.GetType(),
|
||||||
GetXRatioFromConnector(sinkConnector),
|
connectionVM.GetXRatioFromConnector(sinkConnector),
|
||||||
GetYRatioFromConnector(sinkConnector),
|
connectionVM.GetYRatioFromConnector(sinkConnector),
|
||||||
sinkConnector.IsInnerPoint,
|
sinkConnector.IsInnerPoint,
|
||||||
connectionVM);
|
connectionVM);
|
||||||
|
|
||||||
@@ -1039,7 +621,6 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void AddImageExecuted(object para)
|
public void AddImageExecuted(object para)
|
||||||
{
|
{
|
||||||
ImageItemViewModel itemBase = new ImageItemViewModel();
|
ImageItemViewModel itemBase = new ImageItemViewModel();
|
||||||
@@ -1107,7 +688,6 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
private Size MeasureString(OutLineTextDesignerItemViewModel itemBase)
|
private Size MeasureString(OutLineTextDesignerItemViewModel itemBase)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -737,23 +737,17 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
|
|
||||||
private void UnDoExecuted()
|
private void UnDoExecuted()
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.UndoCommand.Execute(null);
|
||||||
|
|
||||||
DiagramsViewModel.UnDoExecuted();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReDoExecuted()
|
private void ReDoExecuted()
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.RedoCommand.Execute(null);
|
||||||
|
|
||||||
DiagramsViewModel.ReDoExecuted();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectedAllExecuted()
|
private void SelectedAllExecuted()
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.SelectAllCommand.Execute(null);
|
||||||
|
|
||||||
DiagramsViewModel.SelectedAllExecuted();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenExecuted(string para = null)
|
private void OpenExecuted(string para = null)
|
||||||
@@ -851,21 +845,17 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
|
|
||||||
private void PasteExecuted()
|
private void PasteExecuted()
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.PasteCommand.Execute(null);
|
||||||
|
|
||||||
DiagramsViewModel.Paste();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Paste_Enabled()
|
private bool Paste_Enabled()
|
||||||
{
|
{
|
||||||
return Clipboard.ContainsData(DataFormats.Xaml);
|
return Clipboard.ContainsData(DataFormats.Serializable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CopyExecuted()
|
private void CopyExecuted()
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.CopyCommand.Execute(null);
|
||||||
|
|
||||||
DiagramsViewModel.CopyCurrentSelection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Copy_Enabled()
|
private bool Copy_Enabled()
|
||||||
@@ -875,9 +865,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
|
|
||||||
private void DeleteExecuted()
|
private void DeleteExecuted()
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.DeleteCommand.Execute(null);
|
||||||
|
|
||||||
DiagramsViewModel.DeleteCurrentSelection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Delete_Enabled()
|
private bool Delete_Enabled()
|
||||||
@@ -887,9 +875,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
|
|
||||||
private void CutExecuted()
|
private void CutExecuted()
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel != null)
|
DiagramsViewModel?.DiagramViewModel?.CutCommand.Execute(null);
|
||||||
|
|
||||||
DiagramsViewModel.CutCurrentSelection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Cut_Enabled()
|
private bool Cut_Enabled()
|
||||||
@@ -937,267 +923,191 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
|
|
||||||
private void GroupExecuted(object para)
|
private void GroupExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.GroupCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.GroupExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UngroupExecuted(object para)
|
private void UngroupExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.UngroupCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.UngroupExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 布局
|
#region 布局
|
||||||
private void AlignTopExecuted(object para)
|
private void AlignTopExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.AlignTopCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.AlignTopExecuted(para);
|
|
||||||
}
|
}
|
||||||
private void AlignVerticalCentersExecuted(object para)
|
private void AlignVerticalCentersExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.AlignVerticalCentersCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.AlignVerticalCentersExecuted(para);
|
|
||||||
}
|
}
|
||||||
private void AlignBottomExecuted(object para)
|
private void AlignBottomExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.AlignBottomCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.AlignBottomExecuted(para);
|
|
||||||
}
|
}
|
||||||
private void AlignLeftExecuted(object para)
|
private void AlignLeftExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.AlignLeftCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.AlignLeftExecuted(para);
|
|
||||||
}
|
}
|
||||||
private void AlignHorizontalCentersExecuted(object para)
|
private void AlignHorizontalCentersExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.AlignHorizontalCentersCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.AlignHorizontalCentersExecuted(para);
|
|
||||||
}
|
}
|
||||||
private void AlignRightExecuted(object para)
|
private void AlignRightExecuted(object para)
|
||||||
{
|
{
|
||||||
DiagramsViewModel.AlignRightExecuted(para);
|
DiagramsViewModel?.DiagramViewModel?.AlignRightCommand.Execute(para);
|
||||||
}
|
}
|
||||||
private void BringForwardExecuted(object para)
|
private void BringForwardExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.BringForwardCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.BringForwardExecuted(para);
|
|
||||||
}
|
}
|
||||||
private void BringToFrontExecuted(object para)
|
private void BringToFrontExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.BringToFrontCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.BringToFrontExecuted(para);
|
|
||||||
}
|
}
|
||||||
private void SendBackwardExecuted(object para)
|
private void SendBackwardExecuted(object para)
|
||||||
{
|
{
|
||||||
DiagramsViewModel.SendBackwardExecuted(para);
|
DiagramsViewModel?.DiagramViewModel?.SendBackwardCommand.Execute(para);
|
||||||
}
|
}
|
||||||
private void SendToBackExecuted(object para)
|
private void SendToBackExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.SendBackwardCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.SendToBackExecuted(para);
|
|
||||||
}
|
}
|
||||||
private void DistributeHorizontalExecuted(object para)
|
private void DistributeHorizontalExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.DistributeHorizontalCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.DistributeHorizontalExecuted(para);
|
|
||||||
}
|
}
|
||||||
private void DistributeVerticalExecuted(object para)
|
private void DistributeVerticalExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.DistributeVerticalCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.DistributeVerticalExecuted(para);
|
|
||||||
}
|
}
|
||||||
private void SelectAllExecuted(object para)
|
private void SelectAllExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.SelectAllCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.SelectAllExecuted(para);
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void CenterMoveExecuted(object para)
|
private void CenterMoveExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.CenterMoveCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.CenterMoveExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LeftMoveExecuted(object para = null)
|
private void LeftMoveExecuted(object para = null)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.LeftMoveCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.LeftMoveExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RightMoveExecuted(object para = null)
|
private void RightMoveExecuted(object para = null)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.RightMoveCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.RightMoveExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpMoveExecuted(object para = null)
|
private void UpMoveExecuted(object para = null)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.UpMoveCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.UpMoveExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DownMoveExecuted(object para = null)
|
private void DownMoveExecuted(object para = null)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.DownMoveCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.DownMoveExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SameWidthExecuted(object para)
|
private void SameWidthExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.SameWidthCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.SameWidthExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SameHeightExecuted(object para)
|
private void SameHeightExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.SameHeightCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.SameHeightExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SameSizeExecuted(object para)
|
private void SameSizeExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.SameSizeCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.SameSizeExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SameAngleExecuted(object para)
|
private void SameAngleExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DiagramViewModel?.SameAngleCommand.Execute(para);
|
||||||
|
|
||||||
DiagramsViewModel.SameAngleExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LockExecuted(object para)
|
private void LockExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
|
||||||
|
|
||||||
LockObjectViewModel.LockObject[0].IsChecked = true;
|
LockObjectViewModel.LockObject[0].IsChecked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UnlockExecuted(object para)
|
private void UnlockExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
|
||||||
|
|
||||||
LockObjectViewModel.LockObject.ForEach(p => p.IsChecked = false);
|
LockObjectViewModel.LockObject.ForEach(p => p.IsChecked = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddPageExecuted(object para)
|
private void AddPageExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.AddPageExecuted(para);
|
||||||
|
|
||||||
DiagramsViewModel.AddPageExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddCopyPageExecuted(object para)
|
private void AddCopyPageExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.AddCopyPageExecuted(para);
|
||||||
|
|
||||||
DiagramsViewModel.AddCopyPageExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RenamePageExecuted(object para)
|
private void RenamePageExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.RenamePageExecuted(para);
|
||||||
|
|
||||||
DiagramsViewModel.RenamePageExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EndRenamePageExecuted(object para)
|
private void EndRenamePageExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.EndRenamePageExecuted(para);
|
||||||
|
|
||||||
DiagramsViewModel.EndRenamePageExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void DeletePageExecuted(object para)
|
private void DeletePageExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.DeletePageExecuted(para);
|
||||||
|
|
||||||
DiagramsViewModel.DeletePageExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void AddImageExecuted(object para)
|
private void AddImageExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.AddImageExecuted(para);
|
||||||
|
|
||||||
DiagramsViewModel.AddImageExecuted(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EditImageExecuted(object para)
|
private void EditImageExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.EditImageExecuted(DiagramsViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
|
||||||
|
|
||||||
DiagramsViewModel.EditImageExecuted(DiagramsViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResizeImageExecuted(object para)
|
private void ResizeImageExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.ResizeImageExecuted(DiagramsViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
|
||||||
|
|
||||||
DiagramsViewModel.ResizeImageExecuted(DiagramsViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetImageExecuted(object para)
|
private void ResetImageExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.ResetImageExecuted(DiagramsViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
|
||||||
|
|
||||||
DiagramsViewModel.ResetImageExecuted(DiagramsViewModel.DiagramViewModel.SelectedItems?.FirstOrDefault());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddVideoExectued(object para)
|
private void AddVideoExectued(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.AddVideoExecuted(para);
|
||||||
|
|
||||||
DiagramsViewModel.AddVideoExecuted(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddOutLineTextExecuted(object para)
|
private void AddOutLineTextExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.AddOutLineTextExecuted(para);
|
||||||
|
|
||||||
DiagramsViewModel.AddOutLineTextExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddBarcodeExecuted(object para)
|
private void AddBarcodeExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
DiagramsViewModel?.AddBarcodeExecuted(para);
|
||||||
|
|
||||||
DiagramsViewModel.AddBarcodeExecuted(para);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectedColorExecuted(object para)
|
private void SelectedColorExecuted(object para)
|
||||||
{
|
{
|
||||||
if (DiagramsViewModel == null) return;
|
|
||||||
|
|
||||||
switch (ColorType)
|
switch (ColorType)
|
||||||
{
|
{
|
||||||
case Models.ColorType.Text: DiagramsViewModel.SetFont(new FontViewModel() { FontColor = (Color)para }, "FontColor"); break;
|
case Models.ColorType.Text: DiagramsViewModel?.SetFont(new FontViewModel() { FontColor = (Color)para }, "FontColor"); break;
|
||||||
case Models.ColorType.Fill: DiagramsViewModel.SetColor(new ColorViewModel() { FillColor = new ColorObject() { Color = (Color)para } }, "FillColor"); break;
|
case Models.ColorType.Fill: DiagramsViewModel?.SetColor(new ColorViewModel() { FillColor = new ColorObject() { Color = (Color)para } }, "FillColor"); break;
|
||||||
case Models.ColorType.Line: DiagramsViewModel.SetColor(new ColorViewModel() { LineColor = new ColorObject() { Color = (Color)para } }, "LineColor"); break;
|
case Models.ColorType.Line: DiagramsViewModel?.SetColor(new ColorViewModel() { LineColor = new ColorObject() { Color = (Color)para } }, "LineColor"); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ namespace AIStudio.Wpf.DiagramApp
|
|||||||
|
|
||||||
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||||
{
|
{
|
||||||
|
base.OnPreviewKeyDown(e);
|
||||||
e.Handled = MainWindowViewModel.KeyExecuted(e.KeyboardDevice.Modifiers == ModifierKeys.None ? e.Key.ToString() : e.KeyboardDevice.Modifiers.ToString() + "+" + e.Key.ToString());
|
e.Handled = MainWindowViewModel.KeyExecuted(e.KeyboardDevice.Modifiers == ModifierKeys.None ? e.Key.ToString() : e.KeyboardDevice.Modifiers.ToString() + "+" + e.Key.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -401,48 +401,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
base.OnPreviewKeyDown(e);
|
base.OnPreviewKeyDown(e);
|
||||||
|
|
||||||
if (_viewModel.IsReadOnly) return;
|
|
||||||
|
|
||||||
if (e.Key == Key.Left)
|
|
||||||
{
|
|
||||||
if (_viewModel.SelectedItems != null)
|
|
||||||
{
|
|
||||||
foreach(var item in _viewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.Left -= 0.1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (e.Key == Key.Right)
|
|
||||||
{
|
|
||||||
if (_viewModel.SelectedItems != null)
|
|
||||||
{
|
|
||||||
foreach (var item in _viewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.Left += 0.1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (e.Key == Key.Up)
|
|
||||||
{
|
|
||||||
if (_viewModel.SelectedItems != null)
|
|
||||||
{
|
|
||||||
foreach (var item in _viewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.Top -= 0.1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (e.Key == Key.Down)
|
|
||||||
{
|
|
||||||
if (_viewModel.SelectedItems != null)
|
|
||||||
{
|
|
||||||
foreach (var item in _viewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
|
||||||
{
|
|
||||||
item.Top += 0.1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Size MeasureOverride(Size constraint)
|
protected override Size MeasureOverride(Size constraint)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Reflection;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramHelper.Helpers
|
namespace AIStudio.Wpf.DiagramDesigner.Helpers
|
||||||
{
|
{
|
||||||
public class TypeHelper
|
public class TypeHelper
|
||||||
{
|
{
|
||||||
@@ -6,7 +6,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramHelper.Helpers
|
namespace AIStudio.Wpf.DiagramDesigner.Helpers
|
||||||
{
|
{
|
||||||
public class XmlSerializeHelper
|
public class XmlSerializeHelper
|
||||||
{
|
{
|
||||||
41
AIStudio.Wpf.DiagramDesigner/Models/SerializableObject.cs
Normal file
41
AIStudio.Wpf.DiagramDesigner/Models/SerializableObject.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.DiagramDesigner.Models
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
[XmlInclude(typeof(SerializableItem))]
|
||||||
|
public class SerializableItem
|
||||||
|
{
|
||||||
|
[XmlIgnore]
|
||||||
|
public Type Type
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public string TypeName
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public string ObjectJson
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
[XmlInclude(typeof(SerializableObject))]
|
||||||
|
public class SerializableObject
|
||||||
|
{
|
||||||
|
[XmlArray]
|
||||||
|
public List<SerializableItem> DesignerItems { get; set; } = new List<SerializableItem>();
|
||||||
|
|
||||||
|
[XmlArray]
|
||||||
|
public List<SerializableItem> Connections { get; set; } = new List<SerializableItem>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ using System.ComponentModel;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner
|
namespace AIStudio.Wpf.DiagramDesigner
|
||||||
{
|
{
|
||||||
@@ -19,6 +20,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DesignerItemViewModelBase(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
@@ -42,6 +47,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
this.Icon = designer.Icon;
|
this.Icon = designer.Icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return new DesignerItemBase(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type ToXmlType()
|
||||||
|
{
|
||||||
|
return typeof(DesignerItemBase);
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void InitConnector()
|
protected virtual void InitConnector()
|
||||||
{
|
{
|
||||||
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top));
|
connectors.Add(new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top));
|
||||||
|
|||||||
@@ -78,6 +78,20 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
BuildMenuOptions();
|
BuildMenuOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LogicalGateItemViewModelBase(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
BuildMenuOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return new LogicalGateDesignerItemBase(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type ToXmlType()
|
||||||
|
{
|
||||||
|
return typeof(LogicalGateDesignerItemBase);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,19 +5,30 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner
|
namespace AIStudio.Wpf.DiagramDesigner
|
||||||
{
|
{
|
||||||
|
|
||||||
public interface ISelectItems
|
public interface ISelectItems
|
||||||
{
|
{
|
||||||
SimpleCommand SelectItemCommand { get; }
|
SimpleCommand SelectItemCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public abstract class SelectableDesignerItemViewModelBase : BindableBase, ISelectItems, ISelectable, IGroupable
|
public abstract class SelectableDesignerItemViewModelBase : BindableBase, ISelectItems, ISelectable, IGroupable
|
||||||
{
|
{
|
||||||
private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
|
private IDiagramServiceProvider _service
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return DiagramServicesProvider.Instance.Provider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SelectableDesignerItemViewModelBase()
|
public SelectableDesignerItemViewModelBase()
|
||||||
{
|
{
|
||||||
@@ -32,6 +43,37 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
(FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged;
|
(FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SelectableDesignerItemViewModelBase(IDiagramViewModel parent, string json)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
LoadDesignerItemViewModel(parent, JsonConvert.DeserializeObject(json, ToXmlType()) as SelectableDesignerItemBase);
|
||||||
|
(FontViewModel as FontViewModel).PropertyChanged += FontViewModel_PropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual SerializableItem ToSerializabObject()
|
||||||
|
{
|
||||||
|
var obj = ToXmlObject();
|
||||||
|
if (obj != null)
|
||||||
|
{
|
||||||
|
return new SerializableItem() { TypeName = this.GetType().FullName, ObjectJson = obj.ToJson() };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public virtual Type ToXmlType()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void Init()
|
protected virtual void Init()
|
||||||
{
|
{
|
||||||
ColorViewModel = _service.CopyDefaultColorViewModel();
|
ColorViewModel = _service.CopyDefaultColorViewModel();
|
||||||
@@ -68,13 +110,28 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
public List<SelectableDesignerItemViewModelBase> SelectedItems
|
public List<SelectableDesignerItemViewModelBase> SelectedItems
|
||||||
{
|
{
|
||||||
//todo
|
//todo
|
||||||
get { return Parent.SelectedItems; }
|
get
|
||||||
|
{
|
||||||
|
return Parent.SelectedItems;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDiagramViewModel Parent { get; set; }
|
public IDiagramViewModel Parent
|
||||||
public SimpleCommand SelectItemCommand { get; private set; }
|
{
|
||||||
public ICommand EditCommand { get; private set; }
|
get; set;
|
||||||
public Guid Id { get; set; }
|
}
|
||||||
|
public SimpleCommand SelectItemCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
public ICommand EditCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
public Guid Id
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
private Guid _parentId;
|
private Guid _parentId;
|
||||||
public Guid ParentId
|
public Guid ParentId
|
||||||
@@ -88,9 +145,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
SetProperty(ref _parentId, value);
|
SetProperty(ref _parentId, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public SelectableDesignerItemViewModelBase ParentItem { get; set; }
|
public SelectableDesignerItemViewModelBase ParentItem
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsGroup { get; set; }
|
public bool IsGroup
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
private bool _isSelected;
|
private bool _isSelected;
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
@@ -203,7 +266,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILockObjectViewModel LockObjectViewModel { get; set; }
|
public ILockObjectViewModel LockObjectViewModel
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private string _text;
|
private string _text;
|
||||||
@@ -275,7 +341,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectableDesignerItemViewModelBase OutTextItem { get; set; }
|
public DesignerItemViewModelBase OutTextItem
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
private void ExecuteSelectItemCommand(object param)
|
private void ExecuteSelectItemCommand(object param)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,42 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
Init(sourceConnectorInfo, sinkConnectorInfo);
|
Init(sourceConnectorInfo, sinkConnectorInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConnectorViewModel( FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode vectorLineDrawMode):this(null, sourceConnectorInfo, sinkConnectorInfo, vectorLineDrawMode)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
if (SinkConnectorInfo is FullyCreatedConnectorInfo sinkConnector)
|
||||||
|
{
|
||||||
|
ConnectionItem connection = new ConnectionItem(
|
||||||
|
SourceConnectorInfo.DataItem.Id,
|
||||||
|
SourceConnectorInfo.Orientation,
|
||||||
|
SourceConnectorInfo.DataItem.GetType(),
|
||||||
|
GetXRatioFromConnector(SourceConnectorInfo),
|
||||||
|
GetYRatioFromConnector(SourceConnectorInfo),
|
||||||
|
SourceConnectorInfo.IsInnerPoint,
|
||||||
|
sinkConnector.DataItem.Id,
|
||||||
|
sinkConnector.Orientation,
|
||||||
|
sinkConnector.DataItem.GetType(),
|
||||||
|
GetXRatioFromConnector(sinkConnector),
|
||||||
|
GetYRatioFromConnector(sinkConnector),
|
||||||
|
sinkConnector.IsInnerPoint,
|
||||||
|
this);
|
||||||
|
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type ToXmlType()
|
||||||
|
{
|
||||||
|
return typeof(ConnectionItem);
|
||||||
|
}
|
||||||
|
|
||||||
public IPathFinder PathFinder
|
public IPathFinder PathFinder
|
||||||
{
|
{
|
||||||
@@ -207,6 +243,52 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double GetXRatioFromConnector(FullyCreatedConnectorInfo info)
|
||||||
|
{
|
||||||
|
if (info.IsInnerPoint)
|
||||||
|
{
|
||||||
|
return info.XRatio;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (info.Orientation)
|
||||||
|
{
|
||||||
|
case ConnectorOrientation.Top:
|
||||||
|
return 0.5;
|
||||||
|
case ConnectorOrientation.Left:
|
||||||
|
return 0;
|
||||||
|
case ConnectorOrientation.Bottom:
|
||||||
|
return 0.5;
|
||||||
|
case ConnectorOrientation.Right:
|
||||||
|
return 1;
|
||||||
|
default: return info.XRatio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetYRatioFromConnector(FullyCreatedConnectorInfo info)
|
||||||
|
{
|
||||||
|
if (info.IsInnerPoint)
|
||||||
|
{
|
||||||
|
return info.YRatio;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (info.Orientation)
|
||||||
|
{
|
||||||
|
case ConnectorOrientation.Top:
|
||||||
|
return 0;
|
||||||
|
case ConnectorOrientation.Left:
|
||||||
|
return 0.5;
|
||||||
|
case ConnectorOrientation.Bottom:
|
||||||
|
return 1;
|
||||||
|
case ConnectorOrientation.Right:
|
||||||
|
return 0.5;
|
||||||
|
default: return info.YRatio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateArea()
|
private void UpdateArea()
|
||||||
{
|
{
|
||||||
Area = new Rect(SourceA, SourceB);
|
Area = new Rect(SourceA, SourceB);
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner
|
namespace AIStudio.Wpf.DiagramDesigner
|
||||||
{
|
{
|
||||||
@@ -353,36 +356,61 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
/// 用于wpf大小与物理像素之间转换
|
/// 用于wpf大小与物理像素之间转换
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double ScreenScale { get; set; } = 1;
|
public double ScreenScale { get; set; } = 1;
|
||||||
|
|
||||||
|
private double OffsetX = 10;
|
||||||
|
private double OffsetY = 10;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private DoCommandManager DoCommandManager = new DoCommandManager();
|
private DoCommandManager DoCommandManager = new DoCommandManager();
|
||||||
public DiagramViewModel()
|
public DiagramViewModel()
|
||||||
{
|
{
|
||||||
CreateNewDiagramCommand = new SimpleCommand(ExecuteCreateNewDiagramCommand);
|
CreateNewDiagramCommand = new SimpleCommand(ExecuteEnable, ExecuteCreateNewDiagramCommand);
|
||||||
AddItemCommand = new SimpleCommand(ExecuteAddItemCommand);
|
AddItemCommand = new SimpleCommand(ExecuteEnable, ExecuteAddItemCommand);
|
||||||
DirectAddItemCommand = new SimpleCommand(ExecuteDirectAddItemCommand);
|
DirectAddItemCommand = new SimpleCommand(ExecuteEnable, ExecuteDirectAddItemCommand);
|
||||||
RemoveItemCommand = new SimpleCommand(ExecuteRemoveItemCommand);
|
RemoveItemCommand = new SimpleCommand(ExecuteEnable, ExecuteRemoveItemCommand);
|
||||||
DirectRemoveItemCommand = new SimpleCommand(ExecuteDirectRemoveItemCommand);
|
DirectRemoveItemCommand = new SimpleCommand(ExecuteEnable, ExecuteDirectRemoveItemCommand);
|
||||||
ClearSelectedItemsCommand = new SimpleCommand(ExecuteClearSelectedItemsCommand);
|
ClearSelectedItemsCommand = new SimpleCommand(ExecuteEnable, ExecuteClearSelectedItemsCommand);
|
||||||
|
|
||||||
AlignTopCommand = new SimpleCommand(ExecuteAlignTopCommand);
|
AlignTopCommand = new SimpleCommand(ExecuteEnable, ExecuteAlignTopCommand);
|
||||||
AlignVerticalCentersCommand = new SimpleCommand(ExecuteAlignVerticalCentersCommand);
|
AlignVerticalCentersCommand = new SimpleCommand(ExecuteEnable, ExecuteAlignVerticalCentersCommand);
|
||||||
AlignBottomCommand = new SimpleCommand(ExecuteAlignBottomCommand);
|
AlignBottomCommand = new SimpleCommand(ExecuteEnable, ExecuteAlignBottomCommand);
|
||||||
AlignLeftCommand = new SimpleCommand(ExecuteAlignLeftCommand);
|
AlignLeftCommand = new SimpleCommand(ExecuteEnable, ExecuteAlignLeftCommand);
|
||||||
AlignHorizontalCentersCommand = new SimpleCommand(ExecuteAlignHorizontalCentersCommand);
|
AlignHorizontalCentersCommand = new SimpleCommand(ExecuteEnable, ExecuteAlignHorizontalCentersCommand);
|
||||||
AlignRightCommand = new SimpleCommand(ExecuteAlignRightCommand);
|
AlignRightCommand = new SimpleCommand(ExecuteEnable, ExecuteAlignRightCommand);
|
||||||
BringForwardCommand = new SimpleCommand(ExecuteBringForwardCommand);
|
BringForwardCommand = new SimpleCommand(ExecuteEnable, ExecuteBringForwardCommand);
|
||||||
BringToFrontCommand = new SimpleCommand(ExecuteBringToFrontCommand);
|
BringToFrontCommand = new SimpleCommand(ExecuteEnable, ExecuteBringToFrontCommand);
|
||||||
SendBackwardCommand = new SimpleCommand(ExecuteSendBackwardCommand);
|
SendBackwardCommand = new SimpleCommand(ExecuteEnable, ExecuteSendBackwardCommand);
|
||||||
SendToBackCommand = new SimpleCommand(ExecuteSendToBackCommand);
|
SendToBackCommand = new SimpleCommand(ExecuteEnable, ExecuteSendToBackCommand);
|
||||||
DistributeHorizontalCommand = new SimpleCommand(ExecuteDistributeHorizontalCommand);
|
DistributeHorizontalCommand = new SimpleCommand(ExecuteEnable, ExecuteDistributeHorizontalCommand);
|
||||||
DistributeVerticalCommand = new SimpleCommand(ExecuteDistributeVerticalCommand);
|
DistributeVerticalCommand = new SimpleCommand(ExecuteEnable, ExecuteDistributeVerticalCommand);
|
||||||
SelectAllCommand = new SimpleCommand(ExecuteSelectAllCommand);
|
SelectAllCommand = new SimpleCommand(ExecuteEnable, ExecuteSelectAllCommand);
|
||||||
|
CopyCommand = new SimpleCommand(ExecuteEnable, ExecuteCopyCommand);
|
||||||
|
PasteCommand = new SimpleCommand(ExecuteEnable, ExecutePasteCommand);
|
||||||
|
CutCommand = new SimpleCommand(ExecuteEnable, ExecuteCutCommand);
|
||||||
|
DeleteCommand = new SimpleCommand(ExecuteEnable, ExecuteDeleteCommand);
|
||||||
|
LeftMoveCommand = new SimpleCommand(ExecuteEnable, ExecuteLeftMoveCommand);
|
||||||
|
RightMoveCommand = new SimpleCommand(ExecuteEnable, ExecuteRightMoveCommand);
|
||||||
|
UpMoveCommand = new SimpleCommand(ExecuteEnable, ExecuteUpMoveCommand);
|
||||||
|
DownMoveCommand = new SimpleCommand(ExecuteEnable, ExecuteDownMoveCommand);
|
||||||
|
CenterMoveCommand = new SimpleCommand(ExecuteEnable, ExecuteCenterMoveCommand);
|
||||||
|
SameSizeCommand = new SimpleCommand(ExecuteEnable, ExecuteSameSizeCommand);
|
||||||
|
SameWidthCommand = new SimpleCommand(ExecuteEnable, ExecuteSameWidthCommand);
|
||||||
|
SameHeightCommand = new SimpleCommand(ExecuteEnable, ExecuteSameHeightCommand);
|
||||||
|
SameAngleCommand = new SimpleCommand(ExecuteEnable, ExecuteSameAngleCommand);
|
||||||
|
GroupCommand = new SimpleCommand(ExecuteEnable, ExecuteGroupCommand);
|
||||||
|
UngroupCommand = new SimpleCommand(ExecuteEnable, ExecuteUngroupCommand);
|
||||||
|
LockCommand = new SimpleCommand(ExecuteEnable, ExecuteLockCommand);
|
||||||
|
UnlockCommand = new SimpleCommand(ExecuteEnable, ExecuteUnlockCommand);
|
||||||
Mediator.Instance.Register(this);
|
Mediator.Instance.Register(this);
|
||||||
|
|
||||||
Items.CollectionChanged += Items_CollectionChanged;
|
Items.CollectionChanged += Items_CollectionChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ExecuteEnable(object para)
|
||||||
|
{
|
||||||
|
return IsReadOnly == false;
|
||||||
|
}
|
||||||
|
|
||||||
#region UnDo ReDo
|
#region UnDo ReDo
|
||||||
|
|
||||||
private void Do(object sender, string propertyName, object newvalue)
|
private void Do(object sender, string propertyName, object newvalue)
|
||||||
@@ -550,6 +578,83 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SimpleCommand CopyCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleCommand PasteCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleCommand CutCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleCommand DeleteCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleCommand LeftMoveCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleCommand RightMoveCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleCommand UpMoveCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleCommand DownMoveCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleCommand CenterMoveCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
public SimpleCommand SameSizeCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
public SimpleCommand SameWidthCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
public SimpleCommand SameHeightCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
public SimpleCommand SameAngleCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
public SimpleCommand GroupCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
public SimpleCommand UngroupCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
public SimpleCommand LockCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
public SimpleCommand UnlockCommand
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
private SimpleCommand _undoCommand;
|
private SimpleCommand _undoCommand;
|
||||||
public SimpleCommand UndoCommand
|
public SimpleCommand UndoCommand
|
||||||
{
|
{
|
||||||
@@ -597,6 +702,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool AddVerify(SelectableDesignerItemViewModelBase item)
|
public bool AddVerify(SelectableDesignerItemViewModelBase item)
|
||||||
{
|
{
|
||||||
if (item.InitData() == false)
|
if (item.InitData() == false)
|
||||||
@@ -638,7 +744,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
item.Parent = this;
|
item.Parent = this;
|
||||||
item.ZIndex = Items.Count;
|
item.ZIndex = Items.Count;
|
||||||
item.Id = Guid.NewGuid();
|
if (item.Id == Guid.Empty)
|
||||||
|
{
|
||||||
|
item.Id = Guid.NewGuid();
|
||||||
|
}
|
||||||
//item.LineColor = this.LineColor;
|
//item.LineColor = this.LineColor;
|
||||||
//item.FillColor = this.FillColor;
|
//item.FillColor = this.FillColor;
|
||||||
var logical = item as LogicalGateItemViewModelBase;
|
var logical = item as LogicalGateItemViewModelBase;
|
||||||
@@ -1267,6 +1376,363 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ExecuteCopyCommand(object parameter)
|
||||||
|
{
|
||||||
|
List<DesignerItemViewModelBase> selectedDesignerItems =
|
||||||
|
SelectedItems.OfType<DesignerItemViewModelBase>().ToList();
|
||||||
|
|
||||||
|
List<ConnectorViewModel> selectedConnections =
|
||||||
|
SelectedItems.OfType<ConnectorViewModel>().ToList();
|
||||||
|
|
||||||
|
foreach (ConnectorViewModel connection in Items.OfType<ConnectorViewModel>())
|
||||||
|
{
|
||||||
|
if (!selectedConnections.Contains(connection))
|
||||||
|
{
|
||||||
|
DesignerItemViewModelBase sourceItem = (from item in selectedDesignerItems
|
||||||
|
where item.Id == connection.SourceConnectorInfo.DataItem.Id
|
||||||
|
select item).FirstOrDefault();
|
||||||
|
|
||||||
|
DesignerItemViewModelBase sinkItem = (from item in selectedDesignerItems
|
||||||
|
where item.Id == ((connection.SinkConnectorInfo as FullyCreatedConnectorInfo).DataItem).Id
|
||||||
|
select item).FirstOrDefault();
|
||||||
|
|
||||||
|
if (sourceItem != null &&
|
||||||
|
sinkItem != null &&
|
||||||
|
BelongToSameGroup(sourceItem, sinkItem))
|
||||||
|
{
|
||||||
|
selectedConnections.Add(connection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//连线上的文本
|
||||||
|
foreach (var selectedConnection in selectedConnections)
|
||||||
|
{
|
||||||
|
if (selectedConnection.OutTextItem != null)
|
||||||
|
{
|
||||||
|
selectedDesignerItems.Add(selectedConnection.OutTextItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string json = new SerializableObject
|
||||||
|
{
|
||||||
|
DesignerItems = selectedDesignerItems.Select(p => p.ToSerializabObject()).Where(p => p != null).ToList(),
|
||||||
|
Connections = selectedConnections.Select(p => p.ToSerializabObject()).Where(p => p != null).ToList(),
|
||||||
|
}.ToJson();
|
||||||
|
|
||||||
|
OffsetX = 10;
|
||||||
|
OffsetY = 10;
|
||||||
|
Clipboard.Clear();
|
||||||
|
Clipboard.SetData(DataFormats.Serializable, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecutePasteCommand(object parameter)
|
||||||
|
{
|
||||||
|
if (Clipboard.ContainsData(DataFormats.Serializable))
|
||||||
|
{
|
||||||
|
String clipboardData = Clipboard.GetData(DataFormats.Serializable) as String;
|
||||||
|
|
||||||
|
if (String.IsNullOrEmpty(clipboardData))
|
||||||
|
return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<SelectableDesignerItemViewModelBase> items = new List<SelectableDesignerItemViewModelBase>();
|
||||||
|
SerializableObject copyitem = JsonConvert.DeserializeObject<SerializableObject>(clipboardData);
|
||||||
|
|
||||||
|
|
||||||
|
Dictionary<Guid, Guid> mappingOldToNewIDs = new Dictionary<Guid, Guid>();
|
||||||
|
|
||||||
|
foreach (var diagramItemData in copyitem.DesignerItems)
|
||||||
|
{
|
||||||
|
DesignerItemViewModelBase newItem = null;
|
||||||
|
|
||||||
|
Type type = TypeHelper.GetType(diagramItemData.TypeName);
|
||||||
|
|
||||||
|
DesignerItemViewModelBase itemBase = (DesignerItemViewModelBase)Activator.CreateInstance(type, this, diagramItemData.ObjectJson);
|
||||||
|
Guid newID = Guid.NewGuid();
|
||||||
|
mappingOldToNewIDs.Add(itemBase.Id, newID);
|
||||||
|
itemBase.Id = newID;
|
||||||
|
itemBase.Left += OffsetX;
|
||||||
|
itemBase.Top += OffsetY;
|
||||||
|
|
||||||
|
newItem = itemBase;
|
||||||
|
|
||||||
|
if (newItem != null)
|
||||||
|
{
|
||||||
|
items.Add(newItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DirectAddItemCommand.Execute(items);
|
||||||
|
OffsetX += 10;
|
||||||
|
OffsetY += 10;
|
||||||
|
|
||||||
|
List<SelectableDesignerItemViewModelBase> connectors = new List<SelectableDesignerItemViewModelBase>();
|
||||||
|
foreach (var connection in copyitem.Connections)
|
||||||
|
{
|
||||||
|
var connectionItem = JsonConvert.DeserializeObject<ConnectionItem>(connection.ObjectJson);
|
||||||
|
Guid newID = Guid.NewGuid();
|
||||||
|
mappingOldToNewIDs.Add(connectionItem.Id, newID);
|
||||||
|
|
||||||
|
connectionItem.SourceId = mappingOldToNewIDs[connectionItem.SourceId];
|
||||||
|
connectionItem.SinkId = mappingOldToNewIDs[connectionItem.SinkId];
|
||||||
|
|
||||||
|
connectionItem.SourceType = System.Type.GetType(connectionItem.SourceTypeName);
|
||||||
|
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
|
||||||
|
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(this, connectionItem.SourceId, connectionItem.SourceType);
|
||||||
|
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
|
||||||
|
FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sourceItem, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint);
|
||||||
|
|
||||||
|
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(this, connectionItem.SinkId, connectionItem.SinkType);
|
||||||
|
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
|
||||||
|
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sinkItem, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint);
|
||||||
|
|
||||||
|
ConnectorViewModel connectionVM = new ConnectorViewModel(this, sourceConnectorInfo, sinkConnectorInfo, connectionItem, connectionItem.VectorLineDrawMode);
|
||||||
|
connectors.Add(connectionVM);
|
||||||
|
|
||||||
|
DesignerItemViewModelBase textItem = items.OfType<DesignerItemViewModelBase>().FirstOrDefault(x => x.ParentId == connectionItem.Id);
|
||||||
|
if (textItem != null)
|
||||||
|
{
|
||||||
|
connectionVM.OutTextItem = textItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DirectAddItemCommand.Execute(connectors);
|
||||||
|
|
||||||
|
//修复父级的引用
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
if (item.ParentId != Guid.Empty)
|
||||||
|
{
|
||||||
|
if (mappingOldToNewIDs.ContainsKey(item.ParentId))
|
||||||
|
item.ParentId = mappingOldToNewIDs[item.ParentId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MessageBox.Show(e.StackTrace, e.Message, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DesignerItemViewModelBase GetConnectorDataItem(IDiagramViewModel diagramViewModel, Guid conectorDataItemId, Type connectorDataItemType)
|
||||||
|
{
|
||||||
|
DesignerItemViewModelBase dataItem = diagramViewModel.Items.OfType<DesignerItemViewModelBase>().Single(x => x.Id == conectorDataItemId);
|
||||||
|
return dataItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FullyCreatedConnectorInfo GetFullConnectorInfo(Guid connectorId, DesignerItemViewModelBase dataItem, ConnectorOrientation connectorOrientation, double xRatio, double yRatio, bool isInnerPoint)
|
||||||
|
{
|
||||||
|
if (isInnerPoint)
|
||||||
|
{
|
||||||
|
return dataItem.Connectors.Where(p => p.XRatio == xRatio && p.YRatio == yRatio).FirstOrDefault();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (connectorOrientation)
|
||||||
|
{
|
||||||
|
case ConnectorOrientation.Top:
|
||||||
|
return dataItem.TopConnector;
|
||||||
|
case ConnectorOrientation.Left:
|
||||||
|
return dataItem.LeftConnector;
|
||||||
|
case ConnectorOrientation.Right:
|
||||||
|
return dataItem.RightConnector;
|
||||||
|
case ConnectorOrientation.Bottom:
|
||||||
|
return dataItem.BottomConnector;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
string.Format("Found invalid persisted Connector Orientation for Connector Id: {0}", connectorId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ItemsToDeleteHasConnector(List<SelectableDesignerItemViewModelBase> itemsToRemove, ConnectorInfoBase connector)
|
||||||
|
{
|
||||||
|
if (connector is FullyCreatedConnectorInfo fully)
|
||||||
|
{
|
||||||
|
return itemsToRemove.Contains(fully.DataItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ExecuteCutCommand(object parameter)
|
||||||
|
{
|
||||||
|
ExecutePasteCommand(null);
|
||||||
|
OffsetX = 0;
|
||||||
|
OffsetY = 0;
|
||||||
|
ExecuteDeleteCommand(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteDeleteCommand(object parameter)
|
||||||
|
{
|
||||||
|
List<SelectableDesignerItemViewModelBase> itemsToRemove = SelectedItems.OfType<SelectableDesignerItemViewModelBase>().ToList();
|
||||||
|
List<SelectableDesignerItemViewModelBase> connectionsToAlsoRemove = new List<SelectableDesignerItemViewModelBase>();
|
||||||
|
|
||||||
|
foreach (var connector in Items.OfType<ConnectorViewModel>())
|
||||||
|
{
|
||||||
|
if (ItemsToDeleteHasConnector(itemsToRemove, connector.SourceConnectorInfo))
|
||||||
|
{
|
||||||
|
connectionsToAlsoRemove.Add(connector);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ItemsToDeleteHasConnector(itemsToRemove, connector.SinkConnectorInfo))
|
||||||
|
{
|
||||||
|
connectionsToAlsoRemove.Add(connector);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
itemsToRemove.AddRange(connectionsToAlsoRemove);
|
||||||
|
|
||||||
|
RemoveItemCommand.Execute(itemsToRemove);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteLeftMoveCommand(object parameter)
|
||||||
|
{
|
||||||
|
foreach (var item in SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||||
|
{
|
||||||
|
item.Left -= 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteRightMoveCommand(object parameter)
|
||||||
|
{
|
||||||
|
foreach (var item in SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||||
|
{
|
||||||
|
item.Left += 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteUpMoveCommand(object parameter)
|
||||||
|
{
|
||||||
|
foreach (var item in SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||||
|
{
|
||||||
|
item.Top -= 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteDownMoveCommand(object parameter)
|
||||||
|
{
|
||||||
|
foreach (var item in SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||||
|
{
|
||||||
|
item.Top += 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteCenterMoveCommand(object parameter)
|
||||||
|
{
|
||||||
|
foreach (var item in SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||||
|
{
|
||||||
|
item.Left = (PageSize.Width - item.ItemWidth) / 2;
|
||||||
|
item.Top = (PageSize.Height - item.ItemHeight) / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteSameSizeCommand(object parameter)
|
||||||
|
{
|
||||||
|
if (parameter is DesignerItemViewModelBase designerItem)
|
||||||
|
{
|
||||||
|
foreach (var item in SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||||
|
{
|
||||||
|
item.ItemWidth = designerItem.ItemWidth;
|
||||||
|
item.ItemHeight = designerItem.ItemHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteSameWidthCommand(object parameter)
|
||||||
|
{
|
||||||
|
if (parameter is DesignerItemViewModelBase designerItem)
|
||||||
|
{
|
||||||
|
foreach (var item in SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||||
|
{
|
||||||
|
item.ItemWidth = designerItem.ItemWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteSameHeightCommand(object parameter)
|
||||||
|
{
|
||||||
|
if (parameter is DesignerItemViewModelBase designerItem)
|
||||||
|
{
|
||||||
|
foreach (var item in SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||||
|
{
|
||||||
|
item.ItemHeight = designerItem.ItemHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteSameAngleCommand(object parameter)
|
||||||
|
{
|
||||||
|
if (parameter is DesignerItemViewModelBase designerItem)
|
||||||
|
{
|
||||||
|
foreach (var item in SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||||
|
{
|
||||||
|
item.Angle = designerItem.Angle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteGroupCommand(object parameter)
|
||||||
|
{
|
||||||
|
var items = from item in SelectedItems.OfType<DesignerItemViewModelBase>()
|
||||||
|
where item.ParentId == Guid.Empty
|
||||||
|
select item;
|
||||||
|
|
||||||
|
Rect rect = GetBoundingRectangle(items);
|
||||||
|
|
||||||
|
GroupDesignerItemViewModel groupItem = new GroupDesignerItemViewModel();
|
||||||
|
groupItem.IsGroup = true;
|
||||||
|
groupItem.ItemWidth = rect.Width;
|
||||||
|
groupItem.ItemHeight = rect.Height;
|
||||||
|
groupItem.Left = rect.Left;
|
||||||
|
groupItem.Top = rect.Top;
|
||||||
|
groupItem.ZIndex = Items.Count;
|
||||||
|
|
||||||
|
DirectAddItemCommand.Execute(groupItem);
|
||||||
|
|
||||||
|
foreach (DesignerItemViewModelBase item in items)
|
||||||
|
item.ParentId = groupItem.Id;
|
||||||
|
|
||||||
|
ClearSelectedItemsCommand.Execute(null);
|
||||||
|
//groupItem.IsSelected = true;
|
||||||
|
SelectionService.AddToSelection(groupItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteUngroupCommand(object parameter)
|
||||||
|
{
|
||||||
|
var groups = (from item in SelectedItems.OfType<DesignerItemViewModelBase>()
|
||||||
|
where item.IsGroup && item.ParentId == Guid.Empty
|
||||||
|
select item).ToArray();
|
||||||
|
|
||||||
|
foreach (DesignerItemViewModelBase groupRoot in groups)
|
||||||
|
{
|
||||||
|
var children = from child in SelectedItems.OfType<DesignerItemViewModelBase>()
|
||||||
|
where child.ParentId == groupRoot.Id
|
||||||
|
select child;
|
||||||
|
|
||||||
|
foreach (DesignerItemViewModelBase child in children)
|
||||||
|
child.ParentId = Guid.Empty;
|
||||||
|
|
||||||
|
RemoveItemCommand.Execute(groupRoot);
|
||||||
|
UpdateZIndex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteLockCommand(object parameter)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteUnlockCommand(object parameter)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public bool BelongToSameGroup(IGroupable item1, IGroupable item2)
|
public bool BelongToSameGroup(IGroupable item1, IGroupable item2)
|
||||||
{
|
{
|
||||||
IGroupable root1 = SelectionService.GetGroupRoot(item1);
|
IGroupable root1 = SelectionService.GetGroupRoot(item1);
|
||||||
|
|||||||
@@ -105,6 +105,75 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
SimpleCommand CopyCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand PasteCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand CutCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand DeleteCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand LeftMoveCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand RightMoveCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand UpMoveCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand DownMoveCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand CenterMoveCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand SameSizeCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand SameWidthCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand SameHeightCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand SameAngleCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand GroupCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand UngroupCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand LockCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
SimpleCommand UnlockCommand
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
SimpleCommand UndoCommand
|
SimpleCommand UndoCommand
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|||||||
@@ -30,6 +30,20 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GifImageItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return new MediaDesignerItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type ToXmlType()
|
||||||
|
{
|
||||||
|
return typeof(MediaDesignerItem);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,21 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ImageItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return new ImageDesignerItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type ToXmlType()
|
||||||
|
{
|
||||||
|
return typeof(ImageDesignerItem);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|||||||
@@ -19,6 +19,21 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MediaItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return new MediaDesignerItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type ToXmlType()
|
||||||
|
{
|
||||||
|
return typeof(MediaDesignerItem);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|||||||
@@ -5,17 +5,27 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
public class TextDesignerItemViewModel : DesignerItemViewModelBase
|
public class TextDesignerItemViewModel : DesignerItemViewModelBase
|
||||||
{
|
{
|
||||||
|
public TextDesignerItemViewModel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public TextDesignerItemViewModel(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
public TextDesignerItemViewModel(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextDesignerItemViewModel()
|
public TextDesignerItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return new TextDesignerItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
public VideoItemViewModel(IDiagramViewModel parent, MediaDesignerItem designer) : base(parent, designer)
|
public VideoItemViewModel(IDiagramViewModel parent, MediaDesignerItem designer) : base(parent, designer)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public VideoItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,15 @@ namespace AIStudio.Wpf.DiagramHelper.Extensions.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BarcodeDesignerItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return new DesignerItemBase(this, Format.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|||||||
@@ -9,13 +9,17 @@ namespace AIStudio.Wpf.DiagramHelper.Extensions.ViewModels
|
|||||||
public class OutLineTextDesignerItemViewModel : TextDesignerItemViewModel
|
public class OutLineTextDesignerItemViewModel : TextDesignerItemViewModel
|
||||||
{
|
{
|
||||||
private IUIVisualizerService visualiserService;
|
private IUIVisualizerService visualiserService;
|
||||||
|
public OutLineTextDesignerItemViewModel() : base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public OutLineTextDesignerItemViewModel(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
public OutLineTextDesignerItemViewModel(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OutLineTextDesignerItemViewModel() : base()
|
public OutLineTextDesignerItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using AIStudio.Wpf.DiagramDesigner;
|
using System;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner;
|
||||||
|
using AIStudio.Wpf.DiagramHelper.Extensions.Models;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramHelper.Extensions.ViewModels
|
namespace AIStudio.Wpf.DiagramHelper.Extensions.ViewModels
|
||||||
{
|
{
|
||||||
@@ -9,11 +11,27 @@ namespace AIStudio.Wpf.DiagramHelper.Extensions.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PathItemViewModel(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
public PathItemViewModel(IDiagramViewModel parent, PathDesignerItem designer) : base(parent, designer)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PathItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return new PathDesignerItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type ToXmlType()
|
||||||
|
{
|
||||||
|
return typeof(PathDesignerItem);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using AIStudio.Wpf.DiagramHelper.Services;
|
using AIStudio.Wpf.DiagramHelper.Services;
|
||||||
using AIStudio.Wpf.DiagramDesigner;
|
using AIStudio.Wpf.DiagramDesigner;
|
||||||
using AIStudio.Wpf.DiagramHelper.Extensions.Models;
|
using AIStudio.Wpf.DiagramHelper.Extensions.Models;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramHelper.Extensions.ViewModels
|
namespace AIStudio.Wpf.DiagramHelper.Extensions.ViewModels
|
||||||
{
|
{
|
||||||
@@ -8,16 +9,32 @@ namespace AIStudio.Wpf.DiagramHelper.Extensions.ViewModels
|
|||||||
{
|
{
|
||||||
private IUIVisualizerService visualiserService;
|
private IUIVisualizerService visualiserService;
|
||||||
|
|
||||||
|
public PersistDesignerItemViewModel() : base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public PersistDesignerItemViewModel(IDiagramViewModel parent, PersistDesignerItem designer) : base(parent, designer)
|
public PersistDesignerItemViewModel(IDiagramViewModel parent, PersistDesignerItem designer) : base(parent, designer)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PersistDesignerItemViewModel() : base()
|
public PersistDesignerItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return new PersistDesignerItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override Type ToXmlType()
|
||||||
|
{
|
||||||
|
return typeof(PersistDesignerItem);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|||||||
@@ -9,16 +9,31 @@ namespace AIStudio.Wpf.DiagramHelper.Extensions.ViewModels
|
|||||||
{
|
{
|
||||||
private IUIVisualizerService visualiserService;
|
private IUIVisualizerService visualiserService;
|
||||||
|
|
||||||
|
public SettingsDesignerItemViewModel() : base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public SettingsDesignerItemViewModel(IDiagramViewModel parent, SettingsDesignerItem designer) : base(parent, designer)
|
public SettingsDesignerItemViewModel(IDiagramViewModel parent, SettingsDesignerItem designer) : base(parent, designer)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SettingsDesignerItemViewModel() : base()
|
public SettingsDesignerItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return new SettingsDesignerItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type ToXmlType()
|
||||||
|
{
|
||||||
|
return typeof(SettingsDesignerItem);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|||||||
@@ -14,5 +14,10 @@ namespace AIStudio.Wpf.DiagramHelper.Extensions.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SvgDesignerItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.CodeDom.Compiler;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Input;
|
||||||
using AIStudio.Wpf.DiagramDesigner;
|
using AIStudio.Wpf.DiagramDesigner;
|
||||||
using AIStudio.Wpf.Flowchart.Models;
|
using AIStudio.Wpf.Flowchart.Models;
|
||||||
|
|
||||||
@@ -246,5 +248,30 @@ namespace AIStudio.Wpf.Flowchart.Controls
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnPreviewKeyDown(e);
|
||||||
|
|
||||||
|
bool executed = true;
|
||||||
|
var para = e.KeyboardDevice.Modifiers == ModifierKeys.None ? e.Key.ToString() : e.KeyboardDevice.Modifiers.ToString() + "+" + e.Key.ToString();
|
||||||
|
|
||||||
|
switch (para)
|
||||||
|
{
|
||||||
|
case "Control+A": _diagramViewModel.SelectAllCommand.Execute(null); break;
|
||||||
|
case "Control+C": _diagramViewModel.CopyCommand.Execute(null); break;
|
||||||
|
case "Control+V": _diagramViewModel.PasteCommand.Execute(null); break;
|
||||||
|
case "Control+X": _diagramViewModel.CutCommand.Execute(null); break;
|
||||||
|
case "Control+Z": _diagramViewModel.UndoCommand.Execute(null); break;
|
||||||
|
case "Control+Y": _diagramViewModel.RedoCommand.Execute(null); break;
|
||||||
|
case "Delete": _diagramViewModel.DeleteCommand.Execute(null); break;
|
||||||
|
case "Left": _diagramViewModel.LeftMoveCommand.Execute(null); break;
|
||||||
|
case "Right": _diagramViewModel.RightMoveCommand.Execute(null); break;
|
||||||
|
case "Up": _diagramViewModel.UpMoveCommand.Execute(null); break;
|
||||||
|
case "Down": _diagramViewModel.DownMoveCommand.Execute(null); break;
|
||||||
|
default: executed = false; break;
|
||||||
|
}
|
||||||
|
e.Handled = executed;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace AIStudio.Wpf.Flowchart.Models
|
|||||||
}
|
}
|
||||||
|
|
||||||
diagramNode.Id = nodeModel.Id.ToString();
|
diagramNode.Id = nodeModel.Id.ToString();
|
||||||
if (nodeModel.ParentId != new Guid())
|
if (nodeModel.ParentId != Guid.Empty)
|
||||||
{
|
{
|
||||||
diagramNode.ParentId = nodeModel.ParentId.ToString();
|
diagramNode.ParentId = nodeModel.ParentId.ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using AIStudio.Wpf.Flowchart.Models;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using AIStudio.Wpf.DiagramDesigner;
|
using AIStudio.Wpf.DiagramDesigner;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.Flowchart.ViewModels
|
namespace AIStudio.Wpf.Flowchart.ViewModels
|
||||||
{
|
{
|
||||||
@@ -22,6 +23,21 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FlowNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return new FlowNodeDesignerItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type ToXmlType()
|
||||||
|
{
|
||||||
|
return typeof(FlowNodeDesignerItem);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
@@ -121,6 +137,11 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StartFlowNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EndFlowNode : FlowNode
|
public class EndFlowNode : FlowNode
|
||||||
@@ -134,6 +155,11 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EndFlowNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DecideFlowNode : FlowNode
|
public class DecideFlowNode : FlowNode
|
||||||
@@ -147,6 +173,11 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DecideFlowNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class COBeginFlowNode : FlowNode
|
public class COBeginFlowNode : FlowNode
|
||||||
@@ -160,6 +191,11 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public COBeginFlowNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class COEndFlowNode : FlowNode
|
public class COEndFlowNode : FlowNode
|
||||||
@@ -173,5 +209,10 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public COEndFlowNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MiddleFlowNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private List<string> _userIds = new List<string>();
|
private List<string> _userIds = new List<string>();
|
||||||
[Browsable(true)]
|
[Browsable(true)]
|
||||||
[StyleName("UserIdsStyle")]
|
[StyleName("UserIdsStyle")]
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LogicalGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
@@ -67,6 +72,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
public AddGateItemViewModel(IDiagramViewModel parent, LogicalGateDesignerItemBase designer) : base(parent, designer)
|
public AddGateItemViewModel(IDiagramViewModel parent, LogicalGateDesignerItemBase designer) : base(parent, designer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AddGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SubtractGateItemViewModel : LogicalGateItemViewModel
|
public class SubtractGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -78,6 +88,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
public SubtractGateItemViewModel(IDiagramViewModel parent, LogicalGateDesignerItemBase designer) : base(parent, designer)
|
public SubtractGateItemViewModel(IDiagramViewModel parent, LogicalGateDesignerItemBase designer) : base(parent, designer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SubtractGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MultiplyGateItemViewModel : LogicalGateItemViewModel
|
public class MultiplyGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -89,6 +104,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
public MultiplyGateItemViewModel(IDiagramViewModel parent, LogicalGateDesignerItemBase designer) : base(parent, designer)
|
public MultiplyGateItemViewModel(IDiagramViewModel parent, LogicalGateDesignerItemBase designer) : base(parent, designer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MultiplyGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DivideGateItemViewModel : LogicalGateItemViewModel
|
public class DivideGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -101,6 +121,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
public DivideGateItemViewModel(IDiagramViewModel parent, LogicalGateDesignerItemBase designer) : base(parent, designer)
|
public DivideGateItemViewModel(IDiagramViewModel parent, LogicalGateDesignerItemBase designer) : base(parent, designer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DivideGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AverageGateItemViewModel : LogicalGateItemViewModel
|
public class AverageGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -114,6 +139,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AverageGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MODGateItemViewModel : LogicalGateItemViewModel
|
public class MODGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -127,6 +157,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MODGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ANDGateItemViewModel : LogicalGateItemViewModel
|
public class ANDGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -140,6 +175,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ANDGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ORGateItemViewModel : LogicalGateItemViewModel
|
public class ORGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -153,6 +193,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ORGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class XORGateItemViewModel : LogicalGateItemViewModel
|
public class XORGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -166,6 +211,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public XORGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NOTGateItemViewModel : LogicalGateItemViewModel
|
public class NOTGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -179,6 +229,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NOTGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SHLGateItemViewModel : LogicalGateItemViewModel
|
public class SHLGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -192,6 +247,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SHLGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SHRGateItemViewModel : LogicalGateItemViewModel
|
public class SHRGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -205,6 +265,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SHRGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ROLGateItemViewModel : LogicalGateItemViewModel
|
public class ROLGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -218,6 +283,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ROLGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RORGateItemViewModel : LogicalGateItemViewModel
|
public class RORGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -231,6 +301,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RORGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SELGateItemViewModel : LogicalGateItemViewModel
|
public class SELGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -244,6 +319,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SELGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MAXGateItemViewModel : LogicalGateItemViewModel
|
public class MAXGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -257,6 +337,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MAXGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MINGateItemViewModel : LogicalGateItemViewModel
|
public class MINGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -270,6 +355,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MINGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LIMITGateItemViewModel : LogicalGateItemViewModel
|
public class LIMITGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -283,6 +373,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LIMITGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GTGateItemViewModel : LogicalGateItemViewModel
|
public class GTGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -296,6 +391,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GTGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LTGateItemViewModel : LogicalGateItemViewModel
|
public class LTGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -309,6 +409,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LTGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GEGateItemViewModel : LogicalGateItemViewModel
|
public class GEGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -322,6 +427,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GEGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LEGateItemViewModel : LogicalGateItemViewModel
|
public class LEGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -335,6 +445,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LEGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EQGateItemViewModel : LogicalGateItemViewModel
|
public class EQGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -348,6 +463,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EQGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NEGateItemViewModel : LogicalGateItemViewModel
|
public class NEGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -361,6 +481,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NEGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ABSGateItemViewModel : LogicalGateItemViewModel
|
public class ABSGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -374,6 +499,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ABSGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SQRTGateItemViewModel : LogicalGateItemViewModel
|
public class SQRTGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -387,6 +517,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SQRTGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LNGateItemViewModel : LogicalGateItemViewModel
|
public class LNGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -400,6 +535,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LNGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LOGGateItemViewModel : LogicalGateItemViewModel
|
public class LOGGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -413,6 +553,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LOGGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EXPGateItemViewModel : LogicalGateItemViewModel
|
public class EXPGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -426,6 +571,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EXPGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SINGateItemViewModel : LogicalGateItemViewModel
|
public class SINGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -439,6 +589,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SINGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class COSGateItemViewModel : LogicalGateItemViewModel
|
public class COSGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -452,6 +607,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public COSGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TANGateItemViewModel : LogicalGateItemViewModel
|
public class TANGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -465,6 +625,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TANGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ASINGateItemViewModel : LogicalGateItemViewModel
|
public class ASINGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -478,6 +643,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ASINGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ACOSGateItemViewModel : LogicalGateItemViewModel
|
public class ACOSGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -491,6 +661,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ACOSGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ATANGateItemViewModel : LogicalGateItemViewModel
|
public class ATANGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -504,6 +679,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ATANGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EXPTGateItemViewModel : LogicalGateItemViewModel
|
public class EXPTGateItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -517,6 +697,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EXPTGateItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConstantDesignerItemViewModel : LogicalGateItemViewModel
|
public class ConstantDesignerItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -531,6 +716,10 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConstantDesignerItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InputItemViewModel : LogicalGateItemViewModel
|
public class InputItemViewModel : LogicalGateItemViewModel
|
||||||
@@ -545,6 +734,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public InputItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel parent, SelectableDesignerItemBase designerbase)
|
protected override void LoadDesignerItemViewModel(IDiagramViewModel parent, SelectableDesignerItemBase designerbase)
|
||||||
{
|
{
|
||||||
base.LoadDesignerItemViewModel(parent, designerbase);
|
base.LoadDesignerItemViewModel(parent, designerbase);
|
||||||
@@ -594,6 +788,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OutputItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel parent, SelectableDesignerItemBase designerbase)
|
protected override void LoadDesignerItemViewModel(IDiagramViewModel parent, SelectableDesignerItemBase designerbase)
|
||||||
{
|
{
|
||||||
base.LoadDesignerItemViewModel(parent, designerbase);
|
base.LoadDesignerItemViewModel(parent, designerbase);
|
||||||
@@ -650,6 +849,11 @@ namespace AIStudio.Wpf.Logical.ViewModels
|
|||||||
BuildMenuOptions();
|
BuildMenuOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TimerDesignerItemViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
BuildMenuOptions();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
MenuItemCommand = new SimpleCommand(ExecuteMenuItemCommand);
|
MenuItemCommand = new SimpleCommand(ExecuteMenuItemCommand);
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SFCActionNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private LinkPoint _linkPoint;
|
private LinkPoint _linkPoint;
|
||||||
public LinkPoint LinkPoint
|
public LinkPoint LinkPoint
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SFCCOBeginNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override void ExecuteAddTopInput(object parameter)
|
public override void ExecuteAddTopInput(object parameter)
|
||||||
{
|
{
|
||||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top, true);
|
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top, true);
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SFCCOEndNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override void ExecuteAddTopInput(object parameter)
|
public override void ExecuteAddTopInput(object parameter)
|
||||||
{
|
{
|
||||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top, true);
|
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top, true);
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SFCConditionNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
using AIStudio.Wpf.DiagramHelper;
|
using System;
|
||||||
using AIStudio.Wpf.DiagramHelper.Services;
|
|
||||||
using AIStudio.Wpf.SFC.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using AIStudio.Wpf.DiagramDesigner;
|
using AIStudio.Wpf.DiagramDesigner;
|
||||||
|
using AIStudio.Wpf.DiagramHelper;
|
||||||
|
using AIStudio.Wpf.DiagramHelper.Services;
|
||||||
|
using AIStudio.Wpf.SFC.Models;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.SFC.ViewModels
|
namespace AIStudio.Wpf.SFC.ViewModels
|
||||||
{
|
{
|
||||||
@@ -28,6 +27,21 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SFCNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SelectableDesignerItemBase ToXmlObject()
|
||||||
|
{
|
||||||
|
return new SFCNodeDesignerItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type ToXmlType()
|
||||||
|
{
|
||||||
|
return typeof(SFCNodeDesignerItem);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
IsInnerConnector = true;
|
IsInnerConnector = true;
|
||||||
|
|||||||
@@ -18,5 +18,10 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SFCNodeNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,10 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
public SFCStartNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
public SFCStartNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SFCStartNode(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
public Simulate_ListViewModel(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
public Simulate_ListViewModel(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Simulate_ListViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Simulate_SolenoidViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Simulate_StartViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private LinkPoint linkPoint;
|
private LinkPoint linkPoint;
|
||||||
public LinkPoint LinkPoint
|
public LinkPoint LinkPoint
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Simulate_TankViewModel(IDiagramViewModel parent, string json) : base(parent, json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public override void ExecuteAddLeftInput(object parameter)
|
public override void ExecuteAddLeftInput(object parameter)
|
||||||
{
|
{
|
||||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Left, true);
|
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Left, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user