c#参数 这里是怎么传递的?
public partial class Form1 : Form{
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
shape line = new line(10, 10, 100, 100);
line.draw(this.panel1.CreateGraphics());
}
private void button1_Click(object sender, EventArgs e)
{
shape ep = new eillpse(20, 20, 200, 200);
ep.draw(this.panel1.CreateGraphics());
}
private void button2_Click(object sender, EventArgs e)
{
shape re = new eillpse(20, 20, 200, 200);
re.draw(this.panel1.CreateGraphics());
}
}
public class line :shape
{
public line(int x1, int y1, int x2, int y2)
: base(x1, y1, x2, y2)
{ }
public override void draw(Graphics g)
{
Pen mypen =new Pen (Color .Red ) ;
g.DrawLine(mypen , this.X1 , this.Y1, this.X2, this.Y2);
}
}
public class eillpse : shape
{
public eillpse(int x1, int y1, int x2, int y2)
: base(x1, y1, x2, y2)
{ }
public override void draw(Graphics g)
{
Pen mypen = new Pen(Color.Red);
g.DrawEllipse(mypen, this.X1, this.Y1, this.X2, this.Y2);
}
}
public class regricle : shape
{
public regricle(int x1, int y1, int x2, int y2)
: base(x1, y1, x2, y2)
{ }
public override void draw(Graphics g)
{
Pen mypen = new Pen(Color.Red);
g.DrawRectangle(mypen, this.X1, this.Y1, this.X2, this.Y2);
}
}