示例#1
0
 private void drawArrow(IntPtr hdc, Rectangle bounds, bool down)
 {
     using (Graphics g = Graphics.FromHdc(hdc))
     {
         using (GraphicsMode mode = new GraphicsMode(g, SmoothingMode.AntiAlias))
         {
             using (GraphicsPath gp = new GraphicsPath())
             {
                 if (down)
                 {
                     // draw the frame
                     gp.AddLine(new Point(bounds.X, bounds.Top), new Point(bounds.X + 4, bounds.Top));
                     gp.AddLine(new Point(bounds.X, bounds.Top), new Point(bounds.X + 2, bounds.Top + 2));
                     gp.AddLine(new Point(bounds.X + 2, bounds.Top + 2), new Point(bounds.X + 4, bounds.Top));
                     gp.CloseFigure();
                 }
                 else
                 {
                     gp.AddLine(new Point(bounds.X, bounds.Top + 4), new Point(bounds.X + 4, bounds.Top + 4));
                     gp.AddLine(new Point(bounds.X, bounds.Top + 4), new Point(bounds.X + 2, bounds.Top + 2));
                     gp.AddLine(new Point(bounds.X + 4, bounds.Top + 4), new Point(bounds.X + 2, bounds.Top + 2));
                     gp.CloseFigure();
                 }
                 // draw border
                 using (Pen borderPen = new Pen(Color.FromArgb(240, Color.Black), 0.5f))
                     g.DrawPath(borderPen, gp);
                 // fill path
                 using (Brush backBrush = new SolidBrush(Color.SlateGray))
                     g.FillPath(backBrush, gp);
             }
         }
     }
 }
示例#2
0
 private void drawBackground(IntPtr hdc)
 {
     // create the graphics instance
     Graphics g = Graphics.FromHdc(hdc);
     // copy in the background to mimic transparency
     copyBackground(g);
     // create the shadow rect
     Rectangle shadowArea = new Rectangle(3, TipBounds.Height - 3, TipBounds.Width - 3, TipBounds.Height);
     // draw the bottom shadow
     using (GraphicsMode mode = new GraphicsMode(g, SmoothingMode.AntiAlias))
     {
         using (GraphicsPath shadowPath = createRoundRectanglePath(g, 4, TipBounds.Height - 4, TipBounds.Width - 4, TipBounds.Height, 1f))
         {
             using (LinearGradientBrush shadowBrush = new LinearGradientBrush(shadowArea, Color.FromArgb(100, 0x99, 0x99, 0x99), Color.FromArgb(60, 0x44, 0x44, 0x44), LinearGradientMode.Vertical))
             {
                 Blend blend = new Blend();
                 blend.Positions = new float[] { 0f, .3f, .6f, 1f };
                 blend.Factors = new float[] { 0f, .3f, .6f, .9f };
                 shadowBrush.Blend = blend;
                 g.FillPath(shadowBrush, shadowPath);
             }
         }
         // draw the right shadow
         using (GraphicsPath shadowPath = createRoundRectanglePath(g, TipBounds.Width - 4, 4, TipBounds.Width - 4, TipBounds.Height - 8, 1f))
         {
             using (LinearGradientBrush shadowBrush = new LinearGradientBrush(shadowArea, Color.FromArgb(100, 0x99, 0x99, 0x99), Color.FromArgb(60, 0x44, 0x44, 0x44), LinearGradientMode.Horizontal))
             {
                 Blend blend = new Blend();
                 blend.Positions = new float[] { 0f, .3f, .6f, 1f };
                 blend.Factors = new float[] { 0f, .3f, .6f, .9f };
                 shadowBrush.Blend = blend;
                 g.FillPath(shadowBrush, shadowPath);
             }
         }
         // adjust the bounds
         Rectangle fillBounds = new Rectangle(0, 0, TipBounds.Width - 4, TipBounds.Height - 4);
         using (GraphicsPath fillPath = createRoundRectanglePath(g, fillBounds.X, fillBounds.Y, fillBounds.Width, fillBounds.Height, 2f))
         {
             using (LinearGradientBrush shadowBrush = new LinearGradientBrush(shadowArea, GradientBegin, GradientEnd, LinearGradientMode.Vertical))
             {
                 // draw the frame
                 using (Pen fillPen = new Pen(Color.FromArgb(250, 0x44, 0x44, 0x44)))
                     g.DrawPath(fillPen, fillPath);
                 // fill the body
                 Blend blend = new Blend();
                 blend.Positions = new float[] { 0f, .4f, .6f, 1f };
                 blend.Factors = new float[] { 0f, .3f, .6f, .8f };
                 shadowBrush.Blend = blend;
                 g.FillPath(shadowBrush, fillPath);
             }
         }
     }
     g.Dispose();
 }
示例#3
0
        private void drawFocusedButton(IntPtr hdc, Rectangle bounds, LinearGradientMode gradient)
        {
            using (Graphics g = Graphics.FromHdc(hdc))
            {
                // draw using anti alias
                using (GraphicsMode mode = new GraphicsMode(g, SmoothingMode.AntiAlias))
                {
                    // create the path
                    using (GraphicsPath buttonPath = createRoundRectanglePath(
                        g,
                        bounds.X, bounds.Y,
                        bounds.Width, bounds.Height,
                        1.0f))
                    {
                        // draw the outer edge
                        using (Pen borderPen = new Pen(Color.FromArgb(150, Color.SlateGray), 1f))
                            g.DrawPath(borderPen, buttonPath);
                    }
                    bounds.Inflate(-1, -1);

                    using (GraphicsPath buttonPath = createRoundRectanglePath(
                        g,
                        bounds.X, bounds.Y,
                        bounds.Width, bounds.Height,
                        1.0f))
                    {
                        // draw the inner edge
                        using (Pen borderPen = new Pen(Color.FromArgb(150, Color.DarkGray), 1.5f))
                            g.DrawPath(borderPen, buttonPath);

                        // create a thin gradient cover
                        using (LinearGradientBrush fillBrush = new LinearGradientBrush(
                            bounds,
                            Color.FromArgb(50, Color.White),
                            Color.FromArgb(50, Color.SlateGray),
                            gradient))
                        {
                            // shift the blend factors
                            Blend blend = new Blend();
                            blend.Positions = new float[] { 0f, .3f, .6f, 1f };
                            blend.Factors = new float[] { 0f, .5f, .8f, .2f };
                            fillBrush.Blend = blend;
                            // fill the path
                            g.FillPath(fillBrush, buttonPath);
                        }
                    }
                }
            }
        }
        private void createBufferImage()
        {
            ProgressBar pb = (ProgressBar)Control.FromHandle(_hProgressBarWnd);
            Rectangle bounds = pb.ClientRectangle;
            Rectangle bdcopy = bounds;
            _cBufferDc.Height = pb.Height;
            _cBufferDc.Width = pb.Width;
            Graphics g = Graphics.FromHdc(_cBufferDc.Hdc);

            using (GraphicsMode mode = new GraphicsMode(g, SmoothingMode.AntiAlias))
            {
                using (GraphicsPath barPath = createRoundRectanglePath(
                    g,
                    bounds.X, bounds.Y,
                    bounds.Width, bounds.Height,
                    1f))
                {
                    using (SolidBrush backBrush = new SolidBrush(pb.BackColor))
                        g.FillRectangle(backBrush, bounds);
                    // draw the frame
                    using (LinearGradientBrush borderBrush = new LinearGradientBrush(
                        bounds,
                        Color.DarkGray,
                        Color.Silver,
                        90f))
                    {
                        borderBrush.SetSigmaBellShape(0.5f);
                        using (Pen borderPen = new Pen(borderBrush, .5f))
                            g.DrawPath(borderPen, barPath);
                    }
                    bounds.Width--;
                    bounds.Height--;
                    // create a clipping region
                    RectangleF clipBounds = bounds;
                    clipBounds.Inflate(-1, -1);
                    using (GraphicsPath clipPath = createRoundRectanglePath(
                        g,
                        clipBounds.X, clipBounds.Y,
                        clipBounds.Width + 1, clipBounds.Height + 1,
                        1f))
                    {
                        using (Region region = new Region(clipPath))
                            g.SetClip(region, CombineMode.Exclude);
                    }
                    // fill in the edge accent
                    using (LinearGradientBrush edgeBrush = new LinearGradientBrush(
                        bounds,
                        Color.DarkGray,
                        Color.Black,
                        90f))
                    {
                        edgeBrush.SetBlendTriangularShape(0.5f);
                        g.FillPath(edgeBrush, barPath);
                        g.ResetClip();
                        bounds.Inflate(-1, -1);
                    }
                    // fill with a subtle glow
                    using (LinearGradientBrush fillBrush = new LinearGradientBrush(
                        bounds,
                        Color.FromArgb(100, Color.White),
                        Color.FromArgb(100, Color.Silver),
                        LinearGradientMode.Vertical))
                    {
                        fillBrush.SetBlendTriangularShape(0.4f);
                        g.FillPath(fillBrush, barPath);
                        g.ResetClip();
                    }
                }
            }
            g.Dispose();
        }