diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/FlowchartViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/FlowchartViewModel.cs index 94dd989..ff43c1f 100644 --- a/AIStudio.Wpf.DiagramApp/ViewModels/FlowchartViewModel.cs +++ b/AIStudio.Wpf.DiagramApp/ViewModels/FlowchartViewModel.cs @@ -43,31 +43,31 @@ namespace AIStudio.Wpf.Flowchart { base.Init(); - DesignerItemViewModelBase start = new StartFlowNode() { Left = 100, Top = 0, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString() }; + DesignerItemViewModelBase start = new StartFlowNode() { Left = 100, Top = 0, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString() }; DiagramViewModel.DirectAddItemCommand.Execute(start); - DesignerItemViewModelBase middle1 = new MiddleFlowNode() { Left = 100, Top = 100, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString(), Text = "主管审批", UserIds= new List { "操作员1", "操作员2" }, ActType = "or" }; + DesignerItemViewModelBase middle1 = new MiddleFlowNode() { Left = 100, Top = 100, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "主管审批", UserIds= new List { "操作员1", "操作员2" }, ActType = "or" }; DiagramViewModel.DirectAddItemCommand.Execute(middle1); - DesignerItemViewModelBase decide = new DecideFlowNode() { Left = 100, Top = 200, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString(), Text = "5" }; + DesignerItemViewModelBase decide = new DecideFlowNode() { Left = 100, Top = 200, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "5" }; DiagramViewModel.DirectAddItemCommand.Execute(decide); - DesignerItemViewModelBase middle2 = new MiddleFlowNode() { Left = 200, Top = 300, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString(), Text = "分管领导", UserIds = new List { "操作员1", "操作员2" }, ActType = "and", DoubleApprove = true }; + DesignerItemViewModelBase middle2 = new MiddleFlowNode() { Left = 200, Top = 300, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "分管领导", UserIds = new List { "操作员1", "操作员2" }, ActType = "and", DoubleApprove = true }; DiagramViewModel.DirectAddItemCommand.Execute(middle2); - DesignerItemViewModelBase cobegin = new COBeginFlowNode() { Left = 100, Top = 400, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString() }; + DesignerItemViewModelBase cobegin = new COBeginFlowNode() { Left = 100, Top = 400, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString() }; DiagramViewModel.DirectAddItemCommand.Execute(cobegin); - DesignerItemViewModelBase middle3 = new MiddleFlowNode() { Left = 100, Top = 500, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString(), Text = "财务审批", UserIds = new List { "Admin" }, ActType = "or", DoubleApprove = true }; + DesignerItemViewModelBase middle3 = new MiddleFlowNode() { Left = 100, Top = 500, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "财务审批", UserIds = new List { "Admin" }, ActType = "or", DoubleApprove = true }; DiagramViewModel.DirectAddItemCommand.Execute(middle3); - DesignerItemViewModelBase middle4 = new MiddleFlowNode() { Left = 200, Top = 500, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString(), Text = "人力审批", RoleIds = new List { "操作员", "管理员" }, ActType = "or", DoubleApprove = true }; + DesignerItemViewModelBase middle4 = new MiddleFlowNode() { Left = 200, Top = 500, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "人力审批", RoleIds = new List { "操作员", "管理员" }, ActType = "or", DoubleApprove = true }; DiagramViewModel.DirectAddItemCommand.Execute(middle4); - DesignerItemViewModelBase coend = new COEndFlowNode() { Left = 100, Top = 600, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString() }; + DesignerItemViewModelBase coend = new COEndFlowNode() { Left = 100, Top = 600, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString() }; DiagramViewModel.DirectAddItemCommand.Execute(coend); - DesignerItemViewModelBase end = new EndFlowNode() { Left = 100, Top = 700, ItemWidth = 80, ItemHeight = 40, Color = Colors.Yellow.ToString() }; + DesignerItemViewModelBase end = new EndFlowNode() { Left = 100, Top = 700, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString() }; DiagramViewModel.DirectAddItemCommand.Execute(end); ConnectionViewModel connector1 = new ConnectionViewModel(start.BottomConnector, middle1.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode); diff --git a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/Texts/ColorTextViewModel.cs b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/Texts/ColorTextViewModel.cs index 357f902..0aded83 100644 --- a/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/Texts/ColorTextViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner.Demo/ViewModels/Texts/ColorTextViewModel.cs @@ -9,7 +9,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels.Texts { public ColorTextViewModel() { - Title = "Color Text"; + Title = "StatusColor Text"; Info = "A text node of AIStudio.Wpf.DiagramDesigner."; DiagramViewModel = new DiagramViewModel(); diff --git a/AIStudio.Wpf.DiagramDesigner/Models/Serializables/SelectableItemBase.cs b/AIStudio.Wpf.DiagramDesigner/Models/Serializables/SelectableItemBase.cs index 076e034..fd74e9f 100644 --- a/AIStudio.Wpf.DiagramDesigner/Models/Serializables/SelectableItemBase.cs +++ b/AIStudio.Wpf.DiagramDesigner/Models/Serializables/SelectableItemBase.cs @@ -518,6 +518,28 @@ namespace AIStudio.Wpf.DiagramDesigner return new Size(double.Parse(pieces[0]), double.Parse(pieces[1])); } + public static string SerializeCornerRadius(CornerRadius cornerRadius) + { + return string.Format("{0},{1},{2},{3}", cornerRadius.TopLeft, cornerRadius.TopRight, cornerRadius.BottomRight, cornerRadius.BottomLeft); + } + + public static CornerRadius DeserializeCornerRadius(string cornerRadius) + { + string[] pieces = cornerRadius.Split(new char[] { ',' }); + return new CornerRadius(double.Parse(pieces[0]), double.Parse(pieces[1]), double.Parse(pieces[2]), double.Parse(pieces[3])); + } + + public static string SerializeThickness(Thickness thickness) + { + return string.Format("{0},{1},{2},{3}", thickness.Left, thickness.Top, thickness.Right, thickness.Bottom); + } + + public static Thickness DeserializeThickness(string thickness) + { + string[] pieces = thickness.Split(new char[] { ',' }); + return new Thickness(double.Parse(pieces[0]), double.Parse(pieces[1]), double.Parse(pieces[2]), double.Parse(pieces[3])); + } + public static string SerializeDoubleNull(double? point) { return point?.ToString(); diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/FullyCreatedConnectorInfo.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/FullyCreatedConnectorInfo.cs index dd4d056..9d14985 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/FullyCreatedConnectorInfo.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/FullyCreatedConnectorInfo.cs @@ -147,6 +147,19 @@ namespace AIStudio.Wpf.DiagramDesigner } } + public PointBase Ratio + { + get + { + return new PointBase(XRatio, YRatio); + } + set + { + XRatio = value.X; + YRatio = value.Y; + } + } + public bool IsInnerPoint { get; set; diff --git a/AIStudio.Wpf.DiagramModels/DiagramData.cs b/AIStudio.Wpf.DiagramModels/DiagramData.cs index c6b4ce5..e7ebf62 100644 --- a/AIStudio.Wpf.DiagramModels/DiagramData.cs +++ b/AIStudio.Wpf.DiagramModels/DiagramData.cs @@ -90,6 +90,7 @@ namespace AIStudio.Wpf.DiagramModels { get; set; } + /// /// Gets or sets the color. /// @@ -100,6 +101,62 @@ namespace AIStudio.Wpf.DiagramModels { get; set; } + + /// + /// Gets or sets the color. + /// + /// + /// The color. + /// + public string LineColor + { + get; set; + } + + /// + /// Gets or sets the color. + /// + /// + /// The color. + /// + public string FontColor + { + get; set; + } + + /// + /// Gets or sets the color. + /// + /// + /// The color. + /// + public double FontSize + { + get; set; + } + + /// + /// Gets or sets the color. + /// + /// + /// The color. + /// + public string CornerRadius + { + get; set; + } + + /// + /// Gets or sets the color. + /// + /// + /// The color. + /// + public string BorderThickness + { + get; set; + } + /// /// Gets or sets the label. /// @@ -110,6 +167,7 @@ namespace AIStudio.Wpf.DiagramModels { get; set; } + /// /// Gets or sets the width. /// @@ -120,6 +178,7 @@ namespace AIStudio.Wpf.DiagramModels { get; set; } + /// /// Gets or sets the height. /// @@ -181,6 +240,16 @@ namespace AIStudio.Wpf.DiagramModels get; set; } + public bool IsInnerConnector + { + get; set; + } + + public List PortRatio + { + get; set; + } + public virtual DiagramItemViewModel ToNodel(IDiagramViewModel diagramViewModel) { return new DiagramItemViewModel(diagramViewModel); @@ -296,6 +365,17 @@ namespace AIStudio.Wpf.DiagramModels get; set; } + /// + /// Gets or sets the index of the z. + /// + /// + /// The index of the z. + /// + public int ZIndex + { + get; set; + } = -1; + /// /// Gets or sets the router. /// diff --git a/AIStudio.Wpf.DiagramModels/DiagramDataExtention.cs b/AIStudio.Wpf.DiagramModels/DiagramDataExtention.cs index 38b05be..d651c4e 100644 --- a/AIStudio.Wpf.DiagramModels/DiagramDataExtention.cs +++ b/AIStudio.Wpf.DiagramModels/DiagramDataExtention.cs @@ -27,13 +27,21 @@ namespace AIStudio.Wpf.DiagramModels public static DiagramNode ToDiagramNode(this DiagramItemViewModel nodeModel) { - DiagramNode diagramNode = nodeModel.ToDiagram(); + DiagramNode diagramNode = nodeModel.ToDiagram(); diagramNode.Id = nodeModel.Id.ToString(); if (nodeModel.ParentId != Guid.Empty) { diagramNode.ParentId = nodeModel.ParentId.ToString(); } + + diagramNode.Color = SerializeHelper.SerializeColor(nodeModel.ColorViewModel.FillColor.Color); + diagramNode.LineColor = SerializeHelper.SerializeColor(nodeModel.ColorViewModel.LineColor.Color); + diagramNode.FontColor = SerializeHelper.SerializeColor(nodeModel.FontViewModel.FontColor); + diagramNode.FontSize = nodeModel.FontViewModel.FontSize; + diagramNode.CornerRadius = SerializeHelper.SerializeCornerRadius(nodeModel.CornerRadius); + diagramNode.BorderThickness = SerializeHelper.SerializeThickness(nodeModel.BorderThickness); + diagramNode.Label = nodeModel.Text; diagramNode.Width = nodeModel.ItemWidth * ScreenHelper.ScreenScale; diagramNode.Height = nodeModel.ItemHeight * ScreenHelper.ScreenScale; @@ -42,7 +50,8 @@ namespace AIStudio.Wpf.DiagramModels diagramNode.ZIndex = nodeModel.ZIndex; diagramNode.Type = diagramNode.GetType().Name; diagramNode.PortAlignmentList = nodeModel.Connectors.Select(p => p.Orientation.ToString()).ToList(); - + diagramNode.IsInnerConnector = nodeModel.IsInnerConnector; + diagramNode.PortRatio = nodeModel.Connectors.Select(p => SerializeHelper.SerializePoint(p.Ratio)).ToList(); return diagramNode; } @@ -55,19 +64,19 @@ namespace AIStudio.Wpf.DiagramModels diagramLink.SelectedColor = SerializeHelper.SerializeColor(Colors.Black); diagramLink.Width = linkModel.ColorViewModel.LineWidth; diagramLink.Label = linkModel.Text; + diagramLink.ZIndex = linkModel.ZIndex; if (linkModel.IsFullConnection) { diagramLink.SourceId = linkModel.SourceConnectorInfo.DataItem.Id.ToString(); diagramLink.TargetId = linkModel.SinkConnectorInfoFully.DataItem.Id.ToString(); - //线条形状与箭头待处理 - //diagramLink.Router = baseLinkModel.Router?.Method.Name; - //diagramLink.PathGenerator = baseLinkModel.PathGenerator?.Method.Name; - //diagramLink.SourceMarkerPath = baseLinkModel.SourceMarker?.Path; - //diagramLink.SourceMarkerWidth = baseLinkModel.SourceMarker?.Width; - //diagramLink.TargetMarkerPath = baseLinkModel.TargetMarker?.Path; - //diagramLink.TargetMarkerWidth = baseLinkModel.TargetMarker?.Width; + diagramLink.Router = linkModel.RouterMode; + diagramLink.PathGenerator = linkModel.PathMode; + diagramLink.SourceMarkerPath = linkModel.ShapeViewModel.SourceMarker.Path; + diagramLink.SourceMarkerWidth = linkModel.ShapeViewModel.SourceMarker.Width; + diagramLink.TargetMarkerPath = linkModel.ShapeViewModel.SinkMarker.Path; + diagramLink.TargetMarkerWidth = linkModel.ShapeViewModel.SinkMarker.Width; diagramLink.Type = diagramLink.GetType().Name; @@ -119,7 +128,7 @@ namespace AIStudio.Wpf.DiagramModels private static DiagramItemViewModel ToNodelModel(this DiagramNode diagramNode, IDiagramViewModel diagram) { - DiagramItemViewModel nodeModel = diagramNode.ToNodel(diagram); + DiagramItemViewModel nodeModel = diagramNode.ToNodel(diagram); nodeModel.Id = new Guid(diagramNode.Id); if (!string.IsNullOrEmpty(diagramNode.ParentId)) @@ -127,13 +136,30 @@ namespace AIStudio.Wpf.DiagramModels nodeModel.ParentId = new Guid(diagramNode.ParentId); } nodeModel.Root = diagram; + nodeModel.ColorViewModel.FillColor.Color = SerializeHelper.DeserializeColor(diagramNode.Color); + nodeModel.ColorViewModel.LineColor.Color = SerializeHelper.DeserializeColor(diagramNode.LineColor); + nodeModel.FontViewModel.FontColor = SerializeHelper.DeserializeColor(diagramNode.FontColor); + nodeModel.FontViewModel.FontSize = diagramNode.FontSize; + nodeModel.CornerRadius = SerializeHelper.DeserializeCornerRadius(diagramNode.CornerRadius); + nodeModel.BorderThickness = SerializeHelper.DeserializeThickness(diagramNode.BorderThickness); + nodeModel.Text = diagramNode.Label; nodeModel.ItemWidth = diagramNode.Width / ScreenHelper.ScreenScale; nodeModel.ItemHeight = diagramNode.Height / ScreenHelper.ScreenScale; nodeModel.Left = diagramNode.X / ScreenHelper.ScreenScale; nodeModel.Top = diagramNode.Y / ScreenHelper.ScreenScale; nodeModel.ZIndex = diagramNode.ZIndex; - diagramNode.PortAlignmentList?.ForEach(p => nodeModel.AddConnector(new FullyCreatedConnectorInfo(nodeModel, p.ToEnum()))); + nodeModel.IsInnerConnector = diagramNode.IsInnerConnector; + if (diagramNode.PortAlignmentList != null) + { + nodeModel.ClearConnectors(); + for (int i = 0; i < diagramNode.PortAlignmentList.Count; i++) + { + var connecter = new FullyCreatedConnectorInfo(nodeModel, diagramNode.PortAlignmentList[i].ToEnum(), nodeModel.IsInnerConnector); + connecter.Ratio = SerializeHelper.DeserializePoint(diagramNode.PortRatio[i]); + nodeModel.AddConnector(connecter); + } + } return nodeModel; } @@ -142,35 +168,24 @@ namespace AIStudio.Wpf.DiagramModels { FullyCreatedConnectorInfo sourceConnectorInfo = sourceNode.Connectors.FirstOrDefault(p => p.Orientation.ToString() == diagramLink.SourcePortAlignment); FullyCreatedConnectorInfo sinkConnectorInfo = targetNode.Connectors.FirstOrDefault(p => p.Orientation.ToString() == diagramLink.TargetPortAlignment); - ConnectionViewModel linkModel = new ConnectionViewModel(diagram, sourceConnectorInfo, sinkConnectorInfo, diagram.DrawModeViewModel?.LineDrawMode ?? DrawMode.ConnectingLineSmooth, diagram.DrawModeViewModel?.LineRouterMode ?? RouterMode.RouterNormal); + ConnectionViewModel linkModel = new ConnectionViewModel(diagram, sourceConnectorInfo, sinkConnectorInfo, + (DrawMode)Enum.Parse(typeof(DrawMode), diagramLink.PathGenerator?? DrawMode.ConnectingLineSmooth.ToString()), + (RouterMode)Enum.Parse(typeof(RouterMode), diagramLink.Router ?? RouterMode.RouterNormal.ToString())); 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.Text = diagramLink.Label; + linkModel.ZIndex = diagramLink.ZIndex; + + + if (!string.IsNullOrEmpty(diagramLink.SourceMarkerPath)) { - linkModel.AddLabel(diagramLink.Label); + linkModel.ShapeViewModel.SourceMarker = new LinkMarker() { Path = diagramLink.SourceMarkerPath, Width = diagramLink.SourceMarkerWidth ?? 10, Height = diagramLink.SourceMarkerWidth ?? 10 }; + } + if (!string.IsNullOrEmpty(diagramLink.TargetMarkerPath)) + { + linkModel.ShapeViewModel.SinkMarker = new LinkMarker() { Path = diagramLink.TargetMarkerPath, Width = diagramLink.TargetMarkerWidth ?? 10.0, Height = diagramLink.TargetMarkerWidth ?? 10 }; } - //线条形状与箭头待处理 - //switch (diagramLink.Router) - //{ - // case "Normal": linkModel.Router = Routers.Normal; break; - // case "Orthogonal": linkModel.Router = Routers.Orthogonal; break; - //} - //switch (diagramLink.PathGenerator) - //{ - // case "Smooth": linkModel.PathGenerator = PathGenerators.Smooth; break; - // case "Straight": linkModel.PathGenerator = PathGenerators.Straight; break; - - //} - - //if (!string.IsNullOrEmpty(diagramLink.SourceMarkerPath)) - //{ - // linkModel.SourceMarker = new LinkMarker(diagramLink.SourceMarkerPath, diagramLink.SourceMarkerWidth ?? 10.0); - //} - //if (!string.IsNullOrEmpty(diagramLink.TargetMarkerPath)) - //{ - // linkModel.TargetMarker = new LinkMarker(diagramLink.TargetMarkerPath, diagramLink.TargetMarkerWidth ?? 10.0); - //} return linkModel; } #endregion diff --git a/AIStudio.Wpf.Flowchart/FlowchartService.cs b/AIStudio.Wpf.Flowchart/FlowchartService.cs index 391fda4..b74d457 100644 --- a/AIStudio.Wpf.Flowchart/FlowchartService.cs +++ b/AIStudio.Wpf.Flowchart/FlowchartService.cs @@ -357,22 +357,22 @@ namespace AIStudio.Wpf.Flowchart switch (status) { case 100: - flowNode.Color = Colors.Green.ToString(); + flowNode.StatusColor = Colors.Green.ToString(); break; case 0: - flowNode.Color = Colors.Yellow.ToString(); + flowNode.StatusColor = Colors.Yellow.ToString(); break; case 1: - flowNode.Color = Colors.Orange.ToString(); + flowNode.StatusColor = Colors.Orange.ToString(); break; case 2: - flowNode.Color = Colors.Red.ToString(); + flowNode.StatusColor = Colors.Red.ToString(); break; case 3: - flowNode.Color = Colors.Red.ToString(); + flowNode.StatusColor = Colors.Red.ToString(); break; case 4: - flowNode.Color = Colors.Red.ToString(); + flowNode.StatusColor = Colors.Red.ToString(); break; } } diff --git a/AIStudio.Wpf.Flowchart/Models/FlowNodeDesignerItem.cs b/AIStudio.Wpf.Flowchart/Models/FlowNodeDesignerItem.cs index fd537b6..92f3c7b 100644 --- a/AIStudio.Wpf.Flowchart/Models/FlowNodeDesignerItem.cs +++ b/AIStudio.Wpf.Flowchart/Models/FlowNodeDesignerItem.cs @@ -25,7 +25,7 @@ namespace AIStudio.Wpf.Flowchart.Models RoleIds = middleFlow.RoleIds; ActType = middleFlow.ActType; } - Color = item.Color; + Color = item.StatusColor; Kind = item.Kind; StateImage = item.StateImage; } diff --git a/AIStudio.Wpf.Flowchart/Models/FlowchartNode.cs b/AIStudio.Wpf.Flowchart/Models/FlowchartNode.cs index 634937d..90f4e31 100644 --- a/AIStudio.Wpf.Flowchart/Models/FlowchartNode.cs +++ b/AIStudio.Wpf.Flowchart/Models/FlowchartNode.cs @@ -58,6 +58,17 @@ namespace AIStudio.Wpf.Flowchart.Models get; set; } + /// + /// Gets or sets the color. + /// + /// + /// The color. + /// + public string StatusColor + { + get; set; + } + public override DiagramItemViewModel ToNodel(IDiagramViewModel diagramViewModel) { FlowNode flowNode = null; @@ -108,7 +119,7 @@ namespace AIStudio.Wpf.Flowchart.Models } flowNode.Name = Name; - flowNode.Color = Color; + flowNode.StatusColor = StatusColor; flowNode.Kind = Kind; return flowNode; diff --git a/AIStudio.Wpf.Flowchart/Themes/FlowNode.xaml b/AIStudio.Wpf.Flowchart/Themes/FlowNode.xaml index effe1e8..3b86899 100644 --- a/AIStudio.Wpf.Flowchart/Themes/FlowNode.xaml +++ b/AIStudio.Wpf.Flowchart/Themes/FlowNode.xaml @@ -9,7 +9,7 @@ - + @@ -19,7 +19,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -72,7 +72,7 @@ - + diff --git a/AIStudio.Wpf.Flowchart/ViewModels/FlowNode.cs b/AIStudio.Wpf.Flowchart/ViewModels/FlowNode.cs index 004a9d9..c6b1c68 100644 --- a/AIStudio.Wpf.Flowchart/ViewModels/FlowNode.cs +++ b/AIStudio.Wpf.Flowchart/ViewModels/FlowNode.cs @@ -57,7 +57,7 @@ namespace AIStudio.Wpf.Flowchart.ViewModels if (designerbase is FlowNodeDesignerItem designer) { - this.Color = designer.Color; + this.StatusColor = designer.Color; this.Kind = designer.Kind; this.StateImage = designer.StateImage; @@ -75,7 +75,7 @@ namespace AIStudio.Wpf.Flowchart.ViewModels var flowchartNode = new FlowchartNode(); flowchartNode.Name = Name; - flowchartNode.Color = Color; + flowchartNode.StatusColor = StatusColor; flowchartNode.Kind = Kind; if (this is MiddleFlowNode middleflowNode) { @@ -88,7 +88,7 @@ namespace AIStudio.Wpf.Flowchart.ViewModels private string _color = "#1890ff"; [Browsable(false)] - public string Color + public string StatusColor { get { return _color; } set diff --git a/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs b/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs index a633f4e..41a7579 100644 --- a/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs +++ b/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs @@ -13,65 +13,71 @@ namespace AIStudio.Wpf.Mind.Helpers { public class DirectoryLayout : IMindLayout { - public void Appearance(MindNode mindNode) + public void Appearance(MindNode mindNode, bool initAppearance) { switch (mindNode.NodeLevel) { case 0: { - mindNode.ItemWidth = 110; - mindNode.ItemHeight = 40; - mindNode.ClearConnectors(); + if (initAppearance) + { + mindNode.ItemWidth = 110; + mindNode.ItemHeight = 40; + mindNode.ClearConnectors(); - var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 1 }; - mindNode.AddConnector(port); + var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 1 }; + mindNode.AddConnector(port); - mindNode.IsInnerConnector = true; - - mindNode.ColorViewModel.FillColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); - mindNode.FontViewModel.FontColor = Colors.White; - mindNode.FontViewModel.FontSize = 15; + mindNode.ColorViewModel.FillColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.FontViewModel.FontColor = Colors.White; + mindNode.FontViewModel.FontSize = 15; + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; - mindNode.ConnectorOrientation = ConnectorOrientation.None; break; } case 1: { - mindNode.ItemWidth = 80; - mindNode.ItemHeight = 25; - mindNode.ClearConnectors(); - var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Top, true) { XRatio = 0.5, YRatio = 0 }; - mindNode.AddConnector(port1); - var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.25, YRatio = 1 }; - mindNode.AddConnector(port2); + if (initAppearance) + { + mindNode.ItemWidth = 80; + mindNode.ItemHeight = 25; + mindNode.ClearConnectors(); + var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Top, true) { XRatio = 0.5, YRatio = 0 }; + mindNode.AddConnector(port1); + var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.25, YRatio = 1 }; + mindNode.AddConnector(port2); - mindNode.IsInnerConnector = true; - - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; + mindNode.ConnectorOrientation = ConnectorOrientation.Left; break; } default: { - mindNode.ItemWidth = 80; - mindNode.ItemHeight = 25; - mindNode.ClearConnectors(); + if (initAppearance) + { + mindNode.ItemWidth = 80; + mindNode.ItemHeight = 25; + mindNode.ClearConnectors(); - var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 0.5 }; - mindNode.AddConnector(port1); - var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.25, YRatio = 1 }; - mindNode.AddConnector(port2); + var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 0.5 }; + mindNode.AddConnector(port1); + var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.25, YRatio = 1 }; + mindNode.AddConnector(port2); - mindNode.IsInnerConnector = true; - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.CornerRadius = new System.Windows.CornerRadius(0); + mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0); + + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; - mindNode.CornerRadius = new System.Windows.CornerRadius(0); - mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0); + mindNode.ConnectorOrientation = ConnectorOrientation.Left; break; } } diff --git a/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs b/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs index edd7b78..8e084bf 100644 --- a/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs +++ b/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs @@ -13,7 +13,7 @@ namespace AIStudio.Wpf.Mind.Helpers { public class FishBoneLayout : IMindLayout { - public void Appearance(MindNode mindNode) + public void Appearance(MindNode mindNode, bool initAppearance) { if (mindNode == null) return; @@ -23,65 +23,72 @@ namespace AIStudio.Wpf.Mind.Helpers { case 0: { - mindNode.ItemWidth = 110; - mindNode.ItemHeight = 40; - mindNode.ClearConnectors(); + if (initAppearance) + { + mindNode.ItemWidth = 110; + mindNode.ItemHeight = 40; + mindNode.ClearConnectors(); - var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 0.5 }; - mindNode.AddConnector(port); + var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 0.5 }; + mindNode.AddConnector(port); - mindNode.IsInnerConnector = true; - - mindNode.ColorViewModel.FillColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); - mindNode.FontViewModel.FontColor = Colors.White; - mindNode.FontViewModel.FontSize = 15; - mindNode.Spacing = new SizeBase(50, 15); + mindNode.ColorViewModel.FillColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.FontViewModel.FontColor = Colors.White; + mindNode.FontViewModel.FontSize = 15; + mindNode.Spacing = new SizeBase(50, 15); + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; - mindNode.ConnectorOrientation = ConnectorOrientation.None; break; } case 1: { - mindNode.ItemWidth = 80; - mindNode.ItemHeight = 25; - mindNode.ClearConnectors(); + if (initAppearance) + { + mindNode.ItemWidth = 80; + mindNode.ItemHeight = 25; + mindNode.ClearConnectors(); - var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.BottomLeft, true) { XRatio = 0, YRatio = 1 }; - mindNode.AddConnector(port1); + var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.BottomLeft, true) { XRatio = 0, YRatio = 1 }; + mindNode.AddConnector(port1); - var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.TopLeft, true) { XRatio = 0, YRatio = 0 }; - mindNode.AddConnector(port2); + var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.TopLeft, true) { XRatio = 0, YRatio = 0 }; + mindNode.AddConnector(port2); - mindNode.IsInnerConnector = true; + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + } - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; + mindNode.ConnectorOrientation = ConnectorOrientation.Left; break; } default: { - mindNode.ItemWidth = 80; - mindNode.ItemHeight = 25; - mindNode.ClearConnectors(); + if (initAppearance) + { + mindNode.ItemWidth = 80; + mindNode.ItemHeight = 25; + mindNode.ClearConnectors(); - var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 0.5 }; - mindNode.AddConnector(port1); - var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.25, YRatio = 1 }; - mindNode.AddConnector(port2); - var port3 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Top, true) { XRatio = 0.25, YRatio = 0 }; - mindNode.AddConnector(port3); + var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 0.5 }; + mindNode.AddConnector(port1); + var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.25, YRatio = 1 }; + mindNode.AddConnector(port2); + var port3 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Top, true) { XRatio = 0.25, YRatio = 0 }; + mindNode.AddConnector(port3); - mindNode.IsInnerConnector = true; - mindNode.ColorViewModel.FillColor.Color = Colors.Transparent; - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.CornerRadius = new System.Windows.CornerRadius(0); + mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0); + + mindNode.ColorViewModel.FillColor.Color = Colors.Transparent; + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; - mindNode.CornerRadius = new System.Windows.CornerRadius(0); - mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0); + mindNode.ConnectorOrientation = ConnectorOrientation.Left; break; } } diff --git a/AIStudio.Wpf.Mind/Helpers/IMindLayout.cs b/AIStudio.Wpf.Mind/Helpers/IMindLayout.cs index d1482c3..6da9f84 100644 --- a/AIStudio.Wpf.Mind/Helpers/IMindLayout.cs +++ b/AIStudio.Wpf.Mind/Helpers/IMindLayout.cs @@ -8,7 +8,7 @@ namespace AIStudio.Wpf.Mind.Helpers { public interface IMindLayout { - void Appearance(MindNode mindNode); + void Appearance(MindNode mindNode, bool initAppearance); ConnectionViewModel GetOrSetConnectionViewModel(MindNode source, MindNode sink, ConnectionViewModel connector = null); void LayoutUpdated(MindNode mindNode); diff --git a/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs b/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs index 2303e4c..4032a34 100644 --- a/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs +++ b/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs @@ -13,66 +13,72 @@ namespace AIStudio.Wpf.Mind.Helpers { public class LogicalLayout : IMindLayout { - public void Appearance(MindNode mindNode) + public void Appearance(MindNode mindNode, bool initAppearance) { switch (mindNode.NodeLevel) { case 0: { - mindNode.ItemWidth = 110; - mindNode.ItemHeight = 40; - mindNode.ClearConnectors(); + if (initAppearance) + { + mindNode.ItemWidth = 110; + mindNode.ItemHeight = 40; + mindNode.ClearConnectors(); - var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.None, true) { XRatio = 0.5, YRatio = 0.5 }; - mindNode.AddConnector(port); + var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.None, true) { XRatio = 0.5, YRatio = 0.5 }; + mindNode.AddConnector(port); - mindNode.IsInnerConnector = true; - - mindNode.ColorViewModel.FillColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); - mindNode.FontViewModel.FontColor = Colors.White; - mindNode.FontViewModel.FontSize = 15; - mindNode.Spacing = new SizeBase(50, 15); + mindNode.ColorViewModel.FillColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.FontViewModel.FontColor = Colors.White; + mindNode.FontViewModel.FontSize = 15; + mindNode.Spacing = new SizeBase(50, 15); + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.Circle; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; - mindNode.ConnectorOrientation = ConnectorOrientation.None; break; } case 1: { - mindNode.ItemWidth = 80; - mindNode.ItemHeight = 25; - mindNode.ClearConnectors(); - var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 0.5 }; - mindNode.AddConnector(port1); - var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 0.5 }; - mindNode.AddConnector(port2); + if (initAppearance) + { + mindNode.ItemWidth = 80; + mindNode.ItemHeight = 25; + mindNode.ClearConnectors(); + var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 0.5 }; + mindNode.AddConnector(port1); + var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 0.5 }; + mindNode.AddConnector(port2); - mindNode.IsInnerConnector = true; - - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; + mindNode.ConnectorOrientation = ConnectorOrientation.Left; break; } case 2: { - mindNode.ItemWidth = 80; - mindNode.ItemHeight = 25; - mindNode.ClearConnectors(); + if (initAppearance) + { + mindNode.ItemWidth = 80; + mindNode.ItemHeight = 25; + mindNode.ClearConnectors(); - var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 1 }; - mindNode.AddConnector(port1); - var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 1 }; - mindNode.AddConnector(port2); + var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 1 }; + mindNode.AddConnector(port1); + var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 1 }; + mindNode.AddConnector(port2); - mindNode.IsInnerConnector = true; - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.CornerRadius = new System.Windows.CornerRadius(0); + mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 1); + + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; - mindNode.CornerRadius = new System.Windows.CornerRadius(0); - mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 1); + mindNode.ConnectorOrientation = ConnectorOrientation.Left; break; } } diff --git a/AIStudio.Wpf.Mind/Helpers/MindLayout.cs b/AIStudio.Wpf.Mind/Helpers/MindLayout.cs index 7f61a4b..e0c4534 100644 --- a/AIStudio.Wpf.Mind/Helpers/MindLayout.cs +++ b/AIStudio.Wpf.Mind/Helpers/MindLayout.cs @@ -13,66 +13,72 @@ namespace AIStudio.Wpf.Mind.Helpers { public class MindLayout : IMindLayout { - public void Appearance(MindNode mindNode) + public void Appearance(MindNode mindNode, bool initAppearance) { switch (mindNode.NodeLevel) { case 0: { - mindNode.ItemWidth = 110; - mindNode.ItemHeight = 40; - mindNode.ClearConnectors(); + if (initAppearance) + { + mindNode.ItemWidth = 110; + mindNode.ItemHeight = 40; + mindNode.ClearConnectors(); - var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.None, true) { XRatio = 0.5, YRatio = 0.5 }; - mindNode.AddConnector(port); + var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.None, true) { XRatio = 0.5, YRatio = 0.5 }; + mindNode.AddConnector(port); - mindNode.IsInnerConnector = true; - - mindNode.ColorViewModel.FillColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); - mindNode.FontViewModel.FontColor = Colors.White; - mindNode.FontViewModel.FontSize = 15; - mindNode.Spacing = new SizeBase(50, 15); + mindNode.ColorViewModel.FillColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.FontViewModel.FontColor = Colors.White; + mindNode.FontViewModel.FontSize = 15; + mindNode.Spacing = new SizeBase(50, 15); + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.Circle; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; - mindNode.ConnectorOrientation = ConnectorOrientation.None; break; } case 1: { - mindNode.ItemWidth = 80; - mindNode.ItemHeight = 25; - mindNode.ClearConnectors(); - var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 0.5 }; - mindNode.AddConnector(port1); - var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 0.5 }; - mindNode.AddConnector(port2); + if (initAppearance) + { + mindNode.ItemWidth = 80; + mindNode.ItemHeight = 25; + mindNode.ClearConnectors(); + var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 0.5 }; + mindNode.AddConnector(port1); + var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 0.5 }; + mindNode.AddConnector(port2); - mindNode.IsInnerConnector = true; - - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; + mindNode.ConnectorOrientation = ConnectorOrientation.Left; break; } default: { - mindNode.ItemWidth = 80; - mindNode.ItemHeight = 25; - mindNode.ClearConnectors(); + if (initAppearance) + { + mindNode.ItemWidth = 80; + mindNode.ItemHeight = 25; + mindNode.ClearConnectors(); - var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 1 }; - mindNode.AddConnector(port1); - var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 1 }; - mindNode.AddConnector(port2); + var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 1 }; + mindNode.AddConnector(port1); + var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 1 }; + mindNode.AddConnector(port2); - mindNode.IsInnerConnector = true; - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.CornerRadius = new System.Windows.CornerRadius(0); + mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 1); + + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; - mindNode.CornerRadius = new System.Windows.CornerRadius(0); - mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 1); + mindNode.ConnectorOrientation = ConnectorOrientation.Left; break; } } diff --git a/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs b/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs index 3af3b8a..9dba966 100644 --- a/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs +++ b/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs @@ -13,44 +13,46 @@ namespace AIStudio.Wpf.Mind.Helpers { public class OrganizationalLayout : IMindLayout { - public void Appearance(MindNode mindNode) + public void Appearance(MindNode mindNode, bool initAppearance) { switch (mindNode.NodeLevel) { case 0: { - mindNode.ItemWidth = 110; - mindNode.ItemHeight = 40; - mindNode.ClearConnectors(); + if (initAppearance) + { + mindNode.ItemWidth = 110; + mindNode.ItemHeight = 40; + mindNode.ClearConnectors(); - var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 1 }; - mindNode.AddConnector(port); + var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 1 }; + mindNode.AddConnector(port); - mindNode.IsInnerConnector = true; - - mindNode.ColorViewModel.FillColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); - mindNode.FontViewModel.FontColor = Colors.White; - mindNode.FontViewModel.FontSize = 15; + mindNode.ColorViewModel.FillColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.FontViewModel.FontColor = Colors.White; + mindNode.FontViewModel.FontSize = 15; + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; - mindNode.ConnectorOrientation = ConnectorOrientation.None; break; } case 1: { - mindNode.ItemWidth = 80; - mindNode.ItemHeight = 25; - mindNode.ClearConnectors(); - var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Top, true) { XRatio = 0.5, YRatio = 0 }; - mindNode.AddConnector(port1); - var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 1 }; - mindNode.AddConnector(port2); + if (initAppearance) + { + mindNode.ItemWidth = 80; + mindNode.ItemHeight = 25; + mindNode.ClearConnectors(); + var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Top, true) { XRatio = 0.5, YRatio = 0 }; + mindNode.AddConnector(port1); + var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 1 }; + mindNode.AddConnector(port2); - mindNode.IsInnerConnector = true; + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + } - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; mindNode.ConnectorOrientation = ConnectorOrientation.Top; @@ -58,21 +60,24 @@ namespace AIStudio.Wpf.Mind.Helpers } default: { - mindNode.ItemWidth = 80; - mindNode.ItemHeight = 25; - mindNode.ClearConnectors(); + if (initAppearance) + { + mindNode.ItemWidth = 80; + mindNode.ItemHeight = 25; + mindNode.ClearConnectors(); - var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Top, true) { XRatio = 0.5, YRatio = 0 }; - mindNode.AddConnector(port1); - var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 1 }; - mindNode.AddConnector(port2); + var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Top, true) { XRatio = 0.5, YRatio = 0 }; + mindNode.AddConnector(port1); + var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 1 }; + mindNode.AddConnector(port2); - mindNode.IsInnerConnector = true; - mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + mindNode.CornerRadius = new System.Windows.CornerRadius(0); + mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0); + + mindNode.ColorViewModel.LineColor.Color = Color.FromRgb(0x73, 0xa1, 0xbf); + } mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None; - mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; - mindNode.CornerRadius = new System.Windows.CornerRadius(0); - mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0); + mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall; mindNode.ConnectorOrientation = ConnectorOrientation.Top; break; } diff --git a/AIStudio.Wpf.Mind/Models/MindNodeModel.cs b/AIStudio.Wpf.Mind/Models/MindNodeModel.cs index 16ffdc6..1539e3c 100644 --- a/AIStudio.Wpf.Mind/Models/MindNodeModel.cs +++ b/AIStudio.Wpf.Mind/Models/MindNodeModel.cs @@ -33,7 +33,8 @@ namespace AIStudio.Wpf.Flowchart.Models mindNode.Spacing = Spacing; mindNode.Offset = Offset; - mindNode.IsExpanded = IsExpanded; + mindNode.IsExpanded = IsExpanded; + mindNode.InitLayout(false); return mindNode; } diff --git a/AIStudio.Wpf.Mind/ViewModels/MindDiagramViewModel.cs b/AIStudio.Wpf.Mind/ViewModels/MindDiagramViewModel.cs index 1583b45..f3f8cf3 100644 --- a/AIStudio.Wpf.Mind/ViewModels/MindDiagramViewModel.cs +++ b/AIStudio.Wpf.Mind/ViewModels/MindDiagramViewModel.cs @@ -411,31 +411,44 @@ namespace AIStudio.Wpf.Mind.ViewModels protected override bool Delete(object parameter) { - if (parameter is MindNode node) + List nodes = new List(); + if (parameter is MindNode node1) { - + nodes.Add(node1); + } + else if (parameter is IEnumerable para) + { + nodes.AddRange(para); } else { - node = SelectedItem as MindNode; + nodes.AddRange(SelectedItems.OfType()); } - if (node.IsEditing == true) + if (nodes.FirstOrDefault()?.IsEditing != false) { return false; } - if (node.Parent is MindNode parent) + nodes = nodes.Except(new List{ RootItem }).ToList(); + + if (nodes.Any()) { - int index = parent.Children.IndexOf(node); + Dictionary indexs = nodes.ToDictionary(p => p, p => p.ParentNode.Children.IndexOf(p)); DoCommandManager.DoNewCommand(this.ToString(), () => { - parent.RemoveChild(node, true); - parent.LayoutUpdated(); + foreach (var node in nodes) + { + node.ParentNode.RemoveChild(node, true); + } + RootItem.LayoutUpdated(); }, () => { - parent.AddChild(node, index); - parent.LayoutUpdated(); + foreach (var node in nodes) + { + node.ParentNode.AddChild(node, indexs[node]); + } + RootItem.LayoutUpdated(); }); return true; } @@ -512,6 +525,9 @@ namespace AIStudio.Wpf.Mind.ViewModels parent.Children = new System.Collections.ObjectModel.ObservableCollection(Items.OfType().Where(p => p.ParentId == parent.Id)); foreach (var item in Items.OfType().Where(p => p.ParentId == parent.Id)) { + item.Parent = parent; + item.InitLayout(false); + item.InitConnectLayout(); GetChildren(item); } } diff --git a/AIStudio.Wpf.Mind/ViewModels/MindNode.cs b/AIStudio.Wpf.Mind/ViewModels/MindNode.cs index 86f1e05..003d775 100644 --- a/AIStudio.Wpf.Mind/ViewModels/MindNode.cs +++ b/AIStudio.Wpf.Mind/ViewModels/MindNode.cs @@ -70,10 +70,9 @@ namespace AIStudio.Wpf.Mind.ViewModels var layout = GlobalType.AllTypes.Where(p => typeof(IMindLayout).IsAssignableFrom(p)).FirstOrDefault(p => p.Name == MindType.ToString() + "Layout"); MindLayout = layout != null ? (System.Activator.CreateInstance(layout) as IMindLayout) : new MindLayout(); - if (initAppearance) - { - MindLayout.Appearance(this); - } + IsInnerConnector = true; + MindLayout.Appearance(this, initAppearance); + this.PropertyChanged -= this.Item_PropertyChanged; this.PropertyChanged += this.Item_PropertyChanged; } @@ -412,7 +411,7 @@ namespace AIStudio.Wpf.Mind.ViewModels var connector = Root?.Items.OfType().Where(p => p.IsFullConnection).FirstOrDefault(p => p.SinkConnectorInfoFully.DataItem == this); if (connector != null) { - MindLayout?.GetOrSetConnectionViewModel(connector.SourceConnectorInfo.DataItem as MindNode, connector.SinkConnectorInfoFully.DataItem as MindNode, connector); + MindLayout?.GetOrSetConnectionViewModel(connector.SourceConnectorInfo.DataItem as MindNode, connector.SinkConnectorInfoFully.DataItem as MindNode, connector); } } #endregion @@ -431,7 +430,7 @@ namespace AIStudio.Wpf.Mind.ViewModels break; } case nameof(NodeLevel): - MindLayout?.Appearance(this); + MindLayout?.Appearance(this, false); break; case nameof(Left): {