protected override void OnPaint(PaintEventArgs e)
{
try
{
Graphics g = e.Graphics;//获取绘制对象
///设置参数
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; //图片柔顺模式选择
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;//高质量
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;//再加一点
int topheight = 30;
//绘制Title标题 ----//填充区域
g.FillRectangle(new SolidBrush(Color.FromArgb(223, 221, 216)), 0, 0, Width, topheight);
绘制标题
int numw = (int)g.MeasureString("新建窗体", Font).Width;
int numh = (int)g.MeasureString("新建窗体", Font).Height;
g.DrawString("新建窗体", Font, new SolidBrush(Color.FromArgb(100, 99, 94)), new PointF(topheight, topheight / 2 - numh / 2));
//绘制窗体中间的文字
Font font = new Font(Font.FontFamily, 12, FontStyle.Bold);
int numx = (int)g.MeasureString(Text, font).Width;
int numy = (int)g.MeasureString(Text, font).Height;
g.DrawString(Text, font, new SolidBrush(Color.FromArgb(178, 34, 34)), new PointF(Width / 2 - numx / 2, topheight / 2 - numy / 2));
// g.DrawImage(Properties.Resources.logo128, 10, 8, 16, 16);
}
catch
{
this.Invalidate();
}
}
{
try
{
Graphics g = e.Graphics;//获取绘制对象
///设置参数
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; //图片柔顺模式选择
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;//高质量
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;//再加一点
int topheight = 30;
//绘制Title标题 ----//填充区域
g.FillRectangle(new SolidBrush(Color.FromArgb(223, 221, 216)), 0, 0, Width, topheight);
绘制标题
int numw = (int)g.MeasureString("新建窗体", Font).Width;
int numh = (int)g.MeasureString("新建窗体", Font).Height;
g.DrawString("新建窗体", Font, new SolidBrush(Color.FromArgb(100, 99, 94)), new PointF(topheight, topheight / 2 - numh / 2));
//绘制窗体中间的文字
Font font = new Font(Font.FontFamily, 12, FontStyle.Bold);
int numx = (int)g.MeasureString(Text, font).Width;
int numy = (int)g.MeasureString(Text, font).Height;
g.DrawString(Text, font, new SolidBrush(Color.FromArgb(178, 34, 34)), new PointF(Width / 2 - numx / 2, topheight / 2 - numy / 2));
// g.DrawImage(Properties.Resources.logo128, 10, 8, 16, 16);
}
catch
{
this.Invalidate();
}
}