Exemple #1
0
        private void doPaint(Graphics g)
        {
            // Brush backBrush = new SolidBrush(Color.DarkMagenta);
            Rectangle cr           = ClientRectangle;
            Rectangle deleteButton = getDeleteButton();
            Rectangle shrinkButton = getShrinkButton();
            Rectangle activeButton = getActiveButton();

            int x1 = 0;
            int x2 = Width - 1;

            x2 -= deleteButton.Width;
            if (_hasActiveSwitch)
            {
                x1 += activeButton.Width;
            }
            if (_canShrink)
            {
                x2 -= shrinkButton.Width;
            }
            int centerpos = (x1 + x2) / 2;

            cr.Width  -= 1;
            cr.Height -= 1;
            if (_selected)
            {
                g.DrawRectangle(selectPen, cr);
            }
            else
            {
                g.DrawRectangle(framePen, cr);
            }

            if (_shrinked)
            {
                if ((_shrinkTitle != null) && (_shrinkTitle.Length > 0))
                {
                    GraphicsUtil.drawText(g, Vector.V(centerpos, 0), _titleFont, scale,
                                          _shrinkTitle, 0, 2, 0, 1, Vector.X, titleBrush);
                }
            }
            else
            {
                if ((_title != null) && (_title.Length > 0))
                {
                    GraphicsUtil.drawText(g, Vector.V(centerpos, 0), _titleFont, scale,
                                          _title, 0, 2, 0, 1, Vector.X, titleBrush);
                }
            }

            //if (_selected)
            //    framePen = new Pen(Color.Red);
            // g.DrawLine(framePen, new PointF((float)scale * 5, (float)scale * 15), new PointF((float) (Width - scale*5), (float)scale * 15));

            if ((dragMode == DragMode.DeleteBtn) && onDeleteButton)
            {
                GraphicsUtil.drawButton(g, deleteButton, GraphicsUtil.ButtonType.Delete, framePen, symbolOnPen);
            }
            else
            {
                GraphicsUtil.drawButton(g, deleteButton, GraphicsUtil.ButtonType.Delete, framePen, symbolPen);
            }
            if (_canShrink)
            {
                if ((dragMode == DragMode.ShrinkBtn) && onShrinkButton)
                {
                    GraphicsUtil.drawButton(g, shrinkButton, (_shrinked) ? GraphicsUtil.ButtonType.Expand : GraphicsUtil.ButtonType.Shrink, framePen, symbolOnPen);
                }
                else
                {
                    GraphicsUtil.drawButton(g, shrinkButton, (_shrinked) ? GraphicsUtil.ButtonType.Expand : GraphicsUtil.ButtonType.Shrink, framePen, symbolPen);
                }
            }
            if (_hasActiveSwitch)
            {
                bool showActive = _active;
                if ((dragMode == DragMode.ActiveBtn) && onActiveButton)
                {
                    showActive = !_active;
                }
                if (showActive)
                {
                    g.FillRectangle(activeBrush, activeButton);
                    GraphicsUtil.drawButton(g, activeButton, GraphicsUtil.ButtonType.Active, framePen, activePen);
                }
                else
                {
                    GraphicsUtil.drawButton(g, activeButton, GraphicsUtil.ButtonType.InActive, framePen, passivePen);
                }
            }
        }