mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-14 13:36:38 +08:00
block
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user