Exemple #1
0
        void DrawPanel(Graphics g, Rectangle bounds, TreeNode <Element> treeNode)
        {
            Element module = treeNode.NodeValue;

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

            if (treeNode.HasChildren)
            {
                if (treeNode.IsCollapsed)
                {
                    g.DrawImage(_imgCollapsed, bounds.Left + 4, bounds.Top + 4);
                    g.DrawString(module.Name + " - " + module.Id,
                                 GetNodeFont(treeNode), Brushes.Black, bounds.Left + 18, bounds.Top + 2);
                }
                else
                {
                    g.DrawImage(_imgExpanded, bounds.Left + 4, bounds.Top + 4);
                    g.DrawString(module.Name, GetNodeFont(treeNode), Brushes.Black,
                                 bounds.Left, bounds.Top + 18, _vStringFormat);
                }
            }
            else
            {
                g.DrawString(module.Name + " - " + module.Id, GetNodeFont(treeNode), Brushes.Black,
                             bounds.Left + 2, bounds.Top + 2);
            }



            g.DrawRectangle(_borderPen, bounds);
        }
Exemple #2
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();
                }
            }
        }