Esempio n. 1
0
        public void DrawTabHeader(Graphics g, Font font, Point pos, int width)
        {
            var sz    = ScreenScale.Calc();
            var xleft = Convert.ToInt32(3 * sz);

            switch (sideTabStatus)
            {
            case SideTabStatus.Normal:
                ControlPaint.DrawBorder3D(g, new Rectangle(0, pos.Y, width - 4, font.Height + 4), Border3DStyle.RaisedInner);
                g.DrawString(displayName, font, SystemBrushes.ControlText, new RectangleF(1 + xleft, pos.Y + 1, width - 5, font.Height + 1));

                break;

            case SideTabStatus.Selected:
                ControlPaint.DrawBorder3D(g, new Rectangle(0, pos.Y, width - 4, font.Height + 4), Border3DStyle.Sunken);
                g.DrawString(displayName, font, SystemBrushes.ControlText, new RectangleF(1 + 1 + xleft, pos.Y + 2, width - 5, font.Height + 2));
                break;

            case SideTabStatus.Dragged:
                Rectangle r = new Rectangle(0, pos.Y, width - 4, font.Height + 4);
                ControlPaint.DrawBorder3D(g, r, Border3DStyle.RaisedInner);
                r.X      += 2;
                r.Y      += 1;
                r.Width  -= 4;
                r.Height -= 2;

                g.FillRectangle(SystemBrushes.ControlDarkDark, r);

                g.DrawString(displayName, font, SystemBrushes.HighlightText, new RectangleF(1 + 1 + xleft, pos.Y + 2, width - 5, font.Height + 2));
                break;
            }
        }
Esempio n. 2
0
        public virtual void DrawItem(Graphics g, Font f, Rectangle rectangle)
        {
            var   sz    = ScreenScale.Calc();
            var   xleft = Convert.ToInt32(3 * sz);
            float width = 0;

            if (Icon != null)
            {
                width = Icon.Width;
            }
            var YDelta      = Convert.ToInt32(Math.Max(0, (rectangle.Height - g.MeasureString("AgQ", f).Height) / 2));
            var stringPoint = new PointF(rectangle.X + width * (float)sz + 1 + xleft, rectangle.Y + YDelta);
            var imageRect   = new Rectangle(xleft, rectangle.Y + YDelta, Convert.ToInt32(16 * sz), Convert.ToInt32(16 * sz));

            switch (sideTabItemStatus)
            {
            case SideTabItemStatus.Normal:
                if (Icon != null)
                {
                    //g.DrawImage(Icon, 0, rectangle.Y);
                    g.DrawImage(Icon, imageRect);
                }
                g.DrawString(name, f, SystemBrushes.ControlText, stringPoint);
                break;

            case SideTabItemStatus.Drag:
                ControlPaint.DrawBorder3D(g, rectangle, Border3DStyle.RaisedInner);
                rectangle.X      += 1;
                rectangle.Y      += 1;
                rectangle.Width  -= 2;
                rectangle.Height -= 2;

                g.FillRectangle(SystemBrushes.ControlDarkDark, rectangle);
                if (Icon != null)
                {
                    //g.DrawImage(Icon, 0, rectangle.Y);
                    g.DrawImage(Icon, imageRect);
                }
                g.DrawString(name, f, SystemBrushes.HighlightText, stringPoint);
                break;

            case SideTabItemStatus.Selected:
                ControlPaint.DrawBorder3D(g, rectangle, Border3DStyle.RaisedInner);
                if (Icon != null)
                {
                    //g.DrawImage(Icon, 0, rectangle.Y);
                    g.DrawImage(Icon, imageRect);
                }
                g.DrawString(name, f, SystemBrushes.ControlText, stringPoint);
                break;

            case SideTabItemStatus.Chosen:
                ControlPaint.DrawBorder3D(g, rectangle, Border3DStyle.Sunken);
                rectangle.X      += 1;
                rectangle.Y      += 1;
                rectangle.Width  -= 2;
                rectangle.Height -= 2;

                using (Brush brush = new SolidBrush(ControlPaint.Light(SystemColors.Control))) {
                    g.FillRectangle(brush, rectangle);
                }

                if (Icon != null)
                {
                    //g.DrawImage(Icon, 1, rectangle.Y + 1);
                    imageRect.Offset(1, 1);
                    g.DrawImage(Icon, imageRect);
                }
                stringPoint.X += 1;
                stringPoint.Y += 1;
                g.DrawString(name, f, SystemBrushes.ControlText, stringPoint);
                break;
            }
        }