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);
            Rectangle InnerRect       = new Rectangle(1, 1, Width - 3, Height - 3);


            base.OnPaint(e);

            G.Clear(BackColor);
            Font drawFont = new Font("Tahoma", 10, FontStyle.Bold);

            //G.CompositingQuality = CompositingQuality.HighQuality
            G.SmoothingMode = SmoothingMode.HighQuality;

            switch (State)
            {
            case MouseState.None:
                LinearGradientBrush BBG = new LinearGradientBrush(ClientRectangle, Color.FromArgb(85, 156, 188), Color.FromArgb(58, 136, 175), 90);
                G.FillPath(BBG, Draw.RoundRect(ClientRectangle, 4));
                Pen p = new Pen(new SolidBrush(Color.FromArgb(29, 46, 54)));
                G.DrawPath(Pens.Black, Draw.RoundRect(ClientRectangle, 4));
                Pen Ip = new Pen(Color.FromArgb(129, 175, 201));
                G.DrawPath(Ip, Draw.RoundRect(InnerRect, 4));
                break;

            case MouseState.Over:
                LinearGradientBrush BBG1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(45, 105, 135), Color.FromArgb(30, 90, 120), 90);
                G.FillPath(BBG1, Draw.RoundRect(ClientRectangle, 4));
                Pen p1 = new Pen(new SolidBrush(Color.FromArgb(29, 46, 54)));
                G.DrawPath(Pens.Black, Draw.RoundRect(ClientRectangle, 4));
                Pen Ip1 = new Pen(Color.FromArgb(114, 160, 186));
                G.DrawPath(Ip1, Draw.RoundRect(InnerRect, 4));
                break;

            case MouseState.Down:
                LinearGradientBrush BBG2 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(85, 156, 188), Color.FromArgb(58, 136, 175), 90);
                G.FillPath(BBG2, Draw.RoundRect(ClientRectangle, 4));
                Pen p2 = new Pen(new SolidBrush(Color.FromArgb(29, 46, 54)));
                G.DrawPath(Pens.Black, Draw.RoundRect(ClientRectangle, 4));
                Pen Ip2 = new Pen(Color.FromArgb(129, 175, 201));
                G.DrawPath(Ip2, Draw.RoundRect(InnerRect, 4));
                break;
            }
            G.DrawString(Text, drawFont, new SolidBrush(Color.WhiteSmoke), 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();
        }
예제 #2
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;

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

            G.Clear(BackColor);

            ImageToCodeClass d             = new ImageToCodeClass();
            Bitmap           GRAINIMAGE2   = (Bitmap)d.CodeToImage("/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCAA1AHUDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoE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tIg5AJ68YyKBodEAxJyFAH6004yPmYkHGf/rUqgjcM5J49h1pHKnAIBI7+poEKcBiCBg8ZFNY4PGcD88UrZHAPygjj8KVV5I6Y7ngCgBqDMgzuyOeAc053boMBicj/ADmguwQhiGweM4NL8zEADbg8cUDTGjbyWDEHpzRSuFLYIGR6ciigVwjYvjPIwOvNICGYHBG4kHFFFA0JwzEqNuQf5U8sUUk4ZSenTtRRQJBuEiYAK454pquFQrtyVzz3oooBMCxOAMLkHkdetPiUPKytzlcknk0UUAQl96g4wQaeF+QE9G9PqKKKAYMuVLAkZJp+3MUj5IYn8KKKBoYSWbGcY4HApAxMjAk/KfWiigTY5CyLlTt3UUUUCbP/2Q==");
            TextureBrush     TEXTUREIMAGE2 = new TextureBrush(GRAINIMAGE2, WrapMode.TileFlipX);

            ////// Inner Fill
            G.FillPath(TEXTUREIMAGE2, Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 2));
            G.DrawPath(new Pen(new SolidBrush(Color.FromArgb(26, 26, 26))), Draw.RoundRect(new Rectangle(1, 1, Width - 3, Height - 3), 2));

            ////// Bar Fill
            LinearGradientBrush g1 = new LinearGradientBrush(new Rectangle(2, 2, intValue - 5, Height - 5), Color.FromArgb(60, 60, 60), Color.FromArgb(45, 45, 45), 90);

            G.FillPath(g1, Draw.RoundRect(new Rectangle(2, 2, intValue - 5, Height - 5), 2));

            ///// Bar Overlap
            //Dim h1 As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.FromArgb(40, Color.White), Color.FromArgb(20, Color.White))
            //G.FillPath(h1, Draw.RoundRect(New Rectangle(0, 0, intValue - 1, Height - 2), 1))

            ////// Outer Rectangle
            G.DrawPath(new Pen(Color.FromArgb(190, 70, 70, 70)), Draw.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 2));

            ////// Bar Size
            G.DrawPath(new Pen(Color.FromArgb(150, 97, 94, 90)), Draw.RoundRect(new Rectangle(2, 2, intValue - 5, Height - 5), 2));

            if (_ShowPercentage)
            {
                G.DrawString(Convert.ToString(string.Concat(Value, "%")), new Font("Tahoma", 9, FontStyle.Bold), Brushes.White, 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();
        }
예제 #3
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Bitmap    B        = new Bitmap(Width, Height);
            Graphics  G        = Graphics.FromImage(B);
            Rectangle MainRect = new Rectangle(0, 0, Width - 1, Height - 1);

            base.OnPaint(e);

            G.Clear(Color.Transparent);
            ImageToCodeClass d = new ImageToCodeClass();

            G.SmoothingMode      = SmoothingMode.HighQuality;
            G.CompositingQuality = CompositingQuality.HighQuality;

            G.FillPath(new SolidBrush(Color.FromArgb(58, 56, 57)), Draw.RoundRect(MainRect, 3));
            G.DrawPath(new Pen(new SolidBrush(Color.FromArgb(77, 77, 77))), Draw.RoundRect(MainRect, 3));

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