mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-14 21:26:35 +08:00
线条文本可以保存了
This commit is contained in:
@@ -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