初学c#做了个五子棋,其他位置都可以正常落子,但是如图第一行第一列下不了棋,一时看不出如何修改,棋盘是600×600的,特来请教各位大佬
绘制部分主要代码如下
/// <summary>绘制图像</summary>
private void PictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
for (int i = 0; i <= grid.GetUpperBound(0); i++)
{
for (int j = 0; j <= grid.GetUpperBound(1); j++)
{
if (grid[i, j] != DotColor.None)
{
if (grid[i, j] == DotColor.Black)
{
g.DrawImage(blackBitmap, (i+1)* 40, (j+1) * 40);
}
else
{
g.DrawImage(whiteBitmap, (i+1)* 40,(j+1) * 40);
}
}
}
}
}
/// <summary>在pictureBox1中按下鼠标触发的事件</summary>
private void PictureBox1_MouseDown(object sender, MouseEventArgs e)
{
int x = e.X / 40;
int y = e.Y / 40;
int color = -1;
if (!(x < 1 || x > 15 || y < 1 || y > 15))
{
if (grid[x-1 , y -1] == DotColor.None)
{
// int color = (int)grid[x - 1, y - 1];
if (side == 0)
{
color = 0;
}
if (side == 1)
{
color = 1;
}
//发送格式:UnsetDot,桌号,座位号,行,列,颜色
service.SendToServer(string.Format(
"UnsetDot,{0},{1},{2},{3},{4}", tableIndex, side, x - 1, y - 1, color));
}
}
}