Esempio n. 1
0
 protected override void OnPaintBackground(FluidPaintEventArgs e)
 {
     //     using (SolidBrush b = new SolidBrush(Color.Transparent))
     //     {
     ////         e.Graphics.FillRectangle(b, e.ControlBounds);
     //     }
 }
Esempio n. 2
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);
        }
Esempio n. 3
0
        private void PaintControlDoubleBuffered(FluidPaintEventArgs pe, FluidControl control, Rectangle bounds)
        {
            Bitmap buffer;

            if (imageBuffer.Contains(control))
            {
                buffer = imageBuffer[control] as Bitmap;
            }
            else
            {
                buffer = new Bitmap(bounds.Width, bounds.Height);
                imageBuffer.Add(control, buffer);
                using (Graphics bg = Graphics.FromImage(buffer))
                {
                    this.transparentBrush.Color = transparentColor;
                    bg.FillRectangle(transparentBrush, 0, 0, buffer.Width, buffer.Height);
                    Rectangle paintRect = control.ClientRectangle;
                    //bg.Clear(transparentColor);

                    FluidPaintEventArgs e = paintEventArgs;
                    e.Graphics      = bg;
                    e.ControlBounds = paintRect;
                    e.Region        = bg.Clip;
                    e.ScaleFactor   = pe.ScaleFactor;
                    control.OnPaint(e);
                }
            }
            ia.SetColorKey(transparentColor, transparentColor);
            pe.Graphics.DrawImage(buffer, bounds, 0, 0, bounds.Width, bounds.Height, GraphicsUnit.Pixel, ia);
        }
Esempio n. 4
0
 protected virtual void OnPaintBackground(FluidPaintEventArgs e)
 {
     if (PaintBackground != null)
     {
         PaintBackground(this, e);
     }
     else
     {
         if (!BackColor.IsEmpty && BackColor != Color.Transparent)
         {
             Graphics g = e.Graphics;
             if (BackColor.A == 255 || BackColor.A == 0)
             {
                 SolidBrush brush = Brushes.GetBrush(BackColor);
                 g.FillRectangle(brush, e.ControlBounds);
             }
             else
             {
                 using (GraphicsPlus gp = new GraphicsPlus(g))
                 {
                     using (SolidBrushPlus brush = new SolidBrushPlus(BackColor))
                     {
                         gp.FillRectangle(brush, e.ControlBounds);
                     }
                 }
             }
         }
     }
 }
Esempio n. 5
0
 protected virtual void PaintText(FluidPaintEventArgs e)
 {
     if (!string.IsNullOrEmpty(Text))
     {
         PaintDefaultText(e, Text);
     }
 }
Esempio n. 6
0
 public void PaintBuffer(PaintFunc paintFunc, SizeF scaleFactor)
 {
     Graphics g = EnsureGraphics();
     {
         if (region == null || !region.IsEmpty(g))
         {
             //using (SolidBrush b = new SolidBrush(Color.Transparent))
             //{
             //    bg.FillRectangle(b, clientRectangle);
             //}
             FluidPaintEventArgs ea = EnsurePaintEventArgs();
             ea.Graphics       = g;
             ea.Region         = region;
             g.Clip            = region;
             ea.ScaleFactor    = scaleFactor;
             ea.ControlBounds  = new Rectangle(0, 0, Width, Height);
             ea.DoubleBuffered = false;
             paintFunc(ea);
             if (region != null)
             {
                 region.MakeEmpty();
             }
         }
     }
 }
Esempio n. 7
0
 protected void PerformPaintButtonContent(FluidPaintEventArgs e)
 {
     if (OnPaintContent(e) == false)
     {
         PaintDefaultContent(e);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Paints all  controls.
        /// </summary>
        /// <param name="pe">The PaintEventArgs.</param>
        private void PaintControls(FluidPaintEventArgs pe)
        {
            Rectangle controlBounds = pe.ControlBounds;
            Graphics  g             = pe.Graphics;
            Region    clip          = pe.Region;


            foreach (FluidControl c in controls)
            {
                if (!c.Visible)
                {
                    continue;
                }
                Rectangle bounds = c.Bounds;
                bounds.Offset(controlBounds.X, controlBounds.Y);
                if (clip.IsVisible(bounds))
                {
                    if (this.EnableDoubleBuffer && c.AllowDoubleBuffer)
                    {
                        PaintControlDoubleBuffered(pe, c, bounds);
                    }
                    else
                    {
                        PaintControlUnbuffered(pe, c, bounds);
                    }
                }
            }
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
        protected override void PaintText(FluidPaintEventArgs e)
        {
            if (focused)
            {
                Graphics g = e.Graphics;
                if (SelectBounds.IsEmpty)
                {
                    SelectBounds = GetSelectBounds(startSel, selCount);
                }
                Rectangle bounds  = e.ControlBounds;
                Rectangle selRect = SelectBounds;
                selRect.Offset(e.ScaleX(3), 0);
                selRect.Offset(bounds.X, bounds.Y);
                if (selRect.Width > 1)
                {
                    g.FillRectangle(Brushes.GetBrush(Color.SkyBlue), selRect);
                }
                else
                {
                    selRect.Width = 1;
                    g.FillRectangle(Brushes.GetBrush(Color.Black), selRect);
                }
            }

            string text = GetDisplayText();

            if (!string.IsNullOrEmpty(text))
            {
                PaintDefaultText(e, text);
            }
        }
Esempio n. 11
0
 private void EnsurePaintEvents()
 {
     if (paintEvents == null)
     {
         paintEvents = new FluidPaintEventArgs();
     }
 }
Esempio n. 12
0
 private FluidPaintEventArgs EnsurePaintEventArgs()
 {
     if (paintEventArgs == null)
     {
         paintEventArgs = new FluidPaintEventArgs();
     }
     return(paintEventArgs);
 }
Esempio n. 13
0
 /// <summary>
 /// Paints the content of this control.
 /// </summary>
 /// <param name="pe">The  paint event args.</param>
 protected virtual void PaintContent(FluidPaintEventArgs pe)
 {
     if (BackColor != Color.Transparent)
     {
         Rectangle bounds = pe.ControlBounds;
         backgroundBrush.Color = BackColor;
         pe.Graphics.FillRectangle(backgroundBrush, bounds);
     }
 }
Esempio n. 14
0
        protected void PaintDBuffer(FluidPaintEventArgs pe, int x, int y, Rectangle dstRect)
        {
            int       top     = ScaledTopOffset;
            int       dy      = DBufferTop - top;
            Rectangle srcRect = new Rectangle(0, -dy + dstRect.Y, dstRect.Width, dstRect.Height);

            dstRect.Offset(x, y);
            EnsureDoubleBuffer();
            pe.Graphics.DrawImage(doubleBuffer.Image, dstRect, srcRect, GraphicsUnit.Pixel);
        }
Esempio n. 15
0
        protected void PaintControlUnbuffered(FluidPaintEventArgs pe, FluidControl control, Rectangle bounds)
        {
            FluidPaintEventArgs e = paintEventArgs;

            e.Graphics      = pe.Graphics;
            e.ControlBounds = bounds;
            e.Region        = pe.Region;
            e.ScaleFactor   = pe.ScaleFactor;
            control.OnPaint(e);
        }
Esempio n. 16
0
 protected override void OnPaintBackground(FluidPaintEventArgs e)
 {
     base.OnPaintBackground(e);
     if (showBorder && !BorderColor.IsEmpty)
     {
         Rectangle r = e.ControlBounds;
         r.Width--;
         r.Height--;
         e.Graphics.DrawRectangle(Pens.GetPen(BorderColor), r);
     }
 }
Esempio n. 17
0
 /// <summary>
 /// Paints the control.
 /// Note: Dot derive this method, since it handles double buffering. Derive from PaintBuffered instead.
 /// </summary>
 /// <param name="pe">The FluidPaintEventArgs.</param>
 public override void OnPaint(FluidPaintEventArgs pe)
 {
     if (EnableDoubleBuffer)
     {
         PaintDoubleBuffered(pe);
     }
     else
     {
         PaintUnbuffered(pe);
     }
 }
Esempio n. 18
0
 private void PaintUnbuffered(FluidPaintEventArgs pe)
 {
     PaintContent(pe);
     if (IsScrollBarVisible)
     {
         Rectangle clip   = pe.ControlBounds;
         Rectangle bounds = GetScrollbarButtonBounds();
         bounds.Offset(clip.X, clip.Y);
         PaintScrollBarButton(pe.Graphics, bounds);
     }
 }
Esempio n. 19
0
 protected override void OnPaintBackground(FluidPaintEventArgs e)
 {
     if (GradientFill)
     {
         this.PaintGradientBackground(e, 50, gradientFillOffset > 0 ? gradientFillOffset : Height);
     }
     else
     {
         base.OnPaintBackground(e);
     }
 }
Esempio n. 20
0
        private void PaintControl(FluidPaintEventArgs pe, FluidControl c)
        {
            Rectangle controlBounds = pe.ControlBounds;
            Region    clip          = pe.Region;
            Rectangle bounds        = c.Bounds;

            bounds.Offset(controlBounds.X, controlBounds.Y);
            if (clip.IsVisible(bounds))
            {
                PaintControlUnbuffered(pe, c, bounds);
            }
        }
Esempio n. 21
0
 public override void OnPaint(FluidPaintEventArgs e)
 {
     if (inTransition)
     {
         DoubleBuffer buffer = EnsureDBuffer();
         buffer.Paint(e, this, base.OnPaint, 255);
     }
     else
     {
         base.OnPaint(e);
     }
 }
Esempio n. 22
0
 public override void OnPaint(FluidPaintEventArgs e)
 {
     if (InternalEnableDoubleBuffer && dBufferRequired)
     {
         DoubleBuffer buffer = ensureDBuffer();
         buffer.Paint(e, this, base.OnPaint, alpha);
     }
     else
     {
         base.OnPaint(e);
     }
 }
Esempio n. 23
0
 protected virtual bool OnPaintContent(FluidPaintEventArgs e)
 {
     if (PaintButtonText != null)
     {
         PaintButtonText(this, e);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 24
0
 public override void OnPaint(FluidPaintEventArgs e)
 {
     base.OnPaint(e);
     Graphics g = e.Graphics;
     Rectangle bounds = e.ControlBounds;
     bounds.Inflate(e.ScaleX(-3), e.ScaleY(-1));
     //bounds.Y += e.ScaleY(-1);
     if (bounds.Height > 0 && bounds.Width > 0)
     {
         pen.Color = Enabled ? ForeColor : Color.Silver;
         g.DrawLine(pen, bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
     }
 }
Esempio n. 25
0
        private void PaintControlUnbuffered(FluidPaintEventArgs pe, FluidControl control, Rectangle bounds)
        {
            //bounds.Offset(Left, Top);
            //Region clp = pe.IntersectClip(bounds);
            FluidPaintEventArgs e = paintEventArgs2;

            e.Graphics      = pe.Graphics;
            e.ControlBounds = bounds;
            e.Region        = pe.Region;
            e.ScaleFactor   = pe.ScaleFactor;
            control.OnPaint(e);
            //pe.ResetClip(clp);
        }
Esempio n. 26
0
 public void PaintTemplate()
 {
     if (Template != null)
     {
         Template.BackColor = this.BackColor;
         Template.ForeColor = ForeColor;
         FluidPaintEventArgs e = paintEvent;
         e.Graphics      = Graphics;
         e.Region        = Region;
         e.ControlBounds = ClientBounds;
         e.ScaleFactor   = ScaleFactor;
         Template.OnPaint(e);
     }
 }
Esempio n. 27
0
 public override void OnPaint(FluidPaintEventArgs e)
 {
     base.OnPaint(e);
     if (showBorder)
     {
         using (Pen pen = new Pen(Color.Black))
         {
             Rectangle bounds = e.ControlBounds;
             bounds.Width--;
             bounds.Height--;
             e.Graphics.DrawRectangle(pen, bounds);
         }
     }
 }
Esempio n. 28
0
        public override void OnPaint(FluidPaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics  g      = e.Graphics;
            Rectangle bounds = e.ControlBounds;

            bounds.Inflate(e.ScaleX(-3), e.ScaleY(-1));
            //bounds.Y += e.ScaleY(-1);
            if (bounds.Height > 0 && bounds.Width > 0)
            {
                pen.Color = Enabled ? ForeColor : Color.Silver;
                g.DrawLine(pen, bounds.X, bounds.Y, bounds.X + bounds.Width, bounds.Y);
            }
        }
Esempio n. 29
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);
            }
        }
Esempio n. 30
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);
            }
        }
Esempio n. 31
0
        protected virtual void PaintButtonBackground(FluidPaintEventArgs e)
        {
            const int const_radius = 8;

            if (this.shape != ButtonShape.Flat || IsDown)
            {
                Rectangle rect = ButtonRectangle;
                rect.Width--;
                rect.Height--;
                if (rect.Width < 1 || rect.Height < 1)
                {
                    return;
                }

                rect.Offset(e.ControlBounds.X, e.ControlBounds.Y);

                Graphics g = e.Graphics;


                int radius = e.ScaleX(const_radius);
                if (radius > rect.Width / 2)
                {
                    radius = rect.Width / 2;
                }

                Color endColor = this.BackColor;
                if (!Enabled)
                {
                    endColor = ColorConverter.AlphaBlendColor(Color.Black, endColor, 128);
                }
                int   alpha       = Enabled ? 127 : 32;
                Color startColor  = ColorConverter.AlphaBlendColor(endColor, Color.White, alpha); //Color.FromArgb(0x7fffffff);
                Color borderColor = ColorConverter.AlphaBlendColor(endColor, Color.White, 100);

                GraphicShape shape = ButtonShapeToGraphic(this.shape);
                using (GraphicsPlus gp = new GraphicsPlus(g))
                {
                    GraphicsPlus.GradientMode mode = IsDown ? GraphicsPlus.GradientMode.Bottom : GraphicsPlus.GradientMode.Top;
                    gp.GradientFillShape(rect, radius, startColor, endColor, mode, shape, corners);
                    using (PenPlus pen = new PenPlus(borderColor, (float)1))
                    {
                        gp.DrawShape(rect, radius, pen, shape, corners);
                    }
                }
            }
            PerformPaintButtonContent(e);
        }
Esempio n. 32
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);
        }
Esempio n. 33
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);
         }
     }
 }
Esempio n. 34
0
        protected override void PaintControls(FluidPaintEventArgs pe)
        {
            FluidControl c = SelectedControl;
            FluidControl tc = transitionControl;

            if (tc == null && (c is PageControl))
            {
                /// build a short cut for performance issues:
                c = ((PageControl)c).Control;
            }
            if (c != null) PaintControl(pe, c);

            if (tc != null) PaintControl(pe, tc);
        }
Esempio n. 35
0
 protected override void OnPaintBackground(FluidPaintEventArgs e)
 {
     // dont use background painting
 }
Esempio n. 36
0
        protected override void PaintText(FluidPaintEventArgs e)
        {
            if (focused)
            {
                Graphics g = e.Graphics;
                if (SelectBounds.IsEmpty) SelectBounds = GetSelectBounds(startSel, selCount);
                Rectangle bounds = e.ControlBounds;
                Rectangle selRect = SelectBounds;
                selRect.Offset(e.ScaleX(3), 0);
                selRect.Offset(bounds.X, bounds.Y);
                if (selRect.Width > 1)
                {
                    g.FillRectangle(Brushes.GetBrush(Color.SkyBlue), selRect);
                }
                else
                {
                    selRect.Width = 1;
                    g.FillRectangle(Brushes.GetBrush(Color.Black), selRect);
                }
            }

            string text = GetDisplayText();
            if (!string.IsNullOrEmpty(text))
            {
                PaintDefaultText(e, text);
            }
        }
Esempio n. 37
0
 private void PaintControlUnbuffered(FluidPaintEventArgs pe, FluidControl control, Rectangle bounds)
 {
     //bounds.Offset(Left, Top);
     //Region clp = pe.IntersectClip(bounds);
     FluidPaintEventArgs e = paintEventArgs2;
     e.Graphics = pe.Graphics;
     e.ControlBounds = bounds;
     e.Region = pe.Region;
     e.ScaleFactor = pe.ScaleFactor;
     control.OnPaint(e);
     //pe.ResetClip(clp);
 }
Esempio n. 38
0
        private void PaintControlDoubleBuffered(FluidPaintEventArgs pe, FluidControl control, Rectangle bounds)
        {
            Bitmap buffer;
            if (imageBuffer.Contains(control))
            {
                buffer = imageBuffer[control] as Bitmap;
            }
            else
            {
                buffer = new Bitmap(bounds.Width, bounds.Height);
                imageBuffer.Add(control, buffer);
                using (Graphics bg = Graphics.FromImage(buffer))
                {
                    this.transparentBrush.Color = transparentColor;
                    bg.FillRectangle(transparentBrush, 0, 0, buffer.Width, buffer.Height);
                    Rectangle paintRect = control.ClientRectangle;
                    //bg.Clear(transparentColor);

                    FluidPaintEventArgs e = paintEventArgs;
                    e.Graphics = bg;
                    e.ControlBounds = paintRect;
                    e.Region = bg.Clip;
                    e.ScaleFactor = pe.ScaleFactor;
                    control.OnPaint(e);
                }

            }
            ia.SetColorKey(transparentColor, transparentColor);
            pe.Graphics.DrawImage(buffer, bounds, 0, 0, bounds.Width, bounds.Height, GraphicsUnit.Pixel, ia);
        }
Esempio n. 39
0
 public override void OnPaint(FluidPaintEventArgs e)
 {
     base.OnPaint(e);
     if (showBorder)
     {
         using (Pen pen = new Pen(Color.Black))
         {
             Rectangle bounds = e.ControlBounds;
             bounds.Width--;
             bounds.Height--;
             e.Graphics.DrawRectangle(pen, bounds);
         }
     }
 }
Esempio n. 40
0
 protected override void PaintControls(FluidPaintEventArgs pe)
 {
     PaintControl(pe, header);
     PaintControl(pe, navigation);
 }
Esempio n. 41
0
 protected override void OnPaintBackground(FluidPaintEventArgs e)
 {
     //  do nothing
 }
Esempio n. 42
0
        public override void OnPaint(FluidPaintEventArgs e)
        {
            if (inTransition)
            {
                DoubleBuffer buffer = EnsureDBuffer();
                buffer.Paint(e, this, base.OnPaint, 255);

            }
            else
            {
                base.OnPaint(e);
            }
        }
Esempio n. 43
0
 protected override void OnPaintBackground(FluidPaintEventArgs e)
 {
     //base.OnPaintBackground(e);
 }
Esempio n. 44
0
        void btn_PaintButtonText(object sender, FluidPaintEventArgs e)
        {
            FluidButton btn = (FluidButton)sender;

            string text = btn.Text;
            if (text.Length > 0)
            {
                Brush brush = IsDown ? downTextbrush : textBrush;
                string bigText = text.Substring(0, 1);
                string smallText = text.Substring(1);
                Graphics g = e.Graphics;
                Rectangle r = e.ControlBounds;
                if (IsDown) r.Offset(ScaleX(1), ScaleY(1));
                stringFormat.Alignment = StringAlignment.Near;
                stringFormat.LineAlignment = StringAlignment.Center;
                SizeF bigSize = g.MeasureString(bigText, bigFont);
                float smallWidth = string.IsNullOrEmpty(smallText) ? 0f : e.ScaleFactor.Width * 5f + g.MeasureString(smallText, smallFont).Width;
                int dw = (int)((btn.Width - smallWidth) / 2f);
                //int dh = (int)((btn.Height - bigSize.Height) / 2f);
                int dh = (int)(2f * e.ScaleFactor.Width);
                r.Inflate(-dw, -dh);
                RectangleF rf = RectFFromRect(r);
                g.DrawString(bigText, bigFont, brush, rf, stringFormat);

                if (!string.IsNullOrEmpty(smallText))
                {
                    float width = bigSize.Width + 4f * e.ScaleFactor.Width;
                    rf.X += width;
                    g.DrawString(smallText, smallFont, brush, rf, stringFormat);
                }
            }
        }
Esempio n. 45
0
 protected override void OnPaintBackground(FluidPaintEventArgs e)
 {
     if (GradientFill)
     {
         this.PaintGradientBackground(e, 50, gradientFillOffset > 0 ? gradientFillOffset : Height);
     }
     else
     {
         base.OnPaintBackground(e);
     }
 }
Esempio n. 46
0
 protected override void OnPaintBackground(FluidPaintEventArgs e)
 {
     Size size = bounds.Size;
     if (size.Width <= 0 || size.Height <= 0) return;
     if (EnableCache)
     {
         PaintCached(e);
     }
     else
     {
         PaintButtonBackground(e);
     }
 }
Esempio n. 47
0
 /// <summary>
 /// Paints this control double buffered.
 /// </summary>
 /// <param name="pe">The  paint event args.</param>
 protected override void PaintContent(FluidPaintEventArgs pe)
 {
     base.PaintContent(pe);
     PaintControls(pe);
 }
Esempio n. 48
0
 protected virtual bool OnPaintContent(FluidPaintEventArgs e)
 {
     if (PaintButtonText != null)
     {
         PaintButtonText(this, e);
         return true;
     }
     else return false;
 }
Esempio n. 49
0
        /// <summary>
        /// Paints all  controls.
        /// </summary>
        /// <param name="pe">The PaintEventArgs.</param>
        private void PaintControls(FluidPaintEventArgs pe)
        {
            Rectangle controlBounds = pe.ControlBounds;
            Graphics g = pe.Graphics;
            Region clip = pe.Region;

            foreach (FluidControl c in controls)
            {
                if (!c.Visible) continue;
                Rectangle bounds = c.Bounds;
                bounds.Offset(controlBounds.X, controlBounds.Y);
                if (clip.IsVisible(bounds))
                {
                    if (this.EnableDoubleBuffer && c.AllowDoubleBuffer)
                    {
                        PaintControlDoubleBuffered(pe, c, bounds);
                    }
                    else
                    {
                        PaintControlUnbuffered(pe, c, bounds);
                    }
                }
            }
        }
Esempio n. 50
0
        protected virtual void PaintButtonBackground(FluidPaintEventArgs e)
        {
            const int const_radius = 8;

            if (this.shape != ButtonShape.Flat || IsDown)
            {
                Rectangle rect = ButtonRectangle;
                rect.Width--;
                rect.Height--;
                if (rect.Width < 1 || rect.Height < 1)
                {
                    return;
                }

                rect.Offset(e.ControlBounds.X, e.ControlBounds.Y);

                Graphics g = e.Graphics;

                int radius = e.ScaleX(const_radius);
                if (radius > rect.Width / 2) radius = rect.Width / 2;

                Color endColor = this.BackColor;
                if (!Enabled)
                {
                    endColor = ColorConverter.AlphaBlendColor(Color.Black, endColor, 128);
                }
                int alpha = Enabled ? 127 : 32;
                Color startColor = ColorConverter.AlphaBlendColor(endColor, Color.White, alpha);  //Color.FromArgb(0x7fffffff);
                Color borderColor = ColorConverter.AlphaBlendColor(endColor, Color.White, 100);

                GraphicShape shape = ButtonShapeToGraphic(this.shape);
                using (GraphicsPlus gp = new GraphicsPlus(g))
                {
                    if (GradientFill)
                    {
                        GraphicsPlus.GradientMode mode = IsDown ? GraphicsPlus.GradientMode.Bottom : GraphicsPlus.GradientMode.Top;
                        gp.GradientFillShape(rect, radius, startColor, endColor, mode, shape, corners);
                        using (PenPlus pen = new PenPlus(borderColor, (float)1))
                        {
                            gp.DrawShape(rect, radius, pen, shape, corners);
                        }
                    }
                    else
                    {
                        if (IsDown)
                        {
                            endColor = ColorConverter.AlphaBlendColor(endColor, endColor, 128);
                        }
                        gp.GradientFillShape(rect, radius, endColor, endColor, GraphicsPlus.GradientMode.Bottom, shape, corners);
                        using (PenPlus pen = new PenPlus(borderColor, (float)1))
                        {
                            gp.DrawShape(rect, radius, pen, shape, corners);
                        }
                    }
                }
            }
            PerformPaintButtonContent(e);
        }
Esempio n. 51
0
 protected override void OnPaintBackground(FluidPaintEventArgs e)
 {
     base.OnPaintBackground(e);
     if (showBorder && !BorderColor.IsEmpty)
     {
         Rectangle r = e.ControlBounds;
         r.Width--;
         r.Height--;
         e.Graphics.DrawRectangle(Pens.GetPen(BorderColor), r);
     }
 }
Esempio n. 52
0
 private void EnsurePaintEvents()
 {
     if (paintEvents == null) paintEvents = new FluidPaintEventArgs();
 }
Esempio n. 53
0
 public override void OnPaint(FluidPaintEventArgs e)
 {
     if (InternalEnableDoubleBuffer && dBufferRequired)
     {
         DoubleBuffer buffer = ensureDBuffer();
         buffer.Paint(e, this, base.OnPaint, alpha);
     }
     else base.OnPaint(e);
 }
Esempio n. 54
0
 protected override void PaintText(FluidPaintEventArgs e)
 {
     //base.PaintText(e);
 }
Esempio n. 55
0
 protected override Rectangle PaintControl(FluidPaintEventArgs pe, FluidControl c)
 {
     Rectangle controlBounds = pe.ControlBounds;
     Region clip = pe.Region;
     Rectangle bounds = c.Bounds;
     bounds.Offset(controlBounds.X, controlBounds.Y);
     if (clip.IsVisible(bounds))
     {
         PaintControlUnbuffered(pe, c, bounds);
     }
     return bounds;
 }
Esempio n. 56
0
 protected void PerformPaintButtonContent(FluidPaintEventArgs e)
 {
     if (OnPaintContent(e) == false)
     {
         PaintDefaultContent(e);
     }
 }
Esempio n. 57
0
 private Bitmap CreateBitmap(string key)
 {
     Size size = GetButtonSize();
     int w = Math.Max(size.Width, 2);
     int h = Math.Max(size.Height, 2);
     Bitmap bm = new Bitmap(w, h);
     using (Graphics g = Graphics.FromImage(bm))
     {
         transparentBrush.Color = transparentColor;
         g.FillRectangle(transparentBrush, 0, 0, bm.Width, bm.Height);
         //g.Clear(transparentColor);
         FluidPaintEventArgs pe = new FluidPaintEventArgs(g, ClientRectangle, ScaleFactor);
         PaintButtonBackground(pe);
     }
     cachedBitmaps.Add(key, bm);
     return bm;
 }
Esempio n. 58
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);
     }
 }
Esempio n. 59
0
        protected void PaintDefaultContent(FluidPaintEventArgs e)
        {
            Rectangle rect = ButtonRectangle;
            Color endColor = this.BackColor;
            Graphics g = e.Graphics;
            rect.Offset(e.ControlBounds.X, e.ControlBounds.Y);
            Color textColor = ForeColor;
            if (IsDown)
            {
                textColor = pressedForeColor.IsEmpty ? ColorConverter.AlphaBlendColor(endColor, textColor, 200) : pressedForeColor;
            }
            if (!Enabled)
            {
                textColor = ColorConverter.AlphaBlendColor(endColor, textColor, 32);
            }
            Brush foreBrush = Brushes.GetBrush(textColor);
            StringFormat sf = this.stringFormat;
            Rectangle r = rect;
            r.Inflate(e.ScaleX(-3), e.ScaleY(2));
            RectangleF rf = new RectangleF(r.Left, r.Top, r.Width, r.Height);
            if (IsDown)
            {
                rf.X++;
                rf.Y++;
            }

            rf.X += (float)ScaleX(TextOffset.X);
            rf.Y += (float)ScaleY(TextOffset.Y);

            g.DrawString(Text, Font, foreBrush, rf, sf);

            if (Image != null)
            {
                int imW = ScaleX(Image.Width);
                int imH = ScaleY(Image.Height);

                int w = Math.Min(imW, rect.Width);
                int h = Math.Min(imH, rect.Height);

                rect.Y += (rect.Height - h) / 2;
                rect.X += (rect.Width - h) / 2;
                rect.Width = w;
                rect.Height = h;
                ImageAttributes ia = new ImageAttributes();
                ia.SetColorKey(Color.Transparent, Color.Transparent);
                if (rect.Width > w)
                {
                    rect.X += (rect.Width - w) / 2;
                    rect.Width = w;
                }
                if (rect.Height > h)
                {
                    rect.X += (rect.Height-h) / 2;
                    rect.Height = h;
                }
                if (IsDown)
                {
                    rect.X++;
                    rect.Y++;
                }
                g.DrawImage(Image, rect, 0, 0, Image.Width,Image.Height, GraphicsUnit.Pixel, ia);
                //                g.DrawImage(Image, rect, new Rectangle(0, 0, imW, imH), GraphicsUnit.Pixel);
            }
        }
Esempio n. 60
0
 private void PaintControl(FluidPaintEventArgs pe, FluidControl c)
 {
     Rectangle controlBounds = pe.ControlBounds;
     Region clip = pe.Region;
     Rectangle bounds = c.Bounds;
     bounds.Offset(controlBounds.X, controlBounds.Y);
     if (clip.IsVisible(bounds))
     {
         PaintControlUnbuffered(pe, c, bounds);
     }
 }