private void label_Paint(object sender, PaintEventArgs e)
{
DrawRoundRect(e.Graphics, label);//这里出现问题 e.graphics 不能用
}
private void DrawRoundRect(Graphics graphics, Label label)
{
float X = float.Parse(label.Width.ToString()) - 1;
float Y = float.Parse(label.Height.ToString()) - 1;
PointF[] points = {
new PointF(2, 0),
new PointF(X-2, 0),
new PointF(X-1, 1),
new PointF(X, 2),
new PointF(X, Y-2),
new PointF(X-1, Y-1),
new PointF(X-2, Y),
new PointF(2, Y),
new PointF(1, Y-1),
new PointF(0, Y-2),
new PointF(0, 2),
new PointF(1, 1)
};
GraphicsPath path = new GraphicsPath();
path.AddLines(points);//出错
Pen pen = new Pen(Color.FromArgb(150, Color.Blue), 1);
pen.DashStyle = DashStyle.Solid;
graphics.DrawPath(pen, path);//报错
}
{
DrawRoundRect(e.Graphics, label);//这里出现问题 e.graphics 不能用
}
private void DrawRoundRect(Graphics graphics, Label label)
{
float X = float.Parse(label.Width.ToString()) - 1;
float Y = float.Parse(label.Height.ToString()) - 1;
PointF[] points = {
new PointF(2, 0),
new PointF(X-2, 0),
new PointF(X-1, 1),
new PointF(X, 2),
new PointF(X, Y-2),
new PointF(X-1, Y-1),
new PointF(X-2, Y),
new PointF(2, Y),
new PointF(1, Y-1),
new PointF(0, Y-2),
new PointF(0, 2),
new PointF(1, 1)
};
GraphicsPath path = new GraphicsPath();
path.AddLines(points);//出错
Pen pen = new Pen(Color.FromArgb(150, Color.Blue), 1);
pen.DashStyle = DashStyle.Solid;
graphics.DrawPath(pen, path);//报错
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货