protected override void OnPaintBackground(FluidPaintEventArgs e) { // using (SolidBrush b = new SolidBrush(Color.Transparent)) // { //// e.Graphics.FillRectangle(b, e.ControlBounds); // } }
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); }
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); }
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); } } } } } }
protected virtual void PaintText(FluidPaintEventArgs e) { if (!string.IsNullOrEmpty(Text)) { PaintDefaultText(e, Text); } }
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(); } } } }
protected void PerformPaintButtonContent(FluidPaintEventArgs e) { if (OnPaintContent(e) == false) { PaintDefaultContent(e); } }
/// <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); } } } }
/// <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); } }
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); } }
private void EnsurePaintEvents() { if (paintEvents == null) { paintEvents = new FluidPaintEventArgs(); } }
private FluidPaintEventArgs EnsurePaintEventArgs() { if (paintEventArgs == null) { paintEventArgs = new FluidPaintEventArgs(); } return(paintEventArgs); }
/// <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); } }
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); }
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); }
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); } }
/// <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); } }
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); } }
protected override void OnPaintBackground(FluidPaintEventArgs e) { if (GradientFill) { this.PaintGradientBackground(e, 50, gradientFillOffset > 0 ? gradientFillOffset : Height); } else { base.OnPaintBackground(e); } }
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); } }
public override void OnPaint(FluidPaintEventArgs e) { if (inTransition) { DoubleBuffer buffer = EnsureDBuffer(); buffer.Paint(e, this, base.OnPaint, 255); } else { base.OnPaint(e); } }
public override void OnPaint(FluidPaintEventArgs e) { if (InternalEnableDoubleBuffer && dBufferRequired) { DoubleBuffer buffer = ensureDBuffer(); buffer.Paint(e, this, base.OnPaint, alpha); } else { base.OnPaint(e); } }
protected virtual bool OnPaintContent(FluidPaintEventArgs e) { if (PaintButtonText != null) { PaintButtonText(this, e); return(true); } else { return(false); } }
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); } }
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); }
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); } }
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); } } }
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); } }
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); } }
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); } }
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); }
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); }
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); } } }
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); }
protected override void OnPaintBackground(FluidPaintEventArgs e) { // dont use background painting }
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); } }
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); }
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); }
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); } } }
protected override void PaintControls(FluidPaintEventArgs pe) { PaintControl(pe, header); PaintControl(pe, navigation); }
protected override void OnPaintBackground(FluidPaintEventArgs e) { // do nothing }
public override void OnPaint(FluidPaintEventArgs e) { if (inTransition) { DoubleBuffer buffer = EnsureDBuffer(); buffer.Paint(e, this, base.OnPaint, 255); } else { base.OnPaint(e); } }
protected override void OnPaintBackground(FluidPaintEventArgs e) { //base.OnPaintBackground(e); }
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); } } }
protected override void OnPaintBackground(FluidPaintEventArgs e) { if (GradientFill) { this.PaintGradientBackground(e, 50, gradientFillOffset > 0 ? gradientFillOffset : Height); } else { base.OnPaintBackground(e); } }
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); } }
/// <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); }
protected virtual bool OnPaintContent(FluidPaintEventArgs e) { if (PaintButtonText != null) { PaintButtonText(this, e); return true; } else return false; }
/// <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); } } } }
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); }
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); } }
private void EnsurePaintEvents() { if (paintEvents == null) paintEvents = new FluidPaintEventArgs(); }
public override void OnPaint(FluidPaintEventArgs e) { if (InternalEnableDoubleBuffer && dBufferRequired) { DoubleBuffer buffer = ensureDBuffer(); buffer.Paint(e, this, base.OnPaint, alpha); } else base.OnPaint(e); }
protected override void PaintText(FluidPaintEventArgs e) { //base.PaintText(e); }
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; }
protected void PerformPaintButtonContent(FluidPaintEventArgs e) { if (OnPaintContent(e) == false) { PaintDefaultContent(e); } }
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; }
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); } }
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); } }
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); } }