protected override void OnPaint(PaintEventArgs pe) { pe.Graphics.Clear(BackColor); if (BackgroundImage != null) { Bitmap offscreenBitmap = new Bitmap(ClientSize.Width, ClientSize.Height); Graphics output = Graphics.FromImage(offscreenBitmap); EnhancedControlHelper.PaintBackground( output, BackgroundImage, ClientSize, Bounds, HorizontalAlignment, SizeXMode, VerticalAlignment, SizeYMode, AdaptBackground, HeaderHeight, FooterHeight, MarginLeftWidth, MarginRightWidth, HeaderTileWidth, FooterTileWidth, MarginLeftTileHeight, MarginRightTileHeight, Parent, FilterColor); pe.Graphics.DrawImage(offscreenBitmap, 0, 0); offscreenBitmap.Dispose(); if (iconimage != null) { pe.Graphics.DrawImage(iconimage, (BackgroundImage.Width / 6) - iconimage.Width, (BackgroundImage.Width / 6) - iconimage.Width); pe.Graphics.DrawString(this.Text, new Font("Tahoma", 8F, FontStyle.Bold), new SolidBrush(this.ForeColor), (BackgroundImage.Width / 6) + 5, (BackgroundImage.Width / 6) - iconimage.Width + 5); // pe.Graphics.DrawString(this.Text, new Font("Tahoma", 8F, FontStyle.Bold), new SolidBrush(this.ForeColor), 0,0); } } base.OnPaint(pe); }
protected override void OnPaint(PaintEventArgs pe) { pe.Graphics.Clear(BackColor); Bitmap currentImage = mouseDown ? ClickedBackgroundImage : BackgroundImage; if (currentImage != null) { Bitmap offscreenBitmap = new Bitmap(ClientSize.Width, ClientSize.Height); Graphics output = Graphics.FromImage(offscreenBitmap); EnhancedControlHelper.PaintBackground( output, currentImage, ClientSize, Bounds, HorizontalAlignment, SizeXMode, VerticalAlignment, SizeYMode, AdaptBackground, HeaderHeight, FooterHeight, MarginLeftWidth, MarginRightWidth, HeaderTileWidth, FooterTileWidth, MarginLeftTileHeight, MarginRightTileHeight, Parent, FilterColor); pe.Graphics.DrawImage(offscreenBitmap, 0, 0); offscreenBitmap.Dispose(); this.MisureString(); pe.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), (this.Width - wstring) / 2, this.Height - (this.Height / 3)); } }