public VisualTask(ITask task, IGraphContainer parentContainer) { Task = task; BindTask(); var container = new GraphContainerVertical(); AddBox(container); if (task.Children != null) { var childContainer = new GraphContainerHorizontal(); foreach (var child in task.Children) { _children.Add(new VisualTask(child, childContainer)); } AddDivider(container, childContainer); container.AddBox(childContainer); } parentContainer.AddBox(container); _printer = new NodePrintController(this); }
public void It_should_align_a_child_in_the_center() { _childBox.Width.Returns(50); var children = new GraphContainerHorizontal(); children.AddBox(A.GraphBoxStub().WithSize(50, 50).Build()); children.AddBox(A.GraphBoxStub().WithSize(50, 50).Build()); var wrapper = new GraphContainerVertical(); wrapper.AddBox(_childBox); wrapper.AddBox(children); _container.AddBox(wrapper); _container.CenterAlignChildren(); _childBox.Received(1).AddGlobalPosition(25, 0); }
public void Root_should_push_down_the_next_node() { var tree = new GraphContainerVertical(); tree.SetGlobalPosition(300, 0); var nodeWrapper = new GraphContainerVertical(); var box = new GraphBox(); box.SetSize(50, 50); var childrenContainer = new GraphContainerHorizontal(); var childWrapper = new GraphContainerVertical(); var childBox = new GraphBox(); childBox.SetSize(50, 50); nodeWrapper.AddBox(box); Assert.AreEqual(50, nodeWrapper.Height); Assert.AreEqual(50, nodeWrapper.Width); Assert.AreEqual(0, box.GlobalPositionY); childWrapper.AddBox(childBox); Assert.AreEqual(50, nodeWrapper.Height); Assert.AreEqual(50, nodeWrapper.Width); childrenContainer.AddBox(childWrapper); Assert.AreEqual(50, nodeWrapper.Height); Assert.AreEqual(50, nodeWrapper.Width); Assert.AreEqual(0, childrenContainer.GlobalPositionY); nodeWrapper.AddBox(childrenContainer); Assert.AreEqual(100, nodeWrapper.Height); Assert.AreEqual(50, nodeWrapper.Width); Assert.AreEqual(50, childrenContainer.GlobalPositionY); tree.AddBox(nodeWrapper); Assert.AreEqual(0, nodeWrapper.LocalPositionY); Assert.AreEqual(0, nodeWrapper.GlobalPositionY); Assert.AreEqual(50, childrenContainer.GlobalPositionY); Assert.AreEqual(0, box.GlobalPositionY); }