mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-04 08:06:36 +08:00
添加block快,不需要连接线,直接吸附。
This commit is contained in:
@@ -96,9 +96,53 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
||||
item.SetCellAlignment();
|
||||
}
|
||||
|
||||
var blocks = designerItems.OfType<BlockDesignerItemViewModel>().ToList();
|
||||
if (blocks.Any())
|
||||
{
|
||||
foreach (BlockDesignerItemViewModel item in blocks)
|
||||
{
|
||||
var portTuple = DiagramViewModel.FindNearPortToAttachTo(item, true);
|
||||
var portParent = portTuple.Item1;
|
||||
var portNext = portTuple.Item2;
|
||||
|
||||
if (portParent != null)
|
||||
{
|
||||
(portParent.DataItem as BlockDesignerItemViewModel).AddNext(item);
|
||||
portParent.BeAttachTo = false;
|
||||
portParent.DisableAttachTo = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.Parent != null)
|
||||
{
|
||||
(item.Parent as BlockDesignerItemViewModel).Next = null;
|
||||
item.Parent = null;
|
||||
item.ParentId = new Guid();
|
||||
}
|
||||
}
|
||||
|
||||
if (portNext != null)
|
||||
{
|
||||
item.AddNext(portNext.DataItem as BlockDesignerItemViewModel);
|
||||
portNext.BeAttachTo = false;
|
||||
portNext.DisableAttachTo = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.Next != null)
|
||||
{
|
||||
item.Next.Parent = null;
|
||||
item.Next.ParentId = new Guid();
|
||||
item.Next = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
//-DiagramViewModel.ClearNearPort();
|
||||
}
|
||||
|
||||
Dictionary<DesignerItemViewModelBase, Tuple<PointBase, PointBase>> infos =
|
||||
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
||||
p => new Tuple<PointBase, PointBase>(p.GetOldValue<PointBase>(nameof(p.TopLeft)), p.TopLeft));
|
||||
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
||||
p => new Tuple<PointBase, PointBase>(p.GetOldValue<PointBase>(nameof(p.TopLeft)), p.TopLeft));
|
||||
|
||||
//部分连接点可以移动
|
||||
Dictionary<ConnectionViewModel, Tuple<Tuple<PointBase?, PointBase?>, Tuple<PointBase?, PointBase?>>> conncetorinfos =
|
||||
@@ -162,6 +206,15 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
||||
item.SetPartPostion(sourcePoint, sinkPoint);
|
||||
}
|
||||
|
||||
var blocks = designerItems.OfType<BlockDesignerItemViewModel>().ToList();
|
||||
if (blocks.Any())
|
||||
{
|
||||
DiagramViewModel.ClearNearPort();
|
||||
foreach (BlockDesignerItemViewModel item in blocks)
|
||||
{
|
||||
DiagramViewModel.FindNearPortToAttachTo(item, false);
|
||||
}
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user