public static int iGeShu = 5;
public static int iLeiXing = 2;
private static string sWenBen = "天上星河转人间帘幕垂凉生枕簟泪痕滋起解罗衣聊问夜何";
struct UserSheet
{
public bool visbile;
public int index;
public string str;
public Rectangle rect;
public int x()
{ return rect.X; }
public int y()
{ return rect.Y; }
public int width()
{ return rect.Width; }
public int height()
{ return rect.Height; }
}
private UserSheet[,] mySheet = new UserSheet[10, 10];
private const int iSheetsWidth = 540;
private int iSheetWidth = iSheetsWidth / iGeShu;
private int iSheetLeft = 240;
private int iSheetTop = 100;
private int fontSize = 300 / iGeShu;
private void UserControlZhuYiRun_Paint(object sender, PaintEventArgs e)
{
if (iGeShu != 0)
{
Graphics graphics = e.Graphics; for( int i = 0; i <= iGeShu; i++)
{
graphics.DrawLine(new Pen(Color.Black, 2), new Point(iSheetLeft, i * iSheetWidth + iSheetTop), new Point(iSheetLeft + iSheetsWidth, i * iSheetWidth + iSheetTop));
graphics.DrawLine(new Pen(Color.Black, 2), new Point(i * iSheetWidth + iSheetLeft, iSheetTop), new Point(i * iSheetWidth + iSheetLeft, iSheetTop + iSheetsWidth));
} for (int i = 0; i < iGeShu; i++)
for (int j = 0; j < iGeShu; j++)
if (mySheet[i, j].visbile)
graphics.FillRectangle(new SolidBrush(Color.Black), mySheet[i, j].rect); Font drawFont = new Font("Arial", fontSize);
StringFormat drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Center;
RectangleF drawRect;
for (int i = 0; i < iGeShu; i++)
{
for (int j = 0; j < iGeShu; j++)
{
drawRect = new RectangleF(mySheet[i, j].x(), mySheet[i, j].y() + (mySheet[i, j].height() - drawFont.Height) / 2, mySheet[i, j].width(), mySheet[i, j].height());
graphics.DrawString(mySheet[i, j].str, drawFont, new SolidBrush(Color.Beige), drawRect, drawFormat);
}
}
}
private void UserControlZhuYiRun_MouseDown(object sender, MouseEventArgs e)
{
mySheet[(e.X - iSheetLeft) / iSheetWidth, (e.Y - iSheetWidth) / iSheetWidth].visbile = true;
this.Refresh();
}
public static int iLeiXing = 2;
private static string sWenBen = "天上星河转人间帘幕垂凉生枕簟泪痕滋起解罗衣聊问夜何";
struct UserSheet
{
public bool visbile;
public int index;
public string str;
public Rectangle rect;
public int x()
{ return rect.X; }
public int y()
{ return rect.Y; }
public int width()
{ return rect.Width; }
public int height()
{ return rect.Height; }
}
private UserSheet[,] mySheet = new UserSheet[10, 10];
private const int iSheetsWidth = 540;
private int iSheetWidth = iSheetsWidth / iGeShu;
private int iSheetLeft = 240;
private int iSheetTop = 100;
private int fontSize = 300 / iGeShu;
private void UserControlZhuYiRun_Paint(object sender, PaintEventArgs e)
{
if (iGeShu != 0)
{
Graphics graphics = e.Graphics; for( int i = 0; i <= iGeShu; i++)
{
graphics.DrawLine(new Pen(Color.Black, 2), new Point(iSheetLeft, i * iSheetWidth + iSheetTop), new Point(iSheetLeft + iSheetsWidth, i * iSheetWidth + iSheetTop));
graphics.DrawLine(new Pen(Color.Black, 2), new Point(i * iSheetWidth + iSheetLeft, iSheetTop), new Point(i * iSheetWidth + iSheetLeft, iSheetTop + iSheetsWidth));
} for (int i = 0; i < iGeShu; i++)
for (int j = 0; j < iGeShu; j++)
if (mySheet[i, j].visbile)
graphics.FillRectangle(new SolidBrush(Color.Black), mySheet[i, j].rect); Font drawFont = new Font("Arial", fontSize);
StringFormat drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Center;
RectangleF drawRect;
for (int i = 0; i < iGeShu; i++)
{
for (int j = 0; j < iGeShu; j++)
{
drawRect = new RectangleF(mySheet[i, j].x(), mySheet[i, j].y() + (mySheet[i, j].height() - drawFont.Height) / 2, mySheet[i, j].width(), mySheet[i, j].height());
graphics.DrawString(mySheet[i, j].str, drawFont, new SolidBrush(Color.Beige), drawRect, drawFormat);
}
}
}
private void UserControlZhuYiRun_MouseDown(object sender, MouseEventArgs e)
{
mySheet[(e.X - iSheetLeft) / iSheetWidth, (e.Y - iSheetWidth) / iSheetWidth].visbile = true;
this.Refresh();
}
解决方案 »
- 狂甩分了,指教即给分!Mapx+C#连数据库的问题
- 跪求:中英版网站web.config问题~~
- 顶者有分, PDA手机软件开发中,GPS 里面的跟踪数是指什么, 怎么读取, 给资料的,当然也有分啦
- Microsoft .NET Framework 3.0 正式版发布!
- 哪位有c#的视频呀,能不能发一份上来!谢谢最好是.net 2005的
- 安装程序中的CD-KEY如何验证
- 如何設定 Socket 超時 (Timeout)?
- 这样的代码结构!可取吗?请指点!
- Bitmap问题,急!百分赠送!!!
- 两个.net软件安装的问题
- 用c# 画gif格式的图片
- 请教高手关于C#使用MySql.Data.Dll 进行Mysql跨服查询语句怎么写?!
UserControlZhuYiRun_Paint时间是哪个控件触发的?我所用过的控件中,只有PictureBox返回的Graphics绘图不会闪,别的都会闪,因为PictureBox内置了双缓冲处理图形
GDI+:ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_fxmclignrl/html/a98a76ab-e455-49c9-891c-0491ac932f2c.htm
双缓冲:ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_fxmclignrl/html/dc484e33-7101-4e4b-ada5-d3c96155fbcd.htm
Invalidate方法