使用GDI+画一下就是了,很简单的!!
//模拟颜
private List<Color> colors = new List<Color> {Color.Blue, Color.Black,Color.White };
protected const int xNum = 10;
protected const int yNum = 10;
protected int cxBlock = 60, cyBlock = 40;
protected bool[,] abChecked = new bool[yNum, xNum];
protected int[,] abCheckedColor = new int[yNum, xNum];
//窗体的绘制事件
private void Form1_Paint(object sender, PaintEventArgs e)
{
try
{
Graphics g = e.Graphics;
Pen pen = new Pen(Color.FromArgb(0, 0, 0));
for (int y = 0; y < yNum; y++)
for (int x = 0; x < xNum; x++)
{
g.FillRectangle(new SolidBrush(colors[abCheckedColor[y, x]]),x * cxBlock, y * cyBlock, cxBlock, cyBlock);
g.DrawRectangle(pen, x * cxBlock, y * cyBlock, cxBlock, cyBlock);
abCheckedColor[y, x] = abCheckedColor[y, x] + 1 > 2 ? 0 : abCheckedColor[y, x] + 1;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
//窗体的鼠标释放事件
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
int x = e.X / cxBlock;
int y = e.Y / cyBlock;
Invalidate(new Rectangle(x * cxBlock, y * cyBlock, cxBlock, cyBlock));
}
给你个例子吧!!明天就失效了!!
就是这样,虽然不是很懂,我先看看吧,谢谢