Пример #1
0
        protected override void OnPaint(PaintEventArgs p)
        {
            Graphics     g  = p.Graphics;
            Font         f  = new Font(Font.FontFamily, Height / 3, Font.Style);
            Brush        fb = new SolidBrush(ForeColor);
            Brush        sb;
            Rectangle    r  = new Rectangle(0, 0, Width, Height);
            StringFormat sf = new StringFormat()
            {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
            };

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if (Enabled == false)
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            int brdSize;

            if (AutoSizeBorder)
            {
                brdSize = Math.Max(Math.Min(8, Height / 8), 4);
                if (brdSize % 2 != 0)
                {
                    brdSize -= 1;
                }
            }
            else
            {
                brdSize = BorderSize;
            }

            int fillWidth = (Width - brdSize * 2) * Value / 100;

            if (Value < 50)
            {
                fb = new SolidBrush(FillColor);
                sb = new SolidBrush(BackColor);
            }
            else
            {
                fb = new SolidBrush(BackColor);
                sb = new SolidBrush(FillColor);
            }

            DrawingPlus.DrawBorder(g, r, BorderColor, brdSize);
            if (fillWidth > 0)
            {
                DrawingPlus.DrawPanel(g, new Rectangle(brdSize, brdSize, fillWidth, Height - brdSize * 2), FillColor, 2);
            }
            if (fillWidth < Width - brdSize * 2)
            {
                DrawingPlus.DrawPanel(g, new Rectangle(brdSize + fillWidth, brdSize, Width - brdSize * 2 - fillWidth, Height - brdSize * 2), BackColor, 2);
            }

            g.DrawString(Value + "%", f, sb, new Rectangle(1, 1, Width, Height), sf);
            g.DrawString(Value + "%", f, fb, r, sf);
        }
Пример #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle r = new Rectangle(10, 10, 50, 50);
            Graphics  g = e.Graphics;

            //base.OnPaint(e);

            if (FullScreen == false)
            {
                DrawingPlus.DrawBorder(g, ClientRectangle, BorderColor, BorderSize);
            }
        }
Пример #3
0
        protected override void OnPaint(PaintEventArgs p)
        {
            Graphics  g = p.Graphics;
            Rectangle r = new Rectangle(0, (base.Size.Height - 16) / 2, 16, 16);
            Brush     fb;
            Color     bg;

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if (Enabled)
            {
                fb = new SolidBrush(ForeColor);
            }
            else
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            base.OnPaint(p);

            if (Clicked)
            {
                bg = DrawingPlus.DarkenColor(BoxColor, -32);
            }
            else if (Selected)
            {
                bg = DrawingPlus.DarkenColor(BoxColor, -16);
            }
            else
            {
                bg = BoxColor;
            }

            DrawingPlus.DrawBorder(g, r, BorderColor, 4);
            DrawingPlus.DrawPanel(g, new Rectangle(r.X + 4, r.Y + 4, r.X + r.Width - 8, r.Height - 8), bg, 2);

            if (this.Checked)
            {
                g.DrawString("✔", new Font("Lucida Console", 7), fb, r, new StringFormat()
                {
                    Alignment     = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center
                });
            }
        }
Пример #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics     g  = e.Graphics;
            Font         f  = new Font(Font.FontFamily, Height / 3, Font.Style);
            Brush        fb = new SolidBrush(ForeColor);
            Brush        sb = new SolidBrush(ForeColor);
            Rectangle    r  = new Rectangle(0, 0, Width, Height);
            StringFormat sf = new StringFormat()
            {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
            };
            Color bg;

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if (Enabled == false)
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            int brdSize;

            if (AutoSizeBorder)
            {
                brdSize = Math.Max(Math.Min(8, Height / 8), 4);
                if (brdSize % 2 != 0)
                {
                    brdSize -= 1;
                }
            }
            else
            {
                brdSize = BorderSize;
            }

            if (Clicked)
            {
                bg = DrawingPlus.DarkenColor(BackColor, -32);
            }
            else if (Selected)
            {
                bg = DrawingPlus.DarkenColor(BackColor, -16);
            }
            else
            {
                bg = BackColor;
            }

            if (Clicked || Selected)
            {
                brdSize += 2;
            }

            DrawingPlus.DrawBorder(g, r, BorderColor, brdSize);
            DrawingPlus.DrawPanel(g, new Rectangle(brdSize, brdSize, Width - brdSize * 2, Height - brdSize * 2), bg, Math.Max(2, brdSize - 4));

            if (ShadowColor != Color.Transparent)
            {
                g.DrawString(Text, f, Brushes.Black,
                             new Rectangle(1, 1, Width, Height), sf);
            }
            g.DrawString(Text, f, fb, r, sf);
        }
Пример #5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Size     titleSize;
            Point    titlePosition;
            Color    bg;
            Brush    fb;
            int      borderSize = 4;

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if (Enabled)
            {
                fb = new SolidBrush(ForeColor);
            }
            else
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            if (BackColor != Color.Transparent)
            {
                bg = BackColor;
            }
            else
            if (Parent.GetType() == typeof(CustomGroupBox))
            {
                bg = Color.Transparent;
            }
            else
            {
                bg = Color.FromArgb(31, Color.Black);
            }

            g.FillRectangle(new SolidBrush(bg), new Rectangle(borderSize, borderSize, Width - borderSize * 2, Height - borderSize * 2));
            DrawingPlus.DrawBorder(g, ClientRectangle, BorderColor, borderSize);

            titleSize        = new Size();
            titleSize.Width  = (int)g.MeasureString(Text, Font).Width + 2 + borderSize;
            titleSize.Height = (int)g.MeasureString(Text, Font).Height + 2;

            switch (TextPosition)
            {
            case CustomGroupBoxTextPosition.Left:
                titlePosition = new Point(0, 0);
                break;

            case CustomGroupBoxTextPosition.Center:
                titlePosition = new Point((Width - titleSize.Width) / 2, 0);
                break;

            case CustomGroupBoxTextPosition.Right:
                titlePosition = new Point(Width - titleSize.Width, 0);
                break;

            default:
                goto case CustomGroupBoxTextPosition.Left;
            }

            DrawingPlus.DrawPanel(g,
                                  new Rectangle(titlePosition.X, titlePosition.Y, titleSize.Width, titleSize.Height),
                                  BorderColor, borderSize - 2);

            if (ShadowColor != Color.Transparent)
            {
                g.DrawString(Text, Font, new SolidBrush(ShadowColor),
                             new Point(titlePosition.X + borderSize + 1, 0));
            }
            g.DrawString(Text, Font, fb,
                         new Point(titlePosition.X + borderSize, 0));
        }
Пример #6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            Graphics  g = e.Graphics;
            Rectangle rBrowse;
            Brush     fb = new SolidBrush(ForeColor);
            Color     bg;
            int       brdSize = BorderSize;

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            if (Enabled == false)
            {
                fb = new SolidBrush(ColorTranslator.FromHtml("#A0A0A0"));
            }

            if (Clicked)
            {
                bg = DrawingPlus.DarkenColor(BackColor, -32);
            }
            else if (Selected)
            {
                bg = DrawingPlus.DarkenColor(BackColor, -16);
            }
            else
            {
                bg = BackColor;
            }

            if (Clicked || Selected)
            {
                brdSize += 2;
            }

            rBrowse = new Rectangle(Width - Height + brdSize, brdSize, Height - brdSize * 2, Height - brdSize * 2);

            #region alternative design
            DrawingPlus.DrawBorder(g, new Rectangle(0, 0, Width - Height, Height), BorderColor, BorderSize);
            DrawingPlus.DrawPanel(g, new Rectangle(
                                      BorderSize, BorderSize, Width - Height - BorderSize * 2, Height - BorderSize * 2),
                                  BackColor, BorderSize - 2);

            DrawingPlus.DrawBorder(g, new Rectangle(Width - Height, 0, Height, Height), BorderColor, BorderSize);
            DrawingPlus.DrawPanel(g, new Rectangle(
                                      Width - Height + BorderSize, BorderSize,
                                      Height - BorderSize * 2, Height - borderSize * 2),
                                  BackColor, BorderSize - 2);
            #endregion

            DrawingPlus.DrawBorder(g, new Rectangle(0, 0, Width, Height), BorderColor, brdSize);
            DrawingPlus.DrawPanel(g, new Rectangle(brdSize, brdSize, Width - Height, Height - brdSize * 2), bg, Math.Max(2, brdSize - 4));
            DrawingPlus.DrawPanel(g, rBrowse, bg, Math.Max(2, brdSize - 4));

            StringFormat sf       = new StringFormat();
            StringFormat sfBrowse = new StringFormat();
            sf.LineAlignment       = StringAlignment.Center;
            sfBrowse.LineAlignment = StringAlignment.Center;
            sfBrowse.Alignment     = StringAlignment.Center;
            Font fBrowse = new Font(Font.FontFamily, (int)(Font.Size * 0.66));

            if (ShadowColor != Color.Transparent)
            {
                g.DrawString(Text, Font, Brushes.Black, new Rectangle(brdSize + 1, 1, Width, Height), sf);
                g.DrawString("▼", fBrowse, Brushes.Black, new Rectangle(rBrowse.X + 1, rBrowse.Y + 1, rBrowse.Width, rBrowse.Height), sfBrowse);
            }

            g.DrawString(Text, Font, fb, new Rectangle(brdSize, 0, Width, Height), sf);
            g.DrawString("▼", fBrowse, fb, rBrowse, sfBrowse);
        }