这个界面是怎么做的呢?很多初学者可能比较头疼,用第三方控件有时是很难做成自已想要的效果的,而且有些控件是通过拦截系统消息更改实现的,这样方法虽然用起来简单,但很耗系统资源,建议不要用。
void form_Paint(
object sender, PaintEventArgs e)
{
if (backgroundpic ==
null)
{
bodybrush =
new LinearGradientBrush(
new Rectangle(
0,
0, form.Width, form.Height), backGroundColorA, backGroundColorB, LinearGradientMode.Vertical);
e.Graphics.FillPath(bodybrush, CreateRoundedRectanglePath(new Rectangle(
0,
0, form.Width, form.Height), cornerSiz, CornerPostionType.Body));
//画底色
}
else
{
// e.Graphics.DrawImage(backgroundpic, new Rectangle(0, 0, form.ClientSize.Width, form.ClientSize.Height), 0, 0, backgroundpic.Width, backgroundpic.Height, GraphicsUnit.Pixel);
e.Graphics.DrawImage(backgroundpic,
new Rectangle(
0,
0, form.ClientSize.Width, form.ClientSize.Height),
0,
0, form.ClientSize.Width, form.ClientSize.Height, GraphicsUnit.Pixel, BackGroundImageAttributes);
// e.Graphics.DrawImage(backgroundpic, new Rectangle(0, 0, form.ClientSize.Width, form.ClientSize.Height), 0, 0, backgroundpic.Width, backgroundpic.Height, GraphicsUnit.Pixel, BackGroundImageAttributes);
}
captionBrush =
new LinearGradientBrush(
new Rectangle(
0,
0, e.ClipRectangle.Width, captionTopHeight), Color.FromArgb(captionTopAlpha, Color.White), Color.FromArgb(captionCenterAlpha, Color.White), LinearGradientMode.Vertical);
e.Graphics.FillPath(captionBrush, CreateRoundedRectanglePath(new Rectangle(
0,
0, form.ClientSize.Width, captionTopHeight), cornerSiz, CornerPostionType.Top));
//画标题栏
captionBrush2 =
new LinearGradientBrush(
new Rectangle(
0, captionTopHeight -
1, e.ClipRectangle.Width, captionBottomHeight+
1), Color.FromArgb(captionCenterAlpha, Color.White), Color.FromArgb(captionBottomAlpha, Color.White), LinearGradientMode.Vertical);
e.Graphics.FillRectangle(captionBrush2, new Rectangle(
0, captionTopHeight, form.ClientSize.Width, captionBottomHeight));
//画标题栏
/////////
PaintBackgroundStyle(e);
}