mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-02 07:06:37 +08:00
mind 进行中
This commit is contained in:
@@ -51,16 +51,50 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
public double Spacing
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
} = 20;
|
||||
|
||||
public List<MindNode> Children
|
||||
{
|
||||
get; set;
|
||||
} = new List<MindNode>();
|
||||
|
||||
public SizeBase SizeWithSpacing
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Size.Add(Spacing * 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public SizeBase GetSize()
|
||||
{
|
||||
var sizewithSpacing = SizeWithSpacing;
|
||||
if (Children?.Count > 0)
|
||||
{
|
||||
var childrensizes = Children.Select(p => p.GetSize());
|
||||
sizewithSpacing = new SizeBase(sizewithSpacing.Width + childrensizes.Max(p => p.Width), Math.Max(sizewithSpacing.Height, childrensizes.Sum(p => p.Height)));
|
||||
}
|
||||
return sizewithSpacing;
|
||||
}
|
||||
|
||||
|
||||
public void LayoutUpdated()
|
||||
{
|
||||
var totalsize = GetSize();
|
||||
|
||||
double left = MiddlePosition.X + ItemWidth / 2 + Spacing;
|
||||
double top = MiddlePosition.Y - totalsize.Height / 2;
|
||||
if (Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in Children)
|
||||
{
|
||||
child.Left = left + Spacing;
|
||||
child.Top = top + Spacing;
|
||||
top += child.SizeWithSpacing.Height;
|
||||
|
||||
child.LayoutUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MindLevel1Node : MindNode
|
||||
@@ -84,24 +118,23 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void LayoutUpdated()
|
||||
protected override void Init(IDiagramViewModel root)
|
||||
{
|
||||
foreach(var child in Children)
|
||||
{
|
||||
base.Init(root);
|
||||
|
||||
}
|
||||
ItemWidth = 80;
|
||||
ItemHeight = 40;
|
||||
this.ClearConnectors();
|
||||
var port = new FullyCreatedConnectorInfo(root, this, ConnectorOrientation.None, true) { XRatio = 0.5, YRatio = 0.5 };
|
||||
this.AddConnector(port);
|
||||
IsInnerConnector = true;
|
||||
}
|
||||
|
||||
public RectangleBase Rectangle
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
//public RectangleBase GetChildRectangle()
|
||||
//{
|
||||
// //Children.Select(p => p.Size)
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
public class MindLevel2Node : MindNode
|
||||
@@ -126,6 +159,20 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
|
||||
}
|
||||
|
||||
protected override void Init(IDiagramViewModel root)
|
||||
{
|
||||
base.Init(root);
|
||||
|
||||
ItemWidth = 80;
|
||||
ItemHeight = 40;
|
||||
this.ClearConnectors();
|
||||
var port1 = new FullyCreatedConnectorInfo(root, this, ConnectorOrientation.None, true) { XRatio = 0, YRatio = 0.5 };
|
||||
this.AddConnector(port1);
|
||||
var port2 = new FullyCreatedConnectorInfo(root, this, ConnectorOrientation.None, true) { XRatio = 1, YRatio = 0.5 };
|
||||
this.AddConnector(port2);
|
||||
IsInnerConnector = true;
|
||||
}
|
||||
|
||||
public PointBase Offset
|
||||
{
|
||||
get; set;
|
||||
@@ -153,7 +200,19 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
||||
{
|
||||
|
||||
}
|
||||
protected override void Init(IDiagramViewModel root)
|
||||
{
|
||||
base.Init(root);
|
||||
|
||||
ItemWidth = 80;
|
||||
ItemHeight = 40;
|
||||
this.ClearConnectors();
|
||||
var port1 = new FullyCreatedConnectorInfo(root, this, ConnectorOrientation.None, true) { XRatio = 0, YRatio = 1 };
|
||||
this.AddConnector(port1);
|
||||
var port2 = new FullyCreatedConnectorInfo(root, this, ConnectorOrientation.None, true) { XRatio = 1, YRatio = 1 };
|
||||
this.AddConnector(port2);
|
||||
IsInnerConnector = true;
|
||||
}
|
||||
public PointBase Offset
|
||||
{
|
||||
get; set;
|
||||
|
||||
Reference in New Issue
Block a user