private void ProtoSelectable_Paint(object sender, PaintEventArgs e) { if (this.Focused) { Brush back = ProtoListControlHelp.GetFocusBrush(e.ClipRectangle, BackColor); e.Graphics.FillRectangle(back, e.ClipRectangle); ProtoFrameControlHelp.DrawFocusRectangle(e.Graphics, e.ClipRectangle); e.Graphics.DrawString(Text, Font, new SolidBrush(Color.White), e.ClipRectangle, Format); } else { e.Graphics.FillRectangle(new SolidBrush(Color.White), e.ClipRectangle); e.Graphics.DrawString(Text, Font, new SolidBrush(this.ForeColor), e.ClipRectangle, Format); } }
protected override void OnPaint(PaintEventArgs e) { DrawBackGround(e.Graphics); ProtoFrameControlHelp.DrawBorder(e.Graphics, this.ClientRectangle, Color.Black); if (Bitmap == null) { return; } Rectangle rect = SrcRect; if (SrcRect.Width == 0 && SrcRect.Height == 0) { rect = new Rectangle(new Point(0, 0), bitmap.Size); } int x = 0, y = 0; if (ImageAlignCenter) { x = (int)(e.Graphics.ClipBounds.Width - rect.Width) / 2; y = (int)(e.Graphics.ClipBounds.Height - rect.Height) / 2; } else { x = ((bitmap.Width) - bitmap.Width) / 2; y = ((bitmap.Height) - bitmap.Height) / 2; } if (Scale) { e.Graphics.DrawImage(bitmap, e.ClipRectangle, rect, GraphicsUnit.Pixel); } else { e.Graphics.DrawImage(bitmap, new Rectangle(x, y, rect.Width, rect.Height), rect, GraphicsUnit.Pixel); } if (this.UseRectangleFocus && this.Focused) { ProtoFrameControlHelp.DrawFocusRectangle(e.Graphics, e.ClipRectangle); } }