diff --git a/AIStudio.Wpf.DiagramDesigner/Controls/DesignerCanvas.cs b/AIStudio.Wpf.DiagramDesigner/Controls/DesignerCanvas.cs index 2d2dda6..7500192 100644 --- a/AIStudio.Wpf.DiagramDesigner/Controls/DesignerCanvas.cs +++ b/AIStudio.Wpf.DiagramDesigner/Controls/DesignerCanvas.cs @@ -464,7 +464,7 @@ namespace AIStudio.Wpf.DiagramDesigner } else if (partialConnection.IsFullConnection)//自动连接模式 { - partialConnection.RaiseFullConnection(); + _viewModel.ClearNearPort(); } else if (_service.DrawModeViewModel.LineDrawModeSelected) { diff --git a/AIStudio.Wpf.DiagramDesigner/Themes/ConnectorItem.xaml b/AIStudio.Wpf.DiagramDesigner/Themes/ConnectorItem.xaml index fa94124..f1445ab 100644 --- a/AIStudio.Wpf.DiagramDesigner/Themes/ConnectorItem.xaml +++ b/AIStudio.Wpf.DiagramDesigner/Themes/ConnectorItem.xaml @@ -34,6 +34,12 @@ + + + + + + diff --git a/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml b/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml index 9872da9..7405f9e 100644 --- a/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml +++ b/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml @@ -462,27 +462,22 @@ - - + + - - + + - - - - + - + @@ -521,13 +516,13 @@ - + - + @@ -599,19 +594,14 @@ - - + + - - + + + @@ -681,8 +671,8 @@ - - + + diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/ConnectionViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/ConnectionViewModel.cs index 12876af..0227b48 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/ConnectionViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/ConnectionViewModel.cs @@ -448,12 +448,6 @@ namespace AIStudio.Wpf.DiagramDesigner } } - - public void RaiseFullConnection() - { - RaisePropertyChanged(nameof(IsFullConnection)); - } - public double SmoothMargin { get; set; } = 125; public double SmoothAutoSlope { get; set; } = 1; public double OrthogonalShapeMargin { get; set; } = 10; @@ -585,13 +579,13 @@ namespace AIStudio.Wpf.DiagramDesigner } else if(connectorVertexModel.ConnectorVertexType == ConnectorVertexType.Start) { + var nearPort = Root.FindNearPortToAttachTo(this, ConnectorVertexType.Start); SetSourcePort(new PartCreatedConnectorInfo(connectorVertexModel.Position.X, connectorVertexModel.Position.Y)); - this.ZIndex = -1; } else if (connectorVertexModel.ConnectorVertexType == ConnectorVertexType.End) { + var nearPort = Root.FindNearPortToAttachTo(this, ConnectorVertexType.End); SetSinkPort(new PartCreatedConnectorInfo(connectorVertexModel.Position.X, connectorVertexModel.Position.Y)); - this.ZIndex = -1; } break; case nameof(ConnectorPointModel.DragStart): @@ -599,7 +593,7 @@ namespace AIStudio.Wpf.DiagramDesigner { if (connectorVertexModel.ConnectorVertexType == ConnectorVertexType.Start) { - var nearPort = Root.FindNearPortToAttachTo(this, ConnectorVertexType.Start); + var nearPort = Root?.FindNearPortToAttachTo(this, ConnectorVertexType.Start); if (nearPort != null) { SetSourcePort(nearPort); @@ -607,12 +601,13 @@ namespace AIStudio.Wpf.DiagramDesigner } else if (connectorVertexModel.ConnectorVertexType == ConnectorVertexType.End) { - var nearPort = Root.FindNearPortToAttachTo(this, ConnectorVertexType.End); + var nearPort = Root?.FindNearPortToAttachTo(this, ConnectorVertexType.End); if (nearPort != null) { SetSinkPort(nearPort); } } + Root?.ClearNearPort(); } break; } @@ -895,7 +890,7 @@ namespace AIStudio.Wpf.DiagramDesigner public double GetSourceMarkerWidth() { - if (!IsFullConnection || string.IsNullOrEmpty(ShapeViewModel.SourceMarker.Path)) + if (string.IsNullOrEmpty(ShapeViewModel.SourceMarker.Path)) { return 0; } @@ -904,7 +899,7 @@ namespace AIStudio.Wpf.DiagramDesigner public double GetSourceMarkerHeight() { - if (!IsFullConnection || string.IsNullOrEmpty(ShapeViewModel.SourceMarker.Path)) + if (string.IsNullOrEmpty(ShapeViewModel.SourceMarker.Path)) { return 0; } @@ -913,7 +908,7 @@ namespace AIStudio.Wpf.DiagramDesigner public double GetSinkMarkerWidth() { - if (!IsFullConnection || string.IsNullOrEmpty(ShapeViewModel.SinkMarker.Path)) + if (string.IsNullOrEmpty(ShapeViewModel.SinkMarker.Path)) { return 0; } @@ -922,7 +917,7 @@ namespace AIStudio.Wpf.DiagramDesigner public double GetSinkMarkerHeight() { - if (!IsFullConnection || string.IsNullOrEmpty(ShapeViewModel.SinkMarker.Path)) + if (string.IsNullOrEmpty(ShapeViewModel.SinkMarker.Path)) { return 0; } diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorInfoBase.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorInfoBase.cs index 7261b14..b1663fd 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorInfoBase.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorInfoBase.cs @@ -145,6 +145,19 @@ namespace AIStudio.Wpf.DiagramDesigner } } + private bool _beAttachTo; + public bool BeAttachTo + { + get + { + return _beAttachTo; + } + set + { + SetProperty(ref _beAttachTo, value); + } + } + public virtual bool CanAttachTo(ConnectorInfoBase port) => port != this && !port.IsReadOnly; #endregion diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorPointModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorPointModel.cs index 2b28373..51c4de3 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorPointModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/ConnectorPointModel.cs @@ -170,11 +170,6 @@ namespace AIStudio.Wpf.DiagramDesigner } } - public void SetPosition(PointBase position) - { - X = position.X; - Y = position.Y; - } private bool _dragStart; public bool DragStart @@ -189,6 +184,13 @@ namespace AIStudio.Wpf.DiagramDesigner } } + public void SetPosition(PointBase position) + { + X = position.X; + Y = position.Y; + } + + public static ConnectorPointModel operator -(ConnectorPointModel a, ConnectorPointModel b) { return new ConnectorPointModel(a.X - b.X, a.Y - b.Y); diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramOption.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramOption.cs index 1a0e29f..c49f092 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramOption.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramOption.cs @@ -39,10 +39,6 @@ namespace AIStudio.Wpf.DiagramDesigner { get; set; } = 50; - public double HittingRadius - { - get; set; - } = 20; } public class ShortcutOption diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs index 6cbe5ac..be70f9d 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DiagramViewModel.cs @@ -3357,19 +3357,28 @@ namespace AIStudio.Wpf.DiagramDesigner if (partialConnection == null) return null; + ClearNearPort(); foreach (var port in Items.OfType().ToList().SelectMany(n => n.Connectors)) { if (connectorVertexType == ConnectorVertexType.Start) { - if (partialConnection.SourceConnectorInfo.Position.DistanceTo(port.Position) < DiagramOption.SnappingOption.HittingRadius && + if (partialConnection.SourceConnectorInfo.Position.DistanceTo(port.Position) < DiagramOption.SnappingOption.SnappingRadius && partialConnection.SinkConnectorInfo?.CanAttachTo(port) == true) + { + port.DataItem.ShowConnectors = true; + port.BeAttachTo = true; return port; + } } else if (connectorVertexType == ConnectorVertexType.End) { - if (partialConnection.SinkConnectorInfo.Position.DistanceTo(port.Position) < DiagramOption.SnappingOption.HittingRadius && + if (partialConnection.SinkConnectorInfo.Position.DistanceTo(port.Position) < DiagramOption.SnappingOption.SnappingRadius && partialConnection.SourceConnectorInfo?.CanAttachTo(port) == true) + { + port.DataItem.ShowConnectors = true; + port.BeAttachTo = true; return port; + } } } @@ -3381,15 +3390,25 @@ namespace AIStudio.Wpf.DiagramDesigner if (partialConnection == null) return null; + ClearNearPort(); foreach (var port in Items.OfType().ToList().SelectMany(n => n.Connectors)) { if (partialConnection.OnGoingPosition.DistanceTo(port.Position) < DiagramOption.SnappingOption.SnappingRadius && partialConnection.SourceConnectorInfoFully?.CanAttachTo(port) == true) + { + port.DataItem.ShowConnectors = true; + port.BeAttachTo = true; return port; + } } return null; } + + public void ClearNearPort() + { + Items.OfType().ToList().SelectMany(n => n.Connectors).Where(p => p.BeAttachTo == true).ToList().ForEach(p => p.BeAttachTo = false); + } #endregion } } diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs index 4cd8cd0..e5e3e79 100644 --- a/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs +++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/IDiagramViewModel.cs @@ -408,6 +408,7 @@ namespace AIStudio.Wpf.DiagramDesigner #region 公共方法 FullyCreatedConnectorInfo FindNearPortToAttachTo(ConnectionViewModel partialConnection, ConnectorVertexType connectorVertexType); FullyCreatedConnectorInfo FindNearPortToAttachTo(ConnectionViewModel partialConnection); + void ClearNearPort(); #endregion event PropertyChangedEventHandler PropertyChanged; diff --git a/Extensions/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart_3kagb3cc_wpftmp.csproj b/Extensions/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart_3kagb3cc_wpftmp.csproj new file mode 100644 index 0000000..e33d8c8 --- /dev/null +++ b/Extensions/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart_3kagb3cc_wpftmp.csproj @@ -0,0 +1,255 @@ + + + AIStudio.Wpf.Flowchart + obj\Debug\ + obj\ + F:\aistudio.-wpf.-diagram\Extensions\AIStudio.Wpf.Flowchart\obj\ + <_TargetAssemblyProjectName>AIStudio.Wpf.Flowchart + + + + true + AIStudio.Wpf.Controls + akwkevin + https://gitee.com/akwkevin + A.png + + + 1.0.7 + 一个Wpf的流程图控件 + + + + + + + + + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Extensions/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart_p0d3tq0q_wpftmp.csproj b/Extensions/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart_p0d3tq0q_wpftmp.csproj new file mode 100644 index 0000000..550c937 --- /dev/null +++ b/Extensions/AIStudio.Wpf.Flowchart/AIStudio.Wpf.Flowchart_p0d3tq0q_wpftmp.csproj @@ -0,0 +1,185 @@ + + + AIStudio.Wpf.Flowchart + obj\Debug\ + obj\ + F:\aistudio.-wpf.-diagram\Extensions\AIStudio.Wpf.Flowchart\obj\ + <_TargetAssemblyProjectName>AIStudio.Wpf.Flowchart + + + + true + AIStudio.Wpf.Controls + akwkevin + https://gitee.com/akwkevin + A.png + + + 1.0.7 + 一个Wpf的流程图控件 + + + + + + + + + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Extensions/AIStudio.Wpf.Logical/AIStudio.Wpf.Logical_i51am1y3_wpftmp.csproj b/Extensions/AIStudio.Wpf.Logical/AIStudio.Wpf.Logical_i51am1y3_wpftmp.csproj new file mode 100644 index 0000000..a67426b --- /dev/null +++ b/Extensions/AIStudio.Wpf.Logical/AIStudio.Wpf.Logical_i51am1y3_wpftmp.csproj @@ -0,0 +1,230 @@ + + + AIStudio.Wpf.Logical + obj\Debug\ + obj\ + F:\aistudio.-wpf.-diagram\Extensions\AIStudio.Wpf.Logical\obj\ + <_TargetAssemblyProjectName>AIStudio.Wpf.Logical + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Extensions/AIStudio.Wpf.Mind/AIStudio.Wpf.Mind_itcnve3f_wpftmp.csproj b/Extensions/AIStudio.Wpf.Mind/AIStudio.Wpf.Mind_itcnve3f_wpftmp.csproj new file mode 100644 index 0000000..02bfab2 --- /dev/null +++ b/Extensions/AIStudio.Wpf.Mind/AIStudio.Wpf.Mind_itcnve3f_wpftmp.csproj @@ -0,0 +1,181 @@ + + + AIStudio.Wpf.Mind + obj\Debug\ + obj\ + F:\aistudio.-wpf.-diagram\Extensions\AIStudio.Wpf.Mind\obj\ + <_TargetAssemblyProjectName>AIStudio.Wpf.Mind + + + + true + AIStudio.Wpf.Controls + akwkevin + https://gitee.com/akwkevin + A.png + + + 1.0.6 + 一个Wpf的思维导图控件 + + + + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Extensions/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs b/Extensions/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs index db49959..8bbbb36 100644 --- a/Extensions/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs +++ b/Extensions/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs @@ -93,6 +93,7 @@ namespace AIStudio.Wpf.Mind.Helpers connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineStraight.ToString(), RouterMode.RouterOrthogonal.ToString()); } connector.EnabledForSelection = false; + connector.IsHitTestVisible= false; connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor; connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle; connector.ShapeViewModel.SinkMarker.SizeStyle = source.ShapeViewModel.SinkMarker.SizeStyle; diff --git a/Extensions/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs b/Extensions/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs index 9f97b20..e4b572b 100644 --- a/Extensions/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs +++ b/Extensions/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs @@ -118,6 +118,8 @@ namespace AIStudio.Wpf.Mind.Helpers { connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, drawMode.ToString(), routerMode.ToString()); } + connector.EnabledForSelection = false; + connector.IsHitTestVisible = false; connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor; connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle; connector.ShapeViewModel.SinkMarker.SizeStyle = source.ShapeViewModel.SinkMarker.SizeStyle; diff --git a/Extensions/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs b/Extensions/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs index a49e70f..e8d311b 100644 --- a/Extensions/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs +++ b/Extensions/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs @@ -90,6 +90,8 @@ namespace AIStudio.Wpf.Mind.Helpers { connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineSmooth.ToString(), RouterMode.RouterNormal.ToString()); } + connector.EnabledForSelection = false; + connector.IsHitTestVisible = false; connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor; connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle; connector.ShapeViewModel.SinkMarker.SizeStyle = source.ShapeViewModel.SinkMarker.SizeStyle; diff --git a/Extensions/AIStudio.Wpf.Mind/Helpers/MindLayout.cs b/Extensions/AIStudio.Wpf.Mind/Helpers/MindLayout.cs index 7e4f2f0..9911cf4 100644 --- a/Extensions/AIStudio.Wpf.Mind/Helpers/MindLayout.cs +++ b/Extensions/AIStudio.Wpf.Mind/Helpers/MindLayout.cs @@ -91,7 +91,8 @@ namespace AIStudio.Wpf.Mind.Helpers { connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineSmooth.ToString(), RouterMode.RouterNormal.ToString()); } - + connector.EnabledForSelection = false; + connector.IsHitTestVisible = false; connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor; connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle; connector.ShapeViewModel.SinkMarker.SizeStyle = source.ShapeViewModel.SinkMarker.SizeStyle; diff --git a/Extensions/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs b/Extensions/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs index f3c51e3..a408648 100644 --- a/Extensions/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs +++ b/Extensions/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs @@ -92,6 +92,8 @@ namespace AIStudio.Wpf.Mind.Helpers { connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineStraight.ToString(), RouterMode.RouterOrthogonal.ToString()); } + connector.EnabledForSelection = false; + connector.IsHitTestVisible = false; connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor; connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle; connector.ShapeViewModel.SinkMarker.SizeStyle = sink.ShapeViewModel.SinkMarker.SizeStyle; diff --git a/Extensions/AIStudio.Wpf.Mind/ViewModels/MindNode.cs b/Extensions/AIStudio.Wpf.Mind/ViewModels/MindNode.cs index 187cf6c..6d1cfa5 100644 --- a/Extensions/AIStudio.Wpf.Mind/ViewModels/MindNode.cs +++ b/Extensions/AIStudio.Wpf.Mind/ViewModels/MindNode.cs @@ -585,7 +585,6 @@ namespace AIStudio.Wpf.Mind.ViewModels if (e is ValuePropertyChangedEventArgs valuePropertyChangedEventArgs) { UpdateOffsetX((double)valuePropertyChangedEventArgs.OldValue, (double)valuePropertyChangedEventArgs.NewValue); - Console.WriteLine((sender as MindNode).Text); } break; }