void DrawGroupingSquares(Graphics g) { TreeIterator <Element> iterator = new TreeIterator <Element>(Controller.MatrixModel.Hierarchy); TreeNode <Element> treeNode = iterator.Next(); int xPos = -Controller.OffsetX + 1; int yPos = -Controller.OffsetY + Controller.DisplayOptions.RootHeight + 1; while (treeNode != null) { if (treeNode.IsHidden == false) { if (treeNode.IsCollapsed == false) { int width = Controller.CountNbDisplayableNested(treeNode) * Controller.DisplayOptions.CellHeight; Rectangle rect = new Rectangle(xPos, yPos, width - 1, width - 1); if (g.Clip.IsVisible(rect)) { g.DrawRectangle(new Pen(Brushes.DarkGray, 2), rect); } treeNode = iterator.Next(); } else { xPos += Controller.DisplayOptions.CellHeight; yPos += Controller.DisplayOptions.CellHeight; treeNode = iterator.Skip(); } } else { treeNode = iterator.Next(); } } }
void Draw(Graphics g) { int y = -Controller.OffsetY + Controller.DisplayOptions.RootHeight; TreeIterator <Element> iterator = new TreeIterator <Element>(Controller.MatrixModel.Hierarchy); TreeNode <Element> treeNode = iterator.Next(); while (treeNode != null) { if (treeNode.IsHidden == false) { if (treeNode.IsCollapsed == false) { Rectangle bounds = new Rectangle( treeNode.Depth * Controller.DisplayOptions.CellHeight, y, Controller.DisplayOptions.CellHeight, Controller.CountNbDisplayableNested(treeNode) * Controller.DisplayOptions.CellHeight); if (g.Clip.IsVisible(bounds)) { DrawPanel(g, bounds, treeNode); _layout.Add(new NodePanel(treeNode, bounds)); } // y position does not change for next treeNode treeNode = iterator.Next(); } else { // treeNode is collapsed - draw the module at position // if the treeNode has childrenskip them int x = treeNode.Depth * Controller.DisplayOptions.CellHeight; Rectangle bounds = new Rectangle(x, y, Size.Width - x, Controller.DisplayOptions.CellHeight); if (g.Clip.IsVisible(bounds)) { DrawPanel(g, bounds, treeNode); _layout.Add(new NodePanel(treeNode, bounds)); } // position for next panel y += Controller.DisplayOptions.CellHeight; treeNode = iterator.Skip(); } } else { treeNode = iterator.Next(); } } Size = new Size(Size.Width, y + Controller.OffsetY); g.DrawRectangle(_borderPen, new Rectangle(0, 0, Width - 1, Height - 1)); Rectangle rootBounds = new Rectangle(0, 0, Size.Width - 1, Controller.DisplayOptions.RootHeight - 2); DrawRootPanel(g, rootBounds); }