日期:2014-05-18 浏览次数:20993 次
private void NowPaint1() { Rectangle rec = new Rectangle(0, 0, panel1.Width, panel1.Height); GraphicsPath round = CreateRound(rec, 10 * 2); Graphics gp = panel1.CreateGraphics(); Brush b = new LinearGradientBrush(rec, Color.Blue, Color.Red, LinearGradientMode.Vertical); gp.FillPath(b, round); Image im = panel1.BackgroundImage; if (im != null) gp.DrawImage(im, new Point(0, 0)); } private void NowPaint2() { //在这里如何清空已经绘制的图 panel1.BackColor = Color.Transparent; } private GraphicsPath CreateRound(Rectangle rect, int radius) //画圆角 { GraphicsPath roundRect = new GraphicsPath(); roundRect.AddArc(rect.Right - radius, rect.Top, radius, radius, 270, 90);//右上角 roundRect.AddArc(rect.Right - 1 - radius, rect.Bottom - 1 - radius, radius, radius, 0, 90);//右下角 roundRect.AddArc(rect.Left - 1, rect.Bottom - 1 - radius, radius, radius, 90, 90);//左下角 roundRect.AddArc(rect.Left, rect.Top, radius, radius, 180, 90);//左上角 return roundRect; }