zehs_sha
جمعه 20 اردیبهشت 1392, 19:40 عصر
قطعه کد زیر باید یک صفحه کامل شطرنج رسم کنه اما فقط سطر اول نمایش داده می شود ؟ اشکال کد کجاست ؟
void addBackGround()
{
PictureBox pictureBox3 = new PictureBox();
pictureBox3.Width = 700;
pictureBox3.Height = 700;
pictureBox3.Location = new Point( 100, 40);
Bitmap image = new Bitmap(pictureBox3.Width, pictureBox3.Height);
SolidBrush brush = new SolidBrush(Color.Empty);
int sumx = 0;
int sumy = 0;
using (Graphics args = Graphics.FromImage(image))
{
for (int i = 1; i <= chessStruct.col; i++)
for (int j = 1; j <= chessStruct.row; j++)
{
if ((i + j) % 2 == 0)
{
brush = new SolidBrush(Color.Empty);
brush.Color = Color.FromArgb(255, 255, 255);
args.DrawRectangle(new Pen(Color.Black, 5), new Rectangle(sumx, sumy, chessStruct.weight, chessStruct.weight));
args.FillRectangle(brush, sumx, sumy, chessStruct.weight, chessStruct.weight);
}
else
{
brush = new SolidBrush(Color.Empty);
brush.Color = Color.FromArgb(0, 0, 0);
args.DrawRectangle(new Pen(Color.White, 5), new Rectangle(sumx, sumy, chessStruct.weight, chessStruct.weight));
args.FillRectangle(brush, sumx, sumy, chessStruct.weight, chessStruct.weight);
}
sumx += chessStruct.weight;
}
sumx = 0;
sumy += chessStruct.weight;
}
pictureBox3.Image = image;
pictureBox3.Update();
this.Controls.Add(pictureBox3);
}
void addBackGround()
{
PictureBox pictureBox3 = new PictureBox();
pictureBox3.Width = 700;
pictureBox3.Height = 700;
pictureBox3.Location = new Point( 100, 40);
Bitmap image = new Bitmap(pictureBox3.Width, pictureBox3.Height);
SolidBrush brush = new SolidBrush(Color.Empty);
int sumx = 0;
int sumy = 0;
using (Graphics args = Graphics.FromImage(image))
{
for (int i = 1; i <= chessStruct.col; i++)
for (int j = 1; j <= chessStruct.row; j++)
{
if ((i + j) % 2 == 0)
{
brush = new SolidBrush(Color.Empty);
brush.Color = Color.FromArgb(255, 255, 255);
args.DrawRectangle(new Pen(Color.Black, 5), new Rectangle(sumx, sumy, chessStruct.weight, chessStruct.weight));
args.FillRectangle(brush, sumx, sumy, chessStruct.weight, chessStruct.weight);
}
else
{
brush = new SolidBrush(Color.Empty);
brush.Color = Color.FromArgb(0, 0, 0);
args.DrawRectangle(new Pen(Color.White, 5), new Rectangle(sumx, sumy, chessStruct.weight, chessStruct.weight));
args.FillRectangle(brush, sumx, sumy, chessStruct.weight, chessStruct.weight);
}
sumx += chessStruct.weight;
}
sumx = 0;
sumy += chessStruct.weight;
}
pictureBox3.Image = image;
pictureBox3.Update();
this.Controls.Add(pictureBox3);
}