mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-14 21:26:35 +08:00
线条文本可以保存了
This commit is contained in:
@@ -287,7 +287,13 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
ConnectorOrientation sinkConnectorOrientation = connection.SinkOrientation;
|
||||
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connection.Id, sinkItem, sinkConnectorOrientation, connection.SinkXRatio, connection.SinkYRatio, connection.SinkInnerPoint);
|
||||
|
||||
|
||||
ConnectorViewModel connectionVM = new ConnectorViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connection, connection.VectorLineDrawMode);
|
||||
DesignerItemViewModelBase textItem = viewModel.Items.OfType<DesignerItemViewModelBase>().Single(x => x.ParentId == connection.Id);
|
||||
if (textItem != null)
|
||||
{
|
||||
connectionVM.OutTextItem = textItem;
|
||||
}
|
||||
viewModel.Items.Add(connectionVM);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,13 +69,13 @@ namespace AIStudio.Wpf.DiagramDesigner.Test.ViewModels
|
||||
ToolBoxViewModel = new ToolBoxViewModel();
|
||||
DiagramViewModel = new DiagramViewModel();
|
||||
DiagramViewModel.ShowGrid = true;
|
||||
DiagramViewModel.GridCellSize = new Size(100, 60);
|
||||
DiagramViewModel.GridCellSize = new Size(100, 100);
|
||||
DiagramViewModel.GridMargin = 0d;
|
||||
DiagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
|
||||
DiagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
|
||||
DiagramViewModel.PageSizeType = PageSizeType.Custom;
|
||||
DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
|
||||
DiagramViewModel.VectorLineDrawMode = DrawMode.BoundaryConnectingLine;
|
||||
DiagramViewModel.DrawModeViewModel = new DrawModeViewModel() { VectorLineDrawMode = DrawMode.BoundaryConnectingLine };
|
||||
|
||||
DiagramViewModel.PropertyChanged += DiagramViewModel_PropertyChanged;
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_viewModel.VectorLineDrawMode != null)
|
||||
if (_viewModel.DrawModeViewModel?.VectorLineDrawMode != null)
|
||||
{
|
||||
return _viewModel.VectorLineDrawMode.Value;
|
||||
return _viewModel.DrawModeViewModel.VectorLineDrawMode;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -203,7 +203,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Rect rectangleBounds = sourceConnector.TransformToVisual(this).TransformBounds(new Rect(sourceConnector.RenderSize));
|
||||
Point point = new Point(rectangleBounds.Left + (rectangleBounds.Width / 2),
|
||||
rectangleBounds.Bottom + (rectangleBounds.Height / 2));
|
||||
partialConnection = new ConnectorViewModel(sourceDataItem, new PartCreatedConnectionInfo(point), VectorLineDrawMode);
|
||||
partialConnection = new ConnectorViewModel(_viewModel, sourceDataItem, new PartCreatedConnectionInfo(point), VectorLineDrawMode);
|
||||
|
||||
_viewModel.DirectAddItemCommand.Execute(partialConnection);
|
||||
}
|
||||
}
|
||||
@@ -224,7 +225,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Rect rectangleBounds = new Rect(sourceConnectorInfo.DataItem.Left, sourceConnectorInfo.DataItem.Top, 3, 3);
|
||||
Point point = new Point(rectangleBounds.Left + (rectangleBounds.Width / 2),
|
||||
rectangleBounds.Bottom + (rectangleBounds.Height / 2));
|
||||
partialConnection = new ConnectorViewModel(sourceConnectorInfo, new PartCreatedConnectionInfo(point), VectorLineDrawMode);
|
||||
partialConnection = new ConnectorViewModel(_viewModel, sourceConnectorInfo, new PartCreatedConnectionInfo(point), VectorLineDrawMode);
|
||||
_viewModel.DirectAddItemCommand.Execute(partialConnection);
|
||||
}
|
||||
}
|
||||
@@ -361,7 +362,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
int indexOfLastTempConnection = sinkDataItem.DataItem.Parent.Items.Count - 1;
|
||||
sinkDataItem.DataItem.Parent.DirectRemoveItemCommand.Execute(
|
||||
sinkDataItem.DataItem.Parent.Items[indexOfLastTempConnection]);
|
||||
sinkDataItem.DataItem.Parent.AddItemCommand.Execute(new ConnectorViewModel(sourceDataItem, sinkDataItem, VectorLineDrawMode));
|
||||
sinkDataItem.DataItem.Parent.AddItemCommand.Execute(new ConnectorViewModel(_viewModel, sourceDataItem, sinkDataItem, VectorLineDrawMode));
|
||||
}
|
||||
else if (_service.DrawModeViewModel.GetDrawMode() == DrawMode.ConnectingLine && connectorsHit.Count() == 1)
|
||||
{
|
||||
@@ -372,7 +373,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
_viewModel.DirectRemoveItemCommand.Execute(_viewModel.Items[indexOfLastTempConnection]);
|
||||
_viewModel.DirectAddItemCommand.Execute(pointItemView);
|
||||
|
||||
var connector = new ConnectorViewModel(sourceDataItem, sinkDataItem, VectorLineDrawMode);
|
||||
var connector = new ConnectorViewModel(_viewModel, sourceDataItem, sinkDataItem, VectorLineDrawMode);
|
||||
_viewModel.AddItemCommand.Execute(connector);
|
||||
|
||||
sourceDataItem.DataItem.ZIndex++;
|
||||
|
||||
@@ -18,8 +18,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
}
|
||||
|
||||
public ConnectorViewModel(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode vectorLineDrawMode)
|
||||
public ConnectorViewModel(IDiagramViewModel parent, FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode vectorLineDrawMode)
|
||||
{
|
||||
Parent = parent;
|
||||
VectorLineDrawMode = vectorLineDrawMode;
|
||||
Init(sourceConnectorInfo, sinkConnectorInfo);
|
||||
}
|
||||
@@ -126,10 +127,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
private set
|
||||
{
|
||||
Rect oldarea = _area;
|
||||
if (SetProperty(ref _area, value))
|
||||
{
|
||||
UpdateConnectionPoints();
|
||||
OutTextItemLocation(_area, value);
|
||||
OutTextItemLocation(oldarea, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,6 +141,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
get; set;
|
||||
}
|
||||
|
||||
public virtual Dictionary<string, string> PropertiesSetting
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Dictionary<string, string>()
|
||||
{
|
||||
{ "Text","文本" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public ConnectorInfo ConnectorInfo(ConnectorOrientation orientation, double left, double top, double width, double height, Point position)
|
||||
{
|
||||
|
||||
@@ -256,6 +269,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
this.SinkConnectorInfo = sinkConnectorInfo;
|
||||
DeleteConnectionCommand = new SimpleCommand(DeleteConnection);
|
||||
|
||||
if (Parent != null && Parent.ColorViewModel != null)
|
||||
{
|
||||
this.ColorViewModel = CopyHelper.Mapper(Parent.ColorViewModel);
|
||||
}
|
||||
if (sinkConnectorInfo is FullyCreatedConnectorInfo sink && sink.DataItem.ShowArrow == false)
|
||||
{
|
||||
this.ColorViewModel.RightArrowPathStyle = ArrowPathStyle.None;
|
||||
|
||||
@@ -32,7 +32,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
get; set;
|
||||
}
|
||||
|
||||
public DrawMode? VectorLineDrawMode
|
||||
public IDrawModeViewModel DrawModeViewModel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public IColorViewModel ColorViewModel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class FullyCreatedConnectorInfo : ConnectorInfoBase
|
||||
{
|
||||
|
||||
|
||||
private List<CinchMenuItem> menuOptions;
|
||||
|
||||
public FullyCreatedConnectorInfo(DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint=false, ValueTypePoint valueTypePoint = 0)
|
||||
public FullyCreatedConnectorInfo(DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, ValueTypePoint valueTypePoint = 0)
|
||||
: base(orientation)
|
||||
{
|
||||
this.DataItem = dataItem;
|
||||
@@ -66,7 +66,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
menuOptions.Add(delete);
|
||||
}
|
||||
|
||||
public DesignerItemViewModelBase DataItem { get; private set; }
|
||||
public DesignerItemViewModelBase DataItem
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
private bool _showConnectors = false;
|
||||
public bool ShowConnectors
|
||||
@@ -77,14 +80,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _showConnectors, value);
|
||||
SetProperty(ref _showConnectors, value);
|
||||
}
|
||||
}
|
||||
|
||||
private double _xRatio;
|
||||
public double XRatio
|
||||
{
|
||||
get { return _xRatio; }
|
||||
get
|
||||
{
|
||||
return _xRatio;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _xRatio, value);
|
||||
@@ -94,29 +100,50 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
private double _yRatio;
|
||||
public double YRatio
|
||||
{
|
||||
get { return _yRatio; }
|
||||
get
|
||||
{
|
||||
return _yRatio;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _yRatio, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInnerPoint { get; set; }
|
||||
public bool IsInnerPoint
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public ValueTypePoint _valueTypePoint;
|
||||
public ValueTypePoint ValueTypePoint
|
||||
{
|
||||
get { return _valueTypePoint; }
|
||||
get
|
||||
{
|
||||
return _valueTypePoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _valueTypePoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleCommand DeleteCommand { get; private set; }
|
||||
public SimpleCommand MenuItemCommand { get; private set; }
|
||||
public SimpleCommand DeleteCommand
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
public SimpleCommand MenuItemCommand
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public IEnumerable<CinchMenuItem> MenuOptions { get { return menuOptions; } }
|
||||
public IEnumerable<CinchMenuItem> MenuOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
return menuOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,59 +11,190 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public interface IDiagramViewModel
|
||||
{
|
||||
string Name { get; set; }
|
||||
List<SelectableDesignerItemViewModelBase> SelectedItems { get; }
|
||||
ObservableCollection<SelectableDesignerItemViewModelBase> Items { get; }
|
||||
SelectionService SelectionService { get; }
|
||||
string Name
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
List<SelectableDesignerItemViewModelBase> SelectedItems
|
||||
{
|
||||
get;
|
||||
}
|
||||
ObservableCollection<SelectableDesignerItemViewModelBase> Items
|
||||
{
|
||||
get;
|
||||
}
|
||||
SelectionService SelectionService
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
SimpleCommand CreateNewDiagramCommand { get; }
|
||||
SimpleCommand DirectAddItemCommand { get; }
|
||||
SimpleCommand AddItemCommand { get; }
|
||||
SimpleCommand RemoveItemCommand { get; }
|
||||
SimpleCommand DirectRemoveItemCommand { get; }
|
||||
SimpleCommand ClearSelectedItemsCommand { get; }
|
||||
SimpleCommand AlignTopCommand { get; }
|
||||
SimpleCommand AlignVerticalCentersCommand { get; }
|
||||
SimpleCommand AlignBottomCommand { get; }
|
||||
SimpleCommand AlignLeftCommand { get; }
|
||||
SimpleCommand AlignHorizontalCentersCommand { get; }
|
||||
SimpleCommand AlignRightCommand { get; }
|
||||
SimpleCommand BringForwardCommand { get; }
|
||||
SimpleCommand BringToFrontCommand { get; }
|
||||
SimpleCommand SendBackwardCommand { get; }
|
||||
SimpleCommand SendToBackCommand { get; }
|
||||
SimpleCommand CreateNewDiagramCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand DirectAddItemCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand AddItemCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand RemoveItemCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand DirectRemoveItemCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand ClearSelectedItemsCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand AlignTopCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand AlignVerticalCentersCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand AlignBottomCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand AlignLeftCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand AlignHorizontalCentersCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand AlignRightCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand BringForwardCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand BringToFrontCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand SendBackwardCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand SendToBackCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
SimpleCommand DistributeHorizontalCommand { get; }
|
||||
SimpleCommand DistributeVerticalCommand { get; }
|
||||
SimpleCommand SelectAllCommand { get; }
|
||||
SimpleCommand UndoCommand { get; }
|
||||
SimpleCommand RedoCommand { get; }
|
||||
SimpleCommand DistributeHorizontalCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand DistributeVerticalCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand SelectAllCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand UndoCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
SimpleCommand RedoCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
Func<SelectableDesignerItemViewModelBase, bool> OutAddVerify { get; set; }
|
||||
Func<SelectableDesignerItemViewModelBase, bool> OutAddVerify
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
void ClearSelectedItems();
|
||||
bool BelongToSameGroup(IGroupable item1, IGroupable item2);
|
||||
Rect GetBoundingRectangle(IEnumerable<DesignerItemViewModelBase> items);
|
||||
void UpdateZIndex();
|
||||
|
||||
bool IsReadOnly{ get; set; }
|
||||
bool IsLoading{get;set;}
|
||||
Size PageSize { get; set; }
|
||||
PageSizeType PageSizeType { get; set; }
|
||||
bool ShowGrid { get; set; }
|
||||
Size GridCellSize { get; set; }
|
||||
PageSizeOrientation PageSizeOrientation { get; set; }
|
||||
CellHorizontalAlignment CellHorizontalAlignment { get; set; }
|
||||
CellVerticalAlignment CellVerticalAlignment { get; set; }
|
||||
double GridMargin { get; set; }
|
||||
Color GridColor { get; set; }
|
||||
DiagramType DiagramType { get; set; }
|
||||
bool IsReadOnly
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
bool IsLoading
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
Size PageSize
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
PageSizeType PageSizeType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
bool ShowGrid
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
Size GridCellSize
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
PageSizeOrientation PageSizeOrientation
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
CellHorizontalAlignment CellHorizontalAlignment
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
CellVerticalAlignment CellVerticalAlignment
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
double GridMargin
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
Color GridColor
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
DiagramType DiagramType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
Point CurrentPoint { get; set; }
|
||||
Color CurrentColor { get; set; }
|
||||
//如果这个赋值了,优先用这个的
|
||||
DrawMode? VectorLineDrawMode { get; set; }
|
||||
Point CurrentPoint
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
Color CurrentColor
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
#region 如果这个赋值了,优先用这个的
|
||||
IDrawModeViewModel DrawModeViewModel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
IColorViewModel ColorViewModel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
#endregion
|
||||
//用于wpf大小与物理像素之间转换
|
||||
double ScreenScale { get; set; }
|
||||
double ScreenScale
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
void SetScreenScale();
|
||||
|
||||
|
||||
@@ -20,9 +20,10 @@
|
||||
<!-- ToolBox Control -->
|
||||
<ContentControl Template="{Binding ToolBox,RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
|
||||
|
||||
<!-- Diagram Control -->
|
||||
<dd:DiagramControl Grid.Column="1" x:Name="PART_DiagramControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||
|
||||
<ScrollViewer Grid.Column="1">
|
||||
<!-- Diagram Control -->
|
||||
<dd:DiagramControl x:Name="PART_DiagramControl" MinWidth="1000" MinHeight="1000" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||
</ScrollViewer>
|
||||
<ContentControl Grid.Column="2" x:Name="properity" Template="{Binding PropertiesBox,RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
|
||||
|
||||
</Grid>
|
||||
@@ -42,7 +43,7 @@
|
||||
<Setter Property="PropertiesBox">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Control">
|
||||
<dd:PropertiesView
|
||||
<dd:PropertiesView CustomSetting="True"
|
||||
SelectedObject="{Binding Path=SelectedObject,RelativeSource={RelativeSource AncestorType={x:Type controls:FlowchartEditor}}}"
|
||||
Width="200">
|
||||
<dd:PropertiesView.Resources>
|
||||
|
||||
@@ -37,7 +37,8 @@ namespace AIStudio.Wpf.Flowchart.Controls
|
||||
_diagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
|
||||
_diagramViewModel.PageSizeType = PageSizeType.Custom;
|
||||
_diagramViewModel.PageSize = new Size(double.NaN, double.NaN);
|
||||
_diagramViewModel.VectorLineDrawMode = DrawMode.BoundaryConnectingLine;
|
||||
_diagramViewModel.ColorViewModel = new ColorViewModel() { LineWidth = 2 };
|
||||
_diagramViewModel.DrawModeViewModel = new DrawModeViewModel() { VectorLineDrawMode = DrawMode.BoundaryConnectingLine };
|
||||
|
||||
_diagramViewModel.PropertyChanged += DiagramViewModel_PropertyChanged;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,17 @@ namespace AIStudio.Wpf.Flowchart.Models
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the parent identifier.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The parent identifier.
|
||||
/// </value>
|
||||
public string ParentId
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace AIStudio.Wpf.Flowchart.Models
|
||||
public static string ToJson(this IDiagramViewModel diagram)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(new {
|
||||
Nodes = diagram.Items.OfType<DesignerItemViewModelBase>().Select(p => p.ToDiagramNode()),
|
||||
Links = diagram.Items.OfType<ConnectorViewModel>().Select(p => p.ToDiagramLink())
|
||||
Nodes = diagram.Items.OfType<DesignerItemViewModelBase>().Select(p => p.ToDiagramNode()).Where(p => p != null),
|
||||
Links = diagram.Items.OfType<ConnectorViewModel>().Select(p => p.ToDiagramLink()).Where(p => p != null)
|
||||
}, new JsonSerializerSettings
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
@@ -45,10 +45,14 @@ namespace AIStudio.Wpf.Flowchart.Models
|
||||
}
|
||||
else
|
||||
{
|
||||
diagramNode = new DiagramNode();
|
||||
return null;
|
||||
}
|
||||
|
||||
diagramNode.Id = nodeModel.Id.ToString();
|
||||
if (nodeModel.ParentId != new Guid())
|
||||
{
|
||||
diagramNode.ParentId = nodeModel.ParentId.ToString();
|
||||
}
|
||||
diagramNode.Label = nodeModel.Text;
|
||||
diagramNode.Width = nodeModel.ItemWidth * nodeModel.Parent.ScreenScale;
|
||||
diagramNode.Height = nodeModel.ItemHeight * nodeModel.Parent.ScreenScale;
|
||||
@@ -69,6 +73,7 @@ namespace AIStudio.Wpf.Flowchart.Models
|
||||
diagramLink.Color = SerializeHelper.SerializeColor(linkModel.ColorViewModel.LineColor.Color);
|
||||
diagramLink.SelectedColor = SerializeHelper.SerializeColor(Colors.Black);
|
||||
diagramLink.Width = linkModel.ColorViewModel.LineWidth;
|
||||
diagramLink.Label = linkModel.Text;
|
||||
|
||||
if (linkModel.SinkConnectorInfo is FullyCreatedConnectorInfo sinkConnector)
|
||||
{
|
||||
@@ -88,6 +93,10 @@ namespace AIStudio.Wpf.Flowchart.Models
|
||||
diagramLink.SourcePortAlignment = linkModel.SourceConnectorInfo.Orientation.ToString();
|
||||
diagramLink.TargetPortAlignment = sinkConnector.Orientation.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return diagramLink;
|
||||
}
|
||||
#endregion
|
||||
@@ -196,6 +205,10 @@ namespace AIStudio.Wpf.Flowchart.Models
|
||||
}
|
||||
|
||||
nodeModel.Id = new Guid(diagramNode.Id);
|
||||
if (!string.IsNullOrEmpty(diagramNode.ParentId))
|
||||
{
|
||||
nodeModel.ParentId = new Guid(diagramNode.ParentId);
|
||||
}
|
||||
nodeModel.Parent = diagram;
|
||||
nodeModel.Text = diagramNode.Label;
|
||||
nodeModel.ItemWidth = diagramNode.Width / diagram.ScreenScale;
|
||||
@@ -212,10 +225,14 @@ namespace AIStudio.Wpf.Flowchart.Models
|
||||
{
|
||||
FullyCreatedConnectorInfo sourceConnectorInfo = sourceNode.Connectors.FirstOrDefault(p => p.Orientation.ToString() == diagramLink.SourcePortAlignment);
|
||||
FullyCreatedConnectorInfo sinkConnectorInfo = targetNode.Connectors.FirstOrDefault(p => p.Orientation.ToString() == diagramLink.TargetPortAlignment);
|
||||
ConnectorViewModel linkModel = new ConnectorViewModel(sourceConnectorInfo, sinkConnectorInfo, diagram.VectorLineDrawMode ?? DrawMode.BoundaryConnectingLine);
|
||||
ConnectorViewModel linkModel = new ConnectorViewModel(diagram, sourceConnectorInfo, sinkConnectorInfo, diagram.DrawModeViewModel?.VectorLineDrawMode ?? DrawMode.BoundaryConnectingLine);
|
||||
linkModel.Id = new Guid(diagramLink.Id);
|
||||
linkModel.ColorViewModel.LineColor.Color = SerializeHelper.DeserializeColor(diagramLink.Color);
|
||||
linkModel.ColorViewModel.LineWidth = diagramLink.Width;
|
||||
if (!string.IsNullOrEmpty(diagramLink.Label))
|
||||
{
|
||||
linkModel.AddText(diagramLink.Label);
|
||||
}
|
||||
//线条形状与箭头待处理
|
||||
//switch (diagramLink.Router)
|
||||
//{
|
||||
|
||||
Reference in New Issue
Block a user