Ejemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var g = e.Graphics;

            g.FillRectangle(UserBrushes.Window, ClientRectangle);
            var width     = 0;
            var textColor = UserColors.Text;
            var corner    = "Corner";
            var cross     = "Cross";

            if (SelectedItem != null)
            {
                currentWidth = width = (Int32)g.MeasureString(SelectedItem.Caption, Fonts.Caption).Width;
            }

            if (hoverItem == 0 || contextMenu.Visible)
            {
                g.FillRectangle(UserBrushes.Selection, new Rectangle(Dpi.ScaleX(3), Dpi.ScaleY(4), Dpi.ScaleX(12) + width, Dpi.ScaleY(14)));
                textColor = UserColors.HighlightText;
                corner    = "CornerWhite";
            }
            else if (hoverItem == 1)
            {
                g.FillRectangle(UserBrushes.Selection, new Rectangle(ClientSize.Width - Dpi.ScaleX(17), Dpi.ScaleY(4), Dpi.ScaleX(14), Dpi.ScaleY(14)));
                cross = "CrossWhite";
            }

            using (var bmp = Bitmaps.Load(corner))
                g.DrawImage(bmp, new Rectangle(Dpi.ScaleX(5), Dpi.ScaleY(9), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));

            using (var bmp = Bitmaps.Load(cross))
                g.DrawImage(bmp, new Rectangle(ClientSize.Width - Dpi.ScaleX(15), Dpi.ScaleY(7), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));

            g.DrawRectangle(UserPens.Border, new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - Dpi.ScaleX(1), ClientRectangle.Height));

            if (SelectedItem != null)
            {
                TextRenderer.DrawText(g, SelectedItem.Caption, Fonts.Caption, new Rectangle(Dpi.ScaleX(14), 0, width + Dpi.ScaleY(20), ClientSize.Height), textColor,
                                      TextFormatFlags.VerticalCenter | TextFormatFlags.Left | TextFormatFlags.EndEllipsis);
            }
        }
Ejemplo n.º 2
0
        private void DrawHeader(ListGroup group, DrawItemEventArgs e)
        {
            var caption = group.Title;

            e.Graphics.FillRectangle(UserBrushes.Window, e.Bounds);

            using (var font = new Font(e.Font, FontStyle.Bold))
            {
                if (group.Expanded)
                {
                    e.Graphics.DrawImage(Bitmaps.Load("ArrowDownGray"), e.Bounds.X + Dpi.ScaleX(5), e.Bounds.Y + Dpi.ScaleY(7));
                }
                else
                {
                    e.Graphics.DrawImage(Bitmaps.Load("ArrowGray"), e.Bounds.X + Dpi.ScaleX(7), e.Bounds.Y + Dpi.ScaleY(5));
                }

                var captionSize = e.Graphics.MeasureString(caption, font);
                e.Graphics.DrawString(caption, font, SystemBrushes.ControlText,
                                      e.Bounds.X + Dpi.ScaleX(14), e.Bounds.Y + (e.Bounds.Height - captionSize.Height) / 2);
            }
        }
Ejemplo n.º 3
0
        private void PaintMain(Graphics g, bool fast = false)
        {
            var textColor = UserColors.Text;
            var corner    = "Corner";

            var rect = new Rectangle(0, 0, ClientSize.Width - Dpi.ScaleX(1), Dpi.ScaleY(HEIGHT));

            if (!fast)
            {
                var fullRect = new Rectangle(0, 0, ClientSize.Width - Dpi.ScaleX(1), ClientSize.Height - Dpi.ScaleY(1));
                g.FillRectangle(UserBrushes.Window, rect);
                g.DrawRectangle(UserPens.Border, rect);
                g.DrawRectangle(UserPens.Border, fullRect);
            }

            var text        = SelectedDocument != null ? SelectedDocument.Caption : String.Empty;
            var captionRect = new Rectangle(Dpi.ScaleX(15), 0, ClientSize.Width - Dpi.ScaleY(LABELS_WIDTH), Dpi.ScaleY(HEIGHT));
            var flags       = TextFormatFlags.Left | TextFormatFlags.PathEllipsis | TextFormatFlags.VerticalCenter;

            lastWidth = (Int32)g.MeasureString(text, Fonts.Header).Width;

            if (lastWidth > captionRect.Width)
            {
                lastWidth = captionRect.Width;
            }

            if (hoverItem == 0 || contextMenu.Visible)
            {
                textColor = UserColors.HighlightText;
                corner    = "CornerWhite";
                g.FillRectangle(UserBrushes.Selection, new Rectangle(Dpi.ScaleX(3), Dpi.ScaleY(4), Dpi.ScaleX(16) + lastWidth, Dpi.ScaleY(14)));
            }
            else if (hoverItem == -1 && fast)
            {
                g.FillRectangle(UserBrushes.Window, new Rectangle(Dpi.ScaleX(3), Dpi.ScaleY(4), Dpi.ScaleX(16) + lastWidth, Dpi.ScaleY(14)));
            }

            TextRenderer.DrawText(g, text, Fonts.Header, captionRect, textColor, flags);

            if (Items.Count > 1)
            {
                using (var bmp = Bitmaps.Load(corner))
                    g.DrawImage(bmp, new Rectangle(Dpi.ScaleX(5), Dpi.ScaleY(9), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));
            }
            else if (Items.Count == 1)
            {
                using (var bmp = Bitmaps.Load("CornerDisabled"))
                    g.DrawImage(bmp, new Rectangle(Dpi.ScaleX(7), Dpi.ScaleY(7), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));
            }

            if (InfoBarVisible && !fast)
            {
                TextRenderer.DrawText(g, Overtype ? "OVR" : "INS", Fonts.Header, new Rectangle(ClientSize.Width - Dpi.ScaleX(32), 0, Dpi.ScaleX(30), Dpi.ScaleY(HEIGHT)), UserColors.Text, flags);
                TextRenderer.DrawText(g, Column.ToString(), Fonts.Menu, new Rectangle(ClientSize.Width - Dpi.ScaleX(68), 0, Dpi.ScaleX(25), Dpi.ScaleY(HEIGHT)), UserColors.Text, flags);
                TextRenderer.DrawText(g, "Col", Fonts.Header, new Rectangle(ClientSize.Width - Dpi.ScaleX(90), 0, Dpi.ScaleX(25), Dpi.ScaleY(20)), UserColors.Text, flags);
                TextRenderer.DrawText(g, Line.ToString(), Fonts.Menu, new Rectangle(ClientSize.Width - Dpi.ScaleX(123), 0, Dpi.ScaleX(35), Dpi.ScaleY(HEIGHT)), UserColors.Text, flags);
                TextRenderer.DrawText(g, "Line", Fonts.Header, new Rectangle(ClientSize.Width - Dpi.ScaleX(150), 0, Dpi.ScaleX(30), Dpi.ScaleY(HEIGHT)), UserColors.Text, flags);

                using (var bmp = Bitmaps.Load("Bounds"))
                    g.DrawImage(bmp, new Rectangle(ClientSize.Width - Dpi.ScaleX(167), Dpi.ScaleY(5), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));
            }
        }
Ejemplo n.º 4
0
 protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
 {
     using (var bmp = Bitmaps.Load("Check"))
         e.Graphics.DrawImage(bmp, new Rectangle(e.ImageRectangle.X + Dpi.ScaleX(1),
                                                 e.ImageRectangle.Y + Dpi.ScaleY(5), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));
 }
Ejemplo n.º 5
0
 protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
 {
     using (var bmp = Bitmaps.Load("Arrow"))
         e.Graphics.DrawImage(bmp, new Rectangle(e.Item.Bounds.Width - Dpi.ScaleX(10),
                                                 e.ArrowRectangle.Y + Dpi.ScaleY(7), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));
 }