protected override void OnPaint(PaintEventArgs e) { Bitmap offscreenBitmap = new Bitmap(ClientSize.Width, ClientSize.Height); Graphics output = Graphics.FromImage(offscreenBitmap); EnhancedControlHelper.PaintRoundedBackground( output, ClientRectangle, Bounds, BorderSize, BorderColor, CornerRadius, plainLeft, plainRight, plainTop, plainBottom, false, BackColor, Parent, FilterColor); e.Graphics.DrawImage(offscreenBitmap, 0, 0); offscreenBitmap.Dispose(); base.OnPaint(e); }
protected override void OnPaint(PaintEventArgs e) { SizeF headerSize = e.Graphics.MeasureString(HeaderText, headerFont); if (!InlineHeader) { EnhancedControlHelper.PaintRoundedBackground( e.Graphics, new Rectangle(0, HeaderHeight, (int)Math.Ceiling(ClientSize.Width), ClientSize.Height - HeaderHeight), Bounds, BorderSize, BorderColor, CornerRadius, false, false, false, false, false, BackColor, Parent, FilterColor); Color fillColor = BackColor; if (BackColor == Color.Transparent) { fillColor = Parent.BackColor; } Brush fillBrush = new SolidBrush(fillColor); RectangleF headerRectangle = new RectangleF( Math.Max(HeaderOffset * ClientSize.Width, CornerRadius + BorderSize), 0, Math.Min(ClientSize.Width - BorderSize - Math.Max(HeaderOffset * headerSize.Width, CornerRadius + BorderSize), headerSize.Width + 8), HeaderHeight); if (HeaderOffset == 0) { headerRectangle.X = 0; } if (HeaderOffset == 1) { headerRectangle.X = ClientSize.Width - headerRectangle.Width; } RectangleF textRectangle = new RectangleF( headerRectangle.X + (headerRectangle.Width - headerSize.Width) / 2, headerRectangle.Y + (HeaderHeight - headerSize.Height) / 2, headerRectangle.Width, headerRectangle.Height); e.Graphics.FillRectangle( fillBrush, (int)Math.Ceiling(headerRectangle.X), (int)Math.Ceiling(HeaderHeight), (int)Math.Ceiling(headerRectangle.Width), (int)Math.Ceiling((headerOffset != 0 && headerOffset != 1) ? BorderSize : BorderSize + CornerRadius)); Brush borderBursh = new SolidBrush(BorderColor); if (headerOffset == 0) { e.Graphics.FillRectangle(borderBursh, new Rectangle(0, (int)Math.Ceiling(HeaderHeight), BorderSize, BorderSize + CornerRadius)); } if (headerOffset == 1) { e.Graphics.FillRectangle(borderBursh, new Rectangle(ClientSize.Width - BorderSize, (int)Math.Ceiling(headerSize.Height + HeaderHeight), BorderSize, BorderSize + CornerRadius)); } EnhancedControlHelper.PaintRoundedRectangle( e.Graphics, BorderColor, BorderSize, HeaderBackColor, new Rectangle((int)Math.Ceiling(headerRectangle.X), (int)Math.Ceiling(headerRectangle.Y), (int)Math.Ceiling(headerRectangle.Width), (int)headerRectangle.Height + BorderSize), new Size(CornerRadius, CornerRadius), false, false, false, true); Brush textBrush = new SolidBrush(HeaderColor); e.Graphics.DrawString(HeaderText, headerFont, textBrush, textRectangle); borderBursh.Dispose(); fillBrush.Dispose(); } else { EnhancedControlHelper.PaintRoundedBackground( e.Graphics, new Rectangle(0, (int)(headerSize.Height / 2), (int)Math.Ceiling(ClientSize.Width), ClientSize.Height - (int)(headerSize.Height / 2)), Bounds, BorderSize, BorderColor, CornerRadius, false, false, false, false, false, BackColor, Parent, FilterColor); RectangleF headerRectangle = new RectangleF( Math.Max(HeaderOffset * ClientSize.Width, CornerRadius + BorderSize), 0, Math.Min(ClientSize.Width - BorderSize - Math.Max(HeaderOffset * headerSize.Width, CornerRadius + BorderSize), HeaderHeight), headerSize.Height); RectangleF textRectangle = new RectangleF( headerRectangle.X + (headerRectangle.Width - headerSize.Width) / 2, (headerRectangle.Height - headerSize.Height) / 2, headerRectangle.Width, headerSize.Height); Color fillColor = BackColor; if (BackColor == Color.Transparent) { fillColor = Parent.BackColor; } if (HeaderOffset == 0) { headerRectangle.X = 0; } if (HeaderOffset == 1) { headerRectangle.X = ClientSize.Width - headerRectangle.Width; } Brush textBrush = new SolidBrush(HeaderColor); e.Graphics.DrawString(HeaderText, headerFont, textBrush, textRectangle); textBrush.Dispose(); } }