mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
Block图鉴
This commit is contained in:
@@ -37,30 +37,35 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
IsReadOnlyText = true;
|
||||
}
|
||||
|
||||
public void AddNext(BlockDesignerItemViewModel next)
|
||||
public void AddNext(BlockDesignerItemViewModel next, bool first = true)
|
||||
{
|
||||
if (this.Next == next)
|
||||
{
|
||||
AlignNext(next);
|
||||
return;
|
||||
}
|
||||
var oldnext = this.Next;
|
||||
RemoveNext();
|
||||
|
||||
if (next.Prev != null)
|
||||
{
|
||||
next.Prev.RemoveNext();
|
||||
}
|
||||
|
||||
var oldnext = RemoveNext();
|
||||
|
||||
next.Left = this.Left;
|
||||
next.Top = this.Top + this.GetItemHeight();
|
||||
next.ParentId = this.Id;
|
||||
next.Parent = this;
|
||||
next.Prev = this;
|
||||
this.Next = next;
|
||||
if (next.Next != null)
|
||||
{
|
||||
next.AlignNext(next.Next);
|
||||
}
|
||||
if (oldnext != null)
|
||||
if (oldnext != null && first == true)
|
||||
{
|
||||
System.Windows.Application.Current?.Dispatcher.BeginInvoke(new Action(async () => {
|
||||
await Task.Delay(10);
|
||||
GetLast().AddNext(oldnext);
|
||||
GetLast().AddNext(oldnext, false);
|
||||
}));
|
||||
|
||||
}
|
||||
@@ -79,14 +84,19 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveNext()
|
||||
public BlockDesignerItemViewModel RemoveNext()
|
||||
{
|
||||
var next = this.Next;
|
||||
if (next != null)
|
||||
{
|
||||
next.ParentId = new Guid();
|
||||
next.Parent = null;
|
||||
next.Prev = null;
|
||||
this.Next = null;
|
||||
return next;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,6 +187,13 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
return Parent as BlockDesignerItemViewModel;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (Parent != value)
|
||||
{
|
||||
Parent = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BlockDesignerItemViewModel Next
|
||||
@@ -223,9 +240,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
var parent = this.Next;
|
||||
if (parent != null)
|
||||
{
|
||||
while (parent.Parent != null)
|
||||
while (parent.Prev != null)
|
||||
{
|
||||
parent = parent.Parent as BlockDesignerItemViewModel;
|
||||
parent = Prev;
|
||||
}
|
||||
}
|
||||
return parent;
|
||||
@@ -387,12 +404,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
List<BlockDesignerItemTempLink> links = new List<BlockDesignerItemTempLink>();
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user