一个method,比如:private void DrawPawn(Graphics paper, int x, int y, Color colour)
{
int offset = (SquareSize - PieceSize) / 2;
SolidBrush brush = new SolidBrush(colour);
paper.FillPolygon(brush, new Point[].......................
paper.DrawString(.............................);
}这样一个题目本身就给了的method,能够把它用到我的code中来吗?如何操作?题目中的原话是:“画各个图形的method已经给你们了,call them with the appropriate values.” (我的疑问在于这个method没有return.....,所以不知道如何把它call进我的代码中来)?比如:
ifXXXXX
{
XXXXXXXXXXXXXXX;(我现在要在这里作出图,作图方法就是上面的那个method,请问该怎么写?)
}
{
int offset = (SquareSize - PieceSize) / 2;
SolidBrush brush = new SolidBrush(colour);
paper.FillPolygon(brush, new Point[].......................
paper.DrawString(.............................);
}这样一个题目本身就给了的method,能够把它用到我的code中来吗?如何操作?题目中的原话是:“画各个图形的method已经给你们了,call them with the appropriate values.” (我的疑问在于这个method没有return.....,所以不知道如何把它call进我的代码中来)?比如:
ifXXXXX
{
XXXXXXXXXXXXXXX;(我现在要在这里作出图,作图方法就是上面的那个method,请问该怎么写?)
}
Graphics paper = new Graphics();
DrawPawn(paper,x,y,Color.Black);
{
DrawPawn(paper, x, y, colour);(我现在要在这里作出图,作图方法就是上面的那个method,请问该怎么写?)
}
DrawPawn(paper,100,100,System.Drawing.Color.Black);
试试这样
天哪,你能不能试一下,闭着眼睛瞎说!
谁告诉你能这样创建 Graphics 对象?
Graphics paper = new Graphics();
许多事件的参数里就带有Graphics对象//从Paint 事件的 PaintEventArgs 中获取对 Graphics 对象的引用
private void Form1_Paint(object sender,
System.Windows.Forms.PaintEventArgs pe)
{
Graphics g = pe.Graphics;
// Insert code to paint the form here.
}//当然也可以自己创建对象
System.Drawing.Graphics paper=g = this.CreateGraphics();//从控件或窗体创建实例Graphics g = Graphics.FromImage(myBitmap);//从 Image 对象创建