diff --git a/AIStudio.Wpf.DiagramDesigner.Additionals/AIStudio.Wpf.DiagramDesigner.Additionals_ihwwsf1d_wpftmp.csproj b/AIStudio.Wpf.DiagramDesigner.Additionals/AIStudio.Wpf.DiagramDesigner.Additionals_ihwwsf1d_wpftmp.csproj
new file mode 100644
index 0000000..8b4dabd
--- /dev/null
+++ b/AIStudio.Wpf.DiagramDesigner.Additionals/AIStudio.Wpf.DiagramDesigner.Additionals_ihwwsf1d_wpftmp.csproj
@@ -0,0 +1,309 @@
+
+
+ AIStudio.Wpf.DiagramDesigner.Additionals
+ obj\Debug\
+ obj\
+ F:\aistudio.-wpf.-diagram\AIStudio.Wpf.DiagramDesigner.Additionals\obj\
+ <_TargetAssemblyProjectName>AIStudio.Wpf.DiagramDesigner.Additionals
+
+
+
+ true
+ true
+ AIStudio.Wpf.Controls
+ akwkevin
+ https://gitee.com/akwkevin
+ A.png
+
+
+ 1.1.7
+ 一个Wpf的Diagram控件帮助库
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/BlockConnectorInfo.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/BlockConnectorInfo.cs
index 5781d1a..e176e3b 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/BlockConnectorInfo.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/Connector/BlockConnectorInfo.cs
@@ -83,12 +83,34 @@ namespace AIStudio.Wpf.DiagramDesigner
public double DistanceTo(BlockConnectorInfo port)
{
- var leftleftdistance = LeftPosition.DistanceTo(port.LeftPosition);
- var leftrightdistance = LeftPosition.DistanceTo(port.RightPosition);
- var rightleftdistance = RightPosition.DistanceTo(port.LeftPosition);
- var rightrightdistance = RightPosition.DistanceTo(port.RightPosition);
+ PointBase p0 = port.LeftPosition;
+ PointBase p1 = port.RightPosition;
+ PointBase p2 = LeftPosition;
+ PointBase p3 = RightPosition;
+ var distance1 = DistanceTo(p0, p1, p2);
+ var distance2 = DistanceTo(p0, p1, p3);
+ var distance3 = DistanceTo(p2, p3, p0);
+ var distance4 = DistanceTo(p2, p3, p1);
- return Math.Min(Math.Min(leftleftdistance, leftrightdistance), Math.Min(rightleftdistance, rightrightdistance));
+ return Math.Min(Math.Min(distance1, distance2), Math.Min(distance3, distance4));
}
+
+ double DistanceTo(PointBase A, PointBase B, PointBase P) //点P到线段AB的最短距离
+ {
+ double r = ((P.X - A.X) * (B.X - A.X) + (P.Y - A.Y) * (B.Y - A.Y)) / DistanceToPow(A, B);
+ if (r <= 0) return Math.Sqrt(DistanceToPow(A, P));
+ else if (r >= 1) return Math.Sqrt(DistanceToPow(B, P));
+ else
+ {
+ double AC = r * Math.Sqrt(DistanceToPow(A, B));
+ return Math.Sqrt(DistanceToPow(A, P) - AC * AC);
+ }
+ }
+
+ double DistanceToPow(PointBase a, PointBase b) //点a、b距离的平方
+ {
+ return (a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y);
+ }
+
}
}
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs
index 02c4501..c5f0d9a 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BaseViewModel/DesignerItemViewModelBase.cs
@@ -776,12 +776,12 @@ namespace AIStudio.Wpf.DiagramDesigner
public double GetItemWidth()
{
- return double.IsNaN(ItemWidth) ? ActualItemWidth : ItemWidth;
+ return double.IsNaN(ItemWidth) ? Math.Max(ActualItemWidth, MinItemWidth) : ItemWidth;
}
public double GetItemHeight()
{
- return double.IsNaN(ItemHeight) ? ActualItemHeight : ItemHeight;
+ return double.IsNaN(ItemHeight) ? Math.Max(ActualItemHeight, MinItemHeight) : ItemHeight;
}
public IShape GetShape() => ShapeDefiner(this);
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModel.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModel.cs
index 13cdadc..4bc4871 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModel.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModel.cs
@@ -130,9 +130,34 @@ namespace AIStudio.Wpf.DiagramDesigner
{
this.RemoveChild(oldchildren, container);
}
+ Root.Items.Remove(child);
+ if (child.Prev != null)
+ {
+ child.Prev.RemoveNext();
+ }
+ if (child.Next != null)
+ {
+ child.RemoveNext();
+ }
+ container.InsertChild(child, index);
+ }
+ else
+ {
+ var list = child.GetNexts(true);
+ list.Reverse();
+ list.ForEach(p => {
+ Root.Items.Remove(p);
+ if (p.Prev != null)
+ {
+ p.Prev.RemoveNext();
+ }
+ if (p.Next != null)
+ {
+ p.RemoveNext();
+ }
+ container.InsertChild(p, index);
+ });
}
- Root.Items.Remove(child);
- container.InsertChild(child, index);
child.RemoveFromSelection();
this.GetRootContainItem.AddToSelection(true, true);
@@ -237,28 +262,44 @@ namespace AIStudio.Wpf.DiagramDesigner
public BlockDesignerItemViewModel GetFirst()
{
- var parent = this.Next;
- if (parent != null)
+ var parent = this.Prev;
+ while (parent?.Prev != null)
{
- while (parent.Prev != null)
- {
- parent = Prev;
- }
+ parent = parent.Prev;
}
+
return parent;
}
public BlockDesignerItemViewModel GetLast()
{
var next = this;
- if (next != null)
+ while (next.Next != null)
{
- while (next.Next != null)
+ next = next.Next;
+ }
+
+ return next;
+ }
+
+ public List GetNexts(bool self)
+ {
+ List blockDesignerItemViewModels = new List();
+ if (self)
+ {
+ blockDesignerItemViewModels.Add(this);
+ }
+ var next = this;
+ while (next != null)
+ {
+ next = next.Next;
+ if (next != null)
{
- next = next.Next;
+ blockDesignerItemViewModels.Add(next);
}
}
- return next;
+
+ return blockDesignerItemViewModels;
}
public void AddContainer(BlockItemsContainerInfo container)
@@ -404,12 +445,12 @@ namespace AIStudio.Wpf.DiagramDesigner
{
List links = new List();
foreach (var block in blocks.OrderBy(p => p.BlockLevel).ToList())
- {
+ {
bool success = false;
foreach (var link in links)
{
if (link.Items.LastOrDefault() == block.Prev)
- {
+ {
link.Items.Add(block);
success = true;
}
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModelHelper.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModelHelper.cs
index 436fb03..8292b00 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModelHelper.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/BlockViewModel/BlockDesignerItemViewModelHelper.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -34,30 +35,32 @@ namespace AIStudio.Wpf.DiagramDesigner
FullyCreatedConnectorInfo parent = null;
FullyCreatedConnectorInfo next = null;
- foreach (var item in items)
+
+ foreach (var port2 in blockDesignerItemTempLink.Connectors.OfType())
{
bool success = false;
- foreach (var port in item.Connectors.OfType())
- {
- //已经被连接的不允许在顶部吸附了
- if ((port.Orientation == ConnectorOrientation.Top || port.Orientation == ConnectorOrientation.Left) && port.DataItem.Prev != null)
+ foreach (var item in items)
+ {
+ foreach (var port in item.Connectors.OfType())
{
- continue;
- }
+ //已经被连接的不允许在顶部吸附了
+ if ((port.Orientation == ConnectorOrientation.Top || port.Orientation == ConnectorOrientation.Left) && port.DataItem.Prev != null)
+ {
+ continue;
+ }
- foreach (var port2 in blockDesignerItemTempLink.Connectors.OfType())
- {
//parent
if (parent == null)
{
if ((port.Orientation == ConnectorOrientation.Right && port2.Orientation == ConnectorOrientation.Left)
|| (port.Orientation == ConnectorOrientation.Bottom && port2.Orientation == ConnectorOrientation.Top))
{
-
- if (port.DistanceTo(port2) < diagramViewModel.DiagramOption.SnappingOption.BlockSnappingRadius)
+ var dis = port.DistanceTo(port2);
+ Debug.WriteLine($"{port.DataItem.Name}-{port2.DataItem.Name}:{dis}");
+ if (dis < diagramViewModel.DiagramOption.SnappingOption.BlockSnappingRadius)
{
port.DataItem.ShowConnectors = true;
- if (port2.CanAttachTo(port) == true)
+ if (port.CanAttachTo(port2) == true)
{
diagramViewModel.AddAttachTo(port, true);
parent = port;
@@ -79,11 +82,12 @@ namespace AIStudio.Wpf.DiagramDesigner
if ((port.Orientation == ConnectorOrientation.Left && port2.Orientation == ConnectorOrientation.Right)
|| (port.Orientation == ConnectorOrientation.Top && port2.Orientation == ConnectorOrientation.Bottom))
{
-
- if (port.Position.DistanceTo(port2.Position) < diagramViewModel.DiagramOption.SnappingOption.BlockSnappingRadius)
+ var dis = port.DistanceTo(port2);
+ Debug.WriteLine($"{port.DataItem.Name}-{port2.DataItem.Name}:{dis}");
+ if (dis < diagramViewModel.DiagramOption.SnappingOption.BlockSnappingRadius)
{
port.DataItem.ShowConnectors = true;
- if (port2.CanAttachTo(port) == true)
+ if (port.CanAttachTo(port2) == true)
{
diagramViewModel.AddAttachTo(port, true);
next = port;
@@ -105,6 +109,11 @@ namespace AIStudio.Wpf.DiagramDesigner
break;
}
}
+
+ if (success)
+ {
+ break;
+ }
}
return new Tuple(parent, next);
@@ -125,17 +134,17 @@ namespace AIStudio.Wpf.DiagramDesigner
{
var innerport = container.GetAllContainers(container.Children, false).Where(p => p.GetBounds().IntersectsWith(blockDesignerItemTempLink.GetBounds())).OrderByDescending(p => p.ContainerLevel).FirstOrDefault();
if (innerport != null)
- {
+ {
if (innerport.CanAttachTo(blockDesignerItemTempLink.Items.FirstOrDefault()) == true)
{
- innerport.DataItem.ShowConnectors = true;
+ innerport.DataItem.ShowConnectors = true;
if (innerport.OnlyOneChild || innerport.Children.Count == 0)
{
diagramViewModel.AddAttachTo(innerport, true);
}
else
{
- diagramViewModel.FindNearPortToAttachTo(innerport.Children.ToList(), blockDesignerItemTempLink);
+ diagramViewModel.FindNearPortToAttachTo(innerport.Children.ToList(), blockDesignerItemTempLink);
}
return innerport;
}
@@ -148,7 +157,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
else
{
-
+
if (container.CanAttachTo(blockDesignerItemTempLink.Items.FirstOrDefault()) == true)
{
container.DataItem.ShowConnectors = true;
@@ -158,7 +167,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
else
{
- diagramViewModel.FindNearPortToAttachTo(container.Children.ToList(), blockDesignerItemTempLink);
+ diagramViewModel.FindNearPortToAttachTo(container.Children.ToList(), blockDesignerItemTempLink);
}
return container;
}
@@ -209,11 +218,11 @@ namespace AIStudio.Wpf.DiagramDesigner
return;
if (blocks.Any())
- {
+ {
var links = BlockDesignerItemTempLink.Build(blocks);
blocks.ToList().ForEach(p => {
- p.ZIndex = diagramViewModel.Items.Any() ? diagramViewModel.Items.Where(q => q.ZIndex != int.MaxValue).Max(r => r.ZIndex) + 1 : 0;
+ p.ZIndex = diagramViewModel.Items.Where(q => q.ZIndex != int.MaxValue).Any() ? diagramViewModel.Items.Where(q => q.ZIndex != int.MaxValue).Max(r => r.ZIndex) + 1 : 0;
});
foreach (BlockDesignerItemTempLink item in links)
@@ -228,10 +237,10 @@ namespace AIStudio.Wpf.DiagramDesigner
index = container.Children.IndexOf(child);
if (child.RightConnector?.BeAttachTo == true || child.BottomConnector?.BeAttachTo == true)
{
- index ++;
+ index++;
}
}
- diagramViewModel.InsertChildCommand.Execute(new BlockContainerPara() { Item = container.DataItem, Child = item.Items.FirstOrDefault(), Container = container, Index = index });
+ diagramViewModel.InsertChildCommand.Execute(new BlockContainerPara() { Item = container.DataItem, Child = item.Items.FirstOrDefault(), Container = container, Index = index });
continue;
}
@@ -267,7 +276,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
}
-
+
diagramViewModel.ClearAttachTo();
}
}
diff --git a/Extensions/AIStudio.Wpf.Block/Dlls/net461/AIStudio.Wpf.Block.Core.dll b/Extensions/AIStudio.Wpf.Block/Dlls/net461/AIStudio.Wpf.Block.Core.dll
index 5c5ad96..5dfdba7 100644
Binary files a/Extensions/AIStudio.Wpf.Block/Dlls/net461/AIStudio.Wpf.Block.Core.dll and b/Extensions/AIStudio.Wpf.Block/Dlls/net461/AIStudio.Wpf.Block.Core.dll differ
diff --git a/Extensions/AIStudio.Wpf.Block/Dlls/net5.0-windows/AIStudio.Wpf.Block.Core.dll b/Extensions/AIStudio.Wpf.Block/Dlls/net5.0-windows/AIStudio.Wpf.Block.Core.dll
index 40ff471..7c5abd4 100644
Binary files a/Extensions/AIStudio.Wpf.Block/Dlls/net5.0-windows/AIStudio.Wpf.Block.Core.dll and b/Extensions/AIStudio.Wpf.Block/Dlls/net5.0-windows/AIStudio.Wpf.Block.Core.dll differ
diff --git a/Extensions/AIStudio.Wpf.Block/Dlls/net6.0-windows/AIStudio.Wpf.Block.Core.dll b/Extensions/AIStudio.Wpf.Block/Dlls/net6.0-windows/AIStudio.Wpf.Block.Core.dll
index 5efef0f..1c7f9ce 100644
Binary files a/Extensions/AIStudio.Wpf.Block/Dlls/net6.0-windows/AIStudio.Wpf.Block.Core.dll and b/Extensions/AIStudio.Wpf.Block/Dlls/net6.0-windows/AIStudio.Wpf.Block.Core.dll differ
diff --git a/Extensions/AIStudio.Wpf.SFC/AIStudio.Wpf.SFC_a2dtqtuc_wpftmp.csproj b/Extensions/AIStudio.Wpf.SFC/AIStudio.Wpf.SFC_a2dtqtuc_wpftmp.csproj
new file mode 100644
index 0000000..dcc2a7a
--- /dev/null
+++ b/Extensions/AIStudio.Wpf.SFC/AIStudio.Wpf.SFC_a2dtqtuc_wpftmp.csproj
@@ -0,0 +1,235 @@
+
+
+ AIStudio.Wpf.SFC
+ obj\Debug\
+ obj\
+ F:\aistudio.-wpf.-diagram\Extensions\AIStudio.Wpf.SFC\obj\
+ <_TargetAssemblyProjectName>AIStudio.Wpf.SFC
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Extensions/AIStudio.Wpf.Script/AIStudio.Wpf.Script_iozmnnjw_wpftmp.csproj b/Extensions/AIStudio.Wpf.Script/AIStudio.Wpf.Script_iozmnnjw_wpftmp.csproj
new file mode 100644
index 0000000..7d1a01b
--- /dev/null
+++ b/Extensions/AIStudio.Wpf.Script/AIStudio.Wpf.Script_iozmnnjw_wpftmp.csproj
@@ -0,0 +1,276 @@
+
+
+ AIStudio.Wpf.Script
+ obj\Debug\
+ obj\
+ F:\aistudio.-wpf.-diagram\Extensions\AIStudio.Wpf.Script\obj\
+ <_TargetAssemblyProjectName>AIStudio.Wpf.Script
+
+
+
+ true
+ AIStudio.Wpf.Controls
+ akwkevin
+ https://gitee.com/akwkevin
+ A.png
+
+
+ 1.0.6
+ 一个Wpf的脚本生成模块
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file