Exemple #1
0
        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();

            //
            // RootTree has priority - so it is painted last but its panel is saved first in the hList
            if (treeNode != null)
            {
                Rectangle rootBounds = new Rectangle(
                    -Controller.OffsetX, 0,
                    Size.Width, Controller.DisplayOptions.RootHeight);

                // note  for root hpanel treeNode of nodepanel is null
                _hLayout.Add(new NodePanel(null, rootBounds));
            }

            while (treeNode != null)
            {
                if (treeNode.IsCollapsed == false || treeNode.IsHidden)
                {
                    treeNode = iterator.Next();
                }
                else
                {
                    DrawPanel(g, treeNode, y);
                    y += Controller.DisplayOptions.CellHeight;

                    treeNode = iterator.Skip();
                }
            }

            Size = new Size(y + Controller.OffsetY - Controller.DisplayOptions.RootHeight + 1, y + Controller.OffsetY + 1);

            DrawGroupingSquares(g);

            DrawRootPanel(g);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        private void DrawRootPanel(Graphics g)
        {
            int stateDisplay = 0;  // tri-state optimisation 0 not started dispaying, 1 currently displaying
                                   // 2 finished displaying and can therefore break out of the loop

            int x = -Controller.OffsetX;

            TreeIterator <Element> iterator = new TreeIterator <Element>(Controller.MatrixModel.Hierarchy);
            TreeNode <Element>     treeNode = iterator.Next();

            while (treeNode != null && stateDisplay != 2)
            {
                Element module = treeNode.NodeValue;

                if (treeNode.IsCollapsed == false || treeNode.IsHidden)
                {
                    treeNode = iterator.Next();
                }
                else
                {
                    Rectangle cell = new Rectangle(x, 0,
                                                   Controller.DisplayOptions.CellHeight, Controller.DisplayOptions.RootHeight - 2);

                    if (g.Clip.IsVisible(cell))
                    {
                        // for each visible cell we create a vertical panel in vLayout of
                        // height of _matrix
                        Rectangle vPanelRec =
                            new Rectangle(x, 0, Controller.DisplayOptions.CellHeight, Size.Height);
                        _vLayout.Add(new NodePanel(treeNode, vPanelRec));

                        g.FillRectangle(
                            Controller.ConsumerTreeNode == treeNode
                                ? Brushes.White
                                : Controller.GetBackgroundColour(treeNode, null), cell);

                        if (treeNode.HasChildren)
                        {
                            g.DrawImage(_imgCollapsed, cell.Left + (cell.Width / 2.0f) - 4, cell.Top + 2);
                        }

                        g.DrawString(module.Id.ToString(), Controller.DisplayOptions.TextFont,
                                     _fcBrush, x, 10, _vStringFormat);

                        g.DrawRectangle(_borderPen, cell);
                        g.DrawLine(new Pen(Brushes.White, 1),
                                   cell.Left, cell.Bottom + 1, cell.Right, cell.Bottom + 1);

                        if (stateDisplay == 0)
                        {
                            stateDisplay++;
                        }
                    }
                    else if (stateDisplay == 1)
                    {
                        stateDisplay++; // finished displaying
                    }
                    x += Controller.DisplayOptions.CellHeight;

                    treeNode = iterator.Skip();
                }
            }
        }