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); } }
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); } } }
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); } }
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); } }