mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-20 00:16:36 +08:00
嗯,自动获取曲线方向
This commit is contained in:
@@ -66,32 +66,42 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public SizeBase GetSize()
|
||||
public SizeBase DesiredSize
|
||||
{
|
||||
get;set;
|
||||
}
|
||||
|
||||
public SizeBase MeasureOverride()
|
||||
{
|
||||
var sizewithSpacing = SizeWithSpacing;
|
||||
if (Children?.Count > 0)
|
||||
{
|
||||
var childrensizes = Children.Select(p => p.GetSize());
|
||||
var childrensizes = Children.Select(p => p.MeasureOverride()).ToArray();
|
||||
sizewithSpacing = new SizeBase(sizewithSpacing.Width + childrensizes.Max(p => p.Width), Math.Max(sizewithSpacing.Height, childrensizes.Sum(p => p.Height)));
|
||||
}
|
||||
return sizewithSpacing;
|
||||
DesiredSize = sizewithSpacing;
|
||||
return DesiredSize;
|
||||
}
|
||||
|
||||
public void LayoutUpdated()
|
||||
{
|
||||
var totalsize = GetSize();
|
||||
var size = MeasureOverride();
|
||||
ArrangeOverride(size);
|
||||
}
|
||||
|
||||
public void ArrangeOverride(SizeBase sizeBase)
|
||||
{
|
||||
double left = MiddlePosition.X + ItemWidth / 2 + Spacing;
|
||||
double top = MiddlePosition.Y - totalsize.Height / 2;
|
||||
double top = MiddlePosition.Y - sizeBase.Height / 2;
|
||||
if (Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in Children)
|
||||
{
|
||||
child.Left = left + Spacing;
|
||||
child.Top = top + Spacing;
|
||||
top += child.SizeWithSpacing.Height;
|
||||
child.Top = top + child.DesiredSize.Height / 2 - child.ItemHeight;
|
||||
top += child.DesiredSize.Height;
|
||||
|
||||
child.LayoutUpdated();
|
||||
child.ArrangeOverride(child.DesiredSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user