1 private void panel1_Paint(object sender, PaintEventArgs e)
2 {
3 ArrayList dataArrayList = new PlwData_dao().queryPlwDataByDateRange("2014-07-07", "2014-07-24");
4 int start_x = 40;
5 int start_y = 10;
6 int line_height = 25;
7 int table_width = 810;
8 int lineCount = 3 + dataArrayList.Count;
9 int table_height = line_height * lineCount;
10 int fontSize = 12;
11 string[] titles = new string[] { "期号","日期","万位","千位","百位","十位","个位" };
12 Color[] colors = new Color[] { Color.FromArgb(183,0,209),Color.FromArgb(64,48,6),Color.FromArgb(235,116,10),Color.FromArgb(102,24,0),Color.FromArgb(183,30,28) };
13 int[] indexs = new int[] { 2,3,4,5,6,1,0,9,8,7 };
14
15 Graphics g = e.Graphics;
16 Pen pen = new Pen(Color.Blue, 2);
17 g.DrawRectangle(pen, start_x, start_y, table_width, table_height);//画外轮廓
18 pen = new Pen(Color.Gray, 1);
19 for (int i = 0; i < lineCount; i++)
20 {
21 //画行线
22 g.DrawLine(pen, start_x, start_y + (table_height / lineCount) * i, start_x + table_width, start_y + (table_height / lineCount) * i);
23 }
24 for (int i = 0; i < 7; i++)
25 {
26 //画大列线
27 g.DrawLine(pen, start_x + (table_width / 7) * i, start_y, start_x + (table_width / 7) * i, start_y + table_height);
28 if (i > 1)
29 {
30 for (int j = 0; j < 5; j++)
31 {
32 //画小列线
33 pen = new Pen(Color.Gray, 1);
34 g.DrawLine(pen, start_x + (table_width / 7) * i + (table_width / 7 / 5) * j, start_y + (table_height / lineCount), start_x + (table_width / 7) * i + (table_width / 7 / 5) * j, start_y + table_height);
35 pen = new Pen(Color.Gray, 2);
36 }
37 }
38 }
39 Brush brush = new SolidBrush(Color.Black);
40 Font font = new Font("宋体", fontSize);
41 for (int i = 0; i < titles.Length; i++)
42 {
43 //画标题
44 g.DrawString(titles[i], font, brush, new Point(start_x + (table_width / 7 * i + ((table_width / 7) - fontSize * titles[i].Length) / 2), start_y + ((table_height / lineCount) - fontSize) / 2));
45 }
46 for (int i = 0; i < indexs.Length; i++)
47 {
48 //画数字标识
49 for (int j = 2; j < 7; j++)
50 {
51 g.DrawString(indexs[i] + "", font, brush, new Point(start_x + (table_width / 7) * j + table_width / 7 / 5 * (i % 5) + (table_width / 7 / 5 - fontSize) / 2, start_y + int.Parse((Math.Ceiling((i + 1.00) / 5) * (table_height / lineCount)) + "") + (table_height / lineCount - fontSize) / 2));
52 }
53 }
54 int[] positionArr_x = new int[5];
55 int[] positionArr_y = new int[5];
56 int nowLine = 0;
57 foreach (PLW_model plw_model in dataArrayList)
58 {
59 //开始画数据
60 brush = new SolidBrush(Color.Black);
61 g.DrawString(plw_model.getTerm(), font, brush, new Point(start_x + (table_width / 7 - fontSize * plw_model.getTerm().Length) / 3 * 2, start_y + table_height / lineCount * (nowLine + 3) + (table_height / lineCount - fontSize) / 2));
62 g.DrawString(plw_model.getDate(), font, brush, new Point(start_x + table_width / 7 + (table_width / 7 - (fontSize * plw_model.getDate().Length) / 3 * 2) / 2, start_y + table_height / lineCount * (nowLine + 3) + (table_height / lineCount - fontSize) / 2));
63 string lotteryNumber = plw_model.getLotteryNumber();
64 for (int j = 0; j < lotteryNumber.Length; j++)
65 {
66 int lotteryNumberItem = int.Parse(lotteryNumber.Substring(j, 1));
67 int position_x = start_x + (int.Parse(NumberDeal.dealNumber_C(lotteryNumberItem + "")) - indexs[0]) * table_width / 7 / 5 + table_width / 7 * (2 + j) + (table_width / 7 / 5 - fontSize) / 2;
68 int position_y = start_y + (3 + nowLine) * (table_height / lineCount) + (table_height / lineCount - fontSize) / 2;
69 brush = new SolidBrush(colors[j]);
70 pen = new Pen(Color.FromArgb(100, 255, 0, 0), 2);
71 Rectangle rec = new Rectangle(position_x - 3, position_y - 3, fontSize + 8, fontSize + 8);
72 g.FillEllipse(brush, rec);
73 int lineEnd_x = start_x + (int.Parse(NumberDeal.dealNumber_C(lotteryNumberItem + "")) - indexs[0]) * table_width / 7 / 5 + table_width / 7 * (2 + j) + table_width / 7 / 5 / 2;
74 int lineEnd_y = start_y + (3 + nowLine) * (table_height / lineCount) + (table_height / lineCount) / 2;
75 if (nowLine > 0)
76 {
77 //画连线
78 g.DrawLine(pen, positionArr_x[j], positionArr_y[j], lineEnd_x, lineEnd_y);
79 }
80 positionArr_x[j] = lineEnd_x;
81 positionArr_y[j] = lineEnd_y;
82 brush = new SolidBrush(Color.White);
83 g.DrawString(lotteryNumberItem + "", font, brush, new Point(position_x, position_y));
84 }
85 nowLine++;
86 }