This commit is contained in:
艾竹
2023-06-17 23:55:54 +08:00
parent 56545ece4b
commit 0b0f81faac
12 changed files with 346 additions and 81 deletions

View File

@@ -1,24 +1,72 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
namespace AIStudio.Wpf.DiagramDesigner
{
public class BlockDesignerItemTempLink
{
List<BlockDesignerItemViewModel> Items
public List<BlockDesignerItemViewModel> Items
{
get;set;
get; set;
} = new List<BlockDesignerItemViewModel>();
//public static List<BlockDesignerItemTempLink> Build(List<BlockDesignerItemViewModel> blocks)
//{
// List<BlockDesignerItemTempLink> links = new List<BlockDesignerItemTempLink>(){
// new BlockDesignerItemTempLink() };
public RectangleBase GetBounds(bool includePorts = false)
{
return Items.FirstOrDefault().GetBounds();
}
// foreach(var )
//}
public List<FullyCreatedConnectorInfo> Connectors
{
get
{
List<FullyCreatedConnectorInfo> connectors = new List<FullyCreatedConnectorInfo>();
if (Items.FirstOrDefault().TopConnector != null)
{
connectors.Add(Items.FirstOrDefault().TopConnector);
}
if (Items.FirstOrDefault().LeftConnector != null)
{
connectors.Add(Items.FirstOrDefault().LeftConnector);
}
if (Items.LastOrDefault().BottomConnector != null)
{
connectors.Add(Items.LastOrDefault().BottomConnector);
}
if (Items.LastOrDefault().RightConnector != null)
{
connectors.Add(Items.LastOrDefault().RightConnector);
}
return connectors;
}
}
public static List<BlockDesignerItemTempLink> Build(List<BlockDesignerItemViewModel> blocks)
{
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;
}
}
if (success == false)
{
BlockDesignerItemTempLink link = new BlockDesignerItemTempLink();
link.Items.Add(block);
links.Add(link);
}
}
return links;
}
}
}