예제 #1
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);
            }
        }
예제 #2
0
파일: Line.cs 프로젝트: Radytz/DroppedBoxx
 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);
     }
 }
예제 #3
0
파일: Line.cs 프로젝트: Radytz/DroppedBoxx
        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);
            }
        }
예제 #4
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);
        }
예제 #5
0
        protected void PaintDefaultText(FluidPaintEventArgs e, string text)
        {
            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)
            {
                if (ShadowColor.IsEmpty)
                {
                    brush.Color = Enabled ? ForeColor : Color.Silver;
                    g.DrawString(text, Font, brush, RectFFromRect(bounds), stringFormat);
                }
                else
                {
                    Fluid.Drawing.GdiPlus.GdiExt.DrawStringShadow(g, text, Font, ForeColor, ShadowColor, bounds, stringFormat);
                }
            }
        }
예제 #6
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);
            }
        }
예제 #7
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);
            }
        }
예제 #8
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);
        }
예제 #9
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.Fuchsia, Color.Fuchsia);
                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);
            }
        }
예제 #10
0
파일: Label.cs 프로젝트: north0808/haina
 protected void PaintDefaultText(FluidPaintEventArgs e, string text)
 {
     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)
     {
         if (ShadowColor.IsEmpty)
         {
             brush.Color = Enabled ? ForeColor : Color.Silver;
             g.DrawString(text, Font, brush, RectFFromRect(bounds), stringFormat);
         }
         else
         {
             Fluid.Drawing.GdiPlus.GdiExt.DrawStringShadow(g, text, Font, ForeColor, ShadowColor, bounds, stringFormat);
         }
     }
 }