如何绘制四线方格
答案:2 悬赏:30 手机版
解决时间 2021-12-24 05:34
- 提问者网友:轻浮
- 2021-12-24 01:37
如何绘制四线方格
最佳答案
- 五星知识达人网友:神的生死簿
- 2022-01-06 05:07
四线方格?没看明白。
全部回答
- 1楼网友:鱼芗
- 2022-01-06 06:40
使用gdi+画一下就是了,很简单的!!
//模拟颜
private list colors = new list {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));
}
给你个例子吧!!明天就失效了!!
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯