示例#1
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Bitmap   B = new Bitmap(Width, Height);
            Graphics G = Graphics.FromImage(B);

            G.SmoothingMode = SmoothingMode.HighQuality;
            Rectangle ClientRectangle = new Rectangle(0, 0, Width - 1, Height - 1);

            var _with2 = txtbox;

            _with2.Multiline = MultiLine;
            if (MultiLine == false)
            {
                Height = txtbox.Height + 11;
                if (WordWrap == true)
                {
                    _with2.WordWrap = true;
                }
                else
                {
                    _with2.WordWrap = false;
                }
            }
            else
            {
                txtbox.Height = Height - 11;
                if (WordWrap == true)
                {
                    _with2.WordWrap = true;
                }
                else
                {
                    _with2.WordWrap = false;
                }
            }
            _with2.Width                 = Width - 10;
            _with2.TextAlign             = TextAlignment;
            _with2.UseSystemPasswordChar = UseSystemPasswordChar;

            G.Clear(BackColor);

            Color[] c = new Color[] {
                Color.FromArgb(20, 20, 20),
                Color.FromArgb(40, 40, 40),
                Color.FromArgb(45, 45, 45),
                Color.FromArgb(46, 46, 46),
                Color.FromArgb(47, 47, 47),
                Color.FromArgb(48, 48, 48),
                Color.FromArgb(49, 49, 49),
                Color.FromArgb(50, 50, 50)
            };
            G.FillPath(new SolidBrush(Color.FromArgb(50, 50, 50)), Draw.RoundRect(ClientRectangle, 3));
            Draw.InnerGlowRounded(G, ClientRectangle, 3, c);

            e.Graphics.DrawImage((Bitmap)B.Clone(), 0, 0);
            G.Dispose();
            B.Dispose();
        }
        public static void InnerGlowRounded(Graphics G, Rectangle Rectangle, int Degree, Color[] Colors)
        {
            int SubtractTwo = 1;
            int AddOne      = 0;

            foreach (Color c_loopVariable in Colors)
            {
                Color c = c_loopVariable;
                G.DrawPath(new Pen(new SolidBrush(Color.FromArgb(c.R, c.B, c.G))), Draw.RoundRect(Rectangle.X + AddOne, Rectangle.Y + AddOne, Rectangle.Width - SubtractTwo, Rectangle.Height - SubtractTwo, Degree));
                SubtractTwo += 2;
                AddOne      += 1;
            }
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Bitmap   B = new Bitmap(Width, Height);
            Graphics G = Graphics.FromImage(B);

            G.SmoothingMode = SmoothingMode.HighQuality;

            int intValue = Convert.ToInt32(_Value / _Maximum * Width);

            G.Clear(BackColor);

            SolidBrush percentColor = new SolidBrush(Color.White);

            Color[] c = new Color[] {
                Color.FromArgb(20, 20, 20),
                Color.FromArgb(40, 40, 40),
                Color.FromArgb(45, 45, 45),
                Color.FromArgb(46, 46, 46),
                Color.FromArgb(47, 47, 47),
                Color.FromArgb(48, 48, 48),
                Color.FromArgb(49, 49, 49),
                Color.FromArgb(50, 50, 50)
            };
            G.FillPath(new SolidBrush(Color.FromArgb(50, 50, 50)), Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3));
            Draw.InnerGlowRounded(G, ClientRectangle, 3, c);

            ////// Bar Fill
            if (!(intValue == 0))
            {
                G.FillPath(new LinearGradientBrush(new Rectangle(1, 1, intValue, Height - 3), Color.FromArgb(30, 30, 30), Color.FromArgb(35, 35, 35), 90), Draw.RoundRect(new Rectangle(1, 1, intValue, Height - 3), 2));
                G.DrawPath(new Pen(Color.FromArgb(45, 45, 45)), Draw.RoundRect(new Rectangle(1, 1, intValue, Height - 3), 2));
                //G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(15, 15, 15))), intValue + 1, 3, intValue + 1, Height - 4)
                percentColor = new SolidBrush(Color.White);
            }



            if (_ShowPercentage)
            {
                G.DrawString(Convert.ToString(string.Concat(Value, "%")), new Font("Tahoma", 9, FontStyle.Bold), percentColor, new Rectangle(0, 1, Width - 1, Height - 1), new StringFormat
                {
                    Alignment     = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center
                });
            }

            e.Graphics.DrawImage((Bitmap)B.Clone(), 0, 0);
            G.Dispose();
            B.Dispose();
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Bitmap    B = new Bitmap(Width, Height);
            Graphics  G = Graphics.FromImage(B);
            Rectangle ClientRectangle = new Rectangle(0, 0, Width - 1, Height - 1);

            base.OnPaint(e);

            G.Clear(BackColor);
            Font drawFont = new Font("Verdana", 8, FontStyle.Regular);

            G.SmoothingMode = SmoothingMode.HighQuality;

            G.FillPath(new SolidBrush(Color.FromArgb(40, 40, 40)), Draw.RoundRect(ClientRectangle, 3));
            G.DrawPath(new Pen(new SolidBrush(Color.FromArgb(15, 15, 15))), Draw.RoundRect(ClientRectangle, 3));
            G.DrawPath(new Pen(new SolidBrush(Color.FromArgb(55, 55, 55))), Draw.RoundRect(new Rectangle(1, 1, Width - 3, Height - 3), 3));

            switch (State)
            {
            case MouseState.None:
                G.DrawString(Text, drawFont, Brushes.Silver, new Rectangle(0, 0, Width - 1, Height - 1), new StringFormat
                {
                    Alignment     = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center
                });
                break;

            case MouseState.Over:
                G.DrawString(Text, drawFont, Brushes.White, new Rectangle(0, 0, Width - 1, Height - 1), new StringFormat
                {
                    Alignment     = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center
                });
                break;

            case MouseState.Down:
                G.DrawString(Text, drawFont, Brushes.Gray, new Rectangle(0, 0, Width - 1, Height - 1), new StringFormat
                {
                    Alignment     = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center
                });
                break;
            }

            e.Graphics.DrawImage((Bitmap)B.Clone(), 0, 0);
            G.Dispose();
            B.Dispose();
        }
示例#5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Bitmap   B = new Bitmap(Width, Height);
            Graphics G = Graphics.FromImage(B);

            G.SmoothingMode = SmoothingMode.HighQuality;


            G.Clear(BackColor);
            LinearGradientBrush bodyGradNone = new LinearGradientBrush(new Rectangle(0, 0, Width - 1, Height - 2), Color.FromArgb(40, 40, 40), Color.FromArgb(40, 40, 40), 90);

            G.FillPath(bodyGradNone, Draw.RoundRect(new Rectangle((int)bodyGradNone.Rectangle.X, (int)bodyGradNone.Rectangle.Y, (int)bodyGradNone.Rectangle.Width, (int)bodyGradNone.Rectangle.Height), 3));
            LinearGradientBrush bodyInBorderNone = new LinearGradientBrush(new Rectangle(0, 0, Width - 1, Height - 3), Color.FromArgb(40, 40, 40), Color.FromArgb(40, 40, 40), 90);

            G.DrawPath(new Pen(bodyInBorderNone), Draw.RoundRect(new Rectangle(1, 1, Width - 3, Height - 4), 3));
            G.DrawPath(new Pen(Color.FromArgb(20, 20, 20)), Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 3));
            //Outer Line
            G.DrawPath(new Pen(Color.FromArgb(55, 55, 55)), Draw.RoundRect(new Rectangle(1, 1, Width - 3, Height - 3), 3));
            //Inner Line
            DrawTriangle(Color.FromArgb(60, 60, 60), new Point(Width - 14, 12), new Point(Width - 7, 12), new Point(Width - 11, 16), new Point(Width - 14, 10), new Point(Width - 7, 10), new Point(Width - 11, 5), G);
            //Triangle Fill Color

            //Draw Separator line
            G.DrawLine(new Pen(Color.FromArgb(45, 45, 45)), new Point(Width - 21, 2), new Point(Width - 21, Height - 3));
            G.DrawLine(new Pen(Color.FromArgb(55, 55, 55)), new Point(Width - 20, 1), new Point(Width - 20, Height - 3));
            G.DrawLine(new Pen(Color.FromArgb(45, 45, 45)), new Point(Width - 19, 2), new Point(Width - 19, Height - 3));
            try
            {
                G.DrawString(Text, Font, new SolidBrush(ForeColor), new Rectangle(5, 0, Width - 20, Height), new StringFormat
                {
                    LineAlignment = StringAlignment.Center,
                    Alignment     = StringAlignment.Near
                });
            }
            catch
            {
            }

            e.Graphics.DrawImage((Bitmap)B.Clone(), 0, 0);
            G.Dispose();
            B.Dispose();
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Bitmap    B         = new Bitmap(Width, Height);
            Graphics  G         = Graphics.FromImage(B);
            Rectangle onoffRect = new Rectangle(0, 0, Width - 1, Height - 1);

            G.SmoothingMode      = SmoothingMode.HighQuality;
            G.CompositingQuality = CompositingQuality.HighQuality;
            G.TextRenderingHint  = TextRenderingHint.AntiAliasGridFit;

            G.Clear(Color.Transparent);

            LinearGradientBrush bodyGrad = new LinearGradientBrush(onoffRect, Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), 90);

            G.FillPath(bodyGrad, Draw.RoundRect(onoffRect, 4));
            G.DrawPath(new Pen(Color.FromArgb(15, 15, 15)), Draw.RoundRect(onoffRect, 4));
            G.DrawPath(new Pen(Color.FromArgb(50, 50, 50)), Draw.RoundRect(new Rectangle(1, 1, Width - 3, Height - 3), 4));

            if (Checked)
            {
                G.FillPath(new SolidBrush(Color.FromArgb(80, Color.Green)), Draw.RoundRect(new Rectangle(4, 2, 25, Height - 5), 4));
                G.FillPath(new SolidBrush(Color.FromArgb(35, 35, 35)), Draw.RoundRect(new Rectangle(2, 2, 25, Height - 5), 4));
                G.DrawPath(new Pen(new SolidBrush(Color.FromArgb(20, 20, 20))), Draw.RoundRect(new Rectangle(2, 2, 25, Height - 5), 4));
                switch (State)
                {
                case MouseState.None:
                    G.DrawString("On", new Font("Tahoma", 8, FontStyle.Regular), Brushes.Silver, new Point(16, Height - 12), new StringFormat
                    {
                        Alignment     = StringAlignment.Center,
                        LineAlignment = StringAlignment.Center
                    });
                    break;

                case MouseState.Over:
                    G.DrawString("On", new Font("Tahoma", 8, FontStyle.Regular), Brushes.White, new Point(16, Height - 12), new StringFormat
                    {
                        Alignment     = StringAlignment.Center,
                        LineAlignment = StringAlignment.Center
                    });
                    break;

                case MouseState.Down:
                    G.DrawString("On", new Font("Tahoma", 8, FontStyle.Regular), Brushes.Silver, new Point(16, Height - 12), new StringFormat
                    {
                        Alignment     = StringAlignment.Center,
                        LineAlignment = StringAlignment.Center
                    });
                    break;
                }
            }
            else
            {
                G.FillPath(new SolidBrush(Color.FromArgb(60, Color.Red)), Draw.RoundRect(new Rectangle((Width / 2) - 7, 2, Width - 25, Height - 5), 4));
                G.FillPath(new SolidBrush(Color.FromArgb(35, 35, 35)), Draw.RoundRect(new Rectangle((Width / 2) - 5, 2, Width - 23, Height - 5), 4));
                G.DrawPath(new Pen(new SolidBrush(Color.FromArgb(20, 20, 20))), Draw.RoundRect(new Rectangle((Width / 2) - 5, 2, Width - 23, Height - 5), 4));
                switch (State)
                {
                case MouseState.None:
                    G.DrawString("Off", new Font("Tahoma", 8, FontStyle.Regular), Brushes.Silver, new Point(34, Height - 11), new StringFormat
                    {
                        Alignment     = StringAlignment.Center,
                        LineAlignment = StringAlignment.Center
                    });
                    break;

                case MouseState.Over:
                    G.DrawString("Off", new Font("Tahoma", 8, FontStyle.Regular), Brushes.White, new Point(34, Height - 11), new StringFormat
                    {
                        Alignment     = StringAlignment.Center,
                        LineAlignment = StringAlignment.Center
                    });
                    break;

                case MouseState.Down:
                    G.DrawString("Off", new Font("Tahoma", 8, FontStyle.Regular), Brushes.Silver, new Point(34, Height - 11), new StringFormat
                    {
                        Alignment     = StringAlignment.Center,
                        LineAlignment = StringAlignment.Center
                    });
                    break;
                }
            }

            e.Graphics.DrawImage((Bitmap)B.Clone(), 0, 0);
            G.Dispose();
            B.Dispose();
        }