Пример #1
0
        protected override void PaintButtonBackground(FluidPaintEventArgs e)
        {
            Rectangle r = e.ControlBounds;

            r.Width--;
            r.Height--;
            Graphics g          = e.Graphics;
            Color    darkColor  = BackColor;
            Color    lightColor = ColorConverter.AlphaBlendColor(darkColor, Color.White, 48);

            if (!Enabled)
            {
                darkColor  = ColorConverter.AlphaBlendColor(Color.Black, darkColor, 128);
                lightColor = ColorConverter.AlphaBlendColor(Color.Black, lightColor, 128);
            }

            Color beginColor = IsDown ? darkColor : lightColor;
            Color endColor   = IsDown ? lightColor : darkColor;



            GdiExt.GradientFill(e.Graphics, r, beginColor, endColor, Fluid.Drawing.GdiPlus.GdiExt.FillDirection.TopToBottom);
            Pen pen = Pens.GetPen(lightColor);

            e.Graphics.DrawRectangle(pen, r);
            PerformPaintButtonContent(e);
        }
Пример #2
0
        public void PaintHeaderBackground()
        {
            Graphics  g = Graphics;
            Rectangle r = ClientBounds;

            Color color      = BackColor;
            Color startColor = ColorConverter.AlphaBlendColor(Color.White, color, 100);

            if (IsTransparent)
            {
                color      = ColorConverter.AlphaColor(color, 200);
                startColor = ColorConverter.AlphaColor(startColor, 150);
                using (GraphicsPlus gp = new GraphicsPlus(g))
                {
                    PointF p1 = new PointF(r.X, r.Y);
                    PointF p2 = new PointF(r.X, r.Bottom);
                    using (LinearGradientBrush backGround = new LinearGradientBrush(p1, p2, startColor, color))
                    {
                        gp.FillRectangle(backGround, r);
                    }
                }
            }
            else
            {
                GdiExt.GradientFill(g, r, startColor, color, GdiExt.FillDirection.TopToBottom);
            }
        }
Пример #3
0
        /// <summary>
        /// Paints a background with a gradient.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="alpha">the alpha value between white and the background color for the starting gradiant color.</param>
        /// <param name="gradientHeight">the height of the gradient until solid color.</param>
        public void PaintGradientBackground(FluidPaintEventArgs e, int alpha, int gradientHeight)
        {
            Graphics  g          = e.Graphics;
            Rectangle r          = e.ControlBounds;
            Color     color      = BackColor;
            Color     startColor = ColorConverter.AlphaBlendColor(Color.White, color, alpha);

            Rectangle gr = r;

            gr.Height = gradientHeight;
            GdiExt.GradientFill(g, gr, startColor, color, GdiExt.FillDirection.TopToBottom);
            if (gr.Height < r.Height)
            {
                gr.Y      = r.Top + gradientHeight;
                gr.Height = r.Height - gradientHeight;
                using (SolidBrush brush = new SolidBrush(BackColor))
                {
                    g.FillRectangle(brush, gr);
                }
            }

            r.Width--;
            r.Height--;
            using (Pen pen = new Pen(color))
            {
                g.DrawRectangle(pen, r);
            }
        }
Пример #4
0
        public void ScrollUp(int dy)
        {
            graphics.ResetClip();
            GdiExt.ScrollUp(graphics, dy, dbuffer.Width, dbuffer.Height);
            Rectangle invalidBounds = new Rectangle(0, dbuffer.Height - dy, Width, dy);

            Invalidate(invalidBounds);
        }
Пример #5
0
        private void PaintCached(FluidPaintEventArgs pe)
        {
            Bitmap    bm   = CreateChachedBitmap();
            Rectangle rect = pe.ControlBounds;

            ia.SetColorKey(transparentColor, transparentColor);
            if (alpha < 255)
            {
                GdiExt.AlphaBlendImage(pe.Graphics, bm, rect.X, rect.Y, alpha, true);
            }
            else
            {
                pe.Graphics.DrawImage(bm, rect, 0, 0, bm.Width, bm.Height, GraphicsUnit.Pixel, ia);
            }
        }
Пример #6
0
        public void Paint(FluidPaintEventArgs e, FluidControl control, PaintFunc paintFunc, int alpha)
        {
            Rectangle dst = e.ControlBounds;

            //            Rectangle dst = control.Bounds;
            EnsureDBuffer(dst.Width, dst.Height);
            PaintBuffer(paintFunc, e.ScaleFactor);
            if (alpha >= 255)
            {
                e.Graphics.DrawImage(dbuffer, dst.X, dst.Y);
            }
            else
            {
                GdiExt.AlphaBlendImage(e.Graphics, dbuffer, dst.X, dst.Y, alpha, false);
            }
        }
Пример #7
0
        /// <summary>
        /// Paints the bitmap  with the scrollbar button which is temporarily added to the buffer.
        /// </summary>
        /// <param name="pe"></param>
        private void PaintDbWithScrollButtonBitmap(FluidPaintEventArgs pe)
        {
            Rectangle bounds = GetBufferedScrollbarButtonBounds();

            DoubleBuffer buffer  = EnsureScrollbarButtonBuffer(bounds.Width, bounds.Height);
            Graphics     g       = doubleBuffer.Graphics;
            Graphics     bufferG = buffer.Graphics;
            Rectangle    clip    = new Rectangle(0, 0, bounds.Width, bounds.Height);

            GdiExt.Copy(g, bounds, bufferG, 0, 0);
            PaintScrollBarButton(g, bounds);
            Rectangle r = pe.ControlBounds;

            PaintDBuffer(pe, r.X, r.Y);

            GdiExt.Copy(bufferG, clip, g, bounds.X, bounds.Y);
        }
Пример #8
0
 public override void OnPaint(FluidPaintEventArgs e)
 {
     if (IsDoubleBuffered)
     {
         base.OnPaint(e);
     }
     else
     {
         EnsureDBuffer();
         EnsureRegion();
         EnsurePaintEvents();
         if (!invalidRegion.IsEmpty(e.Graphics))
         {
             using (Graphics g = Graphics.FromImage(dbuffer))
             {
                 g.Clip = invalidRegion;
                 paintEvents.Graphics       = g;
                 paintEvents.ScaleFactor    = e.ScaleFactor;
                 paintEvents.ControlBounds  = ClientRectangle;
                 paintEvents.Region         = invalidRegion;
                 paintEvents.DoubleBuffered = true;
                 base.OnPaint(paintEvents);
             }
             invalidRegion.MakeEmpty();
         }
         Rectangle bounds = e.ControlBounds;
         if (IsOpaque)
         {
             Rectangle srcRect = ClientRectangle;
             //e.Graphics.DrawImage(dbuffer, bounds.X, bounds.Y);
             e.Graphics.DrawImage(dbuffer, bounds, srcRect, GraphicsUnit.Pixel);
         }
         else
         {
             GdiExt.AlphaBlendImage(e.Graphics, dbuffer, bounds, alpha, false);
             //                    e.Graphics.DrawImage(dbuffer, bounds, 0, 0, Width, Height, GraphicsUnit.Pixel, imageAttributes);
         }
     }
 }