PDA

View Full Version : رسم ناقص گرافیکی در picture box



zehs_sha
جمعه 20 اردیبهشت 1392, 18: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);
}

plus
جمعه 20 اردیبهشت 1392, 18:50 عصر
برای for بیرونی bracket نگذاشتین بنابراین خطی که مربوط به اضافه کردن به sumy هست (و خط بالاییش) بعد از تمون شدن حلقه بیرونی اجرا میشه، و توی این شرایط، شما یک صفحه 1x64 رسم میکنید.