此函数在窗体上的任意位置沿水平方向绘制矩形。 我该如何编辑该函数,以便它可以在水平和垂直方向上绘制矩形?
int x, y;
int width=100,height=25;
Color color;
public strip()
{
Random rand = new Random();
x = rand.Next(50,500);
y = rand.Next(50,300);
color = Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255), rand.Next(255));
}
internal void Draw(Graphics G)
{
SolidBrush brush = new SolidBrush(color);
G.FillRectangle(brush, x, y, width, height);
G.DrawRectangle(Pens.Black, x, y, width, height);
}