private void Panel2All(Graphics _g) { Graphics g = _g; Pen pen = new Pen(Color.Black); #region 画内容格子 intX = 0; intY = 0; GDIRectangle gdirectangle = new GDIRectangle(); pen.Width = 1.5f; pen.Color = Color.FromArgb(128, 128, 128); gdirectangle.First = new Point(0, 0); gdirectangle.Rec = new Rectangle(0, 0, intWidth * 12 + 23, intHeight * 8 + 23); gdirectangle.g = g;//必须放在画笔之后?? gdirectangle.pen = pen; gdirectangle.DrawRec(); pen.Color = Color.Black; for (int i = 0; i < 96; i++) { if (i % 12 == 0 && i == 0) { gdirectangle = new GDIRectangle(); gdirectangle.Id = i; gdirectangle.g = g; gdirectangle.pen = pen; gdirectangle.FillRec = new Rectangle(intX + 4, intY + 4, intWidth - 8, intHeight - 8); gdirectangle.FillDrawRec(); gdirectangle.Rec = new Rectangle(intX + 2, intY + 2, (intWidth * 12 + 22) / 12 - 5, (intHeight * 8 + 22) / 8 - 5); gdirectangle.DrawRec(); intX += intWidth + 2; lstGdiRectangle.Add(gdirectangle); } else { if (i % 12 == 0) { intX = 0; intY += intHeight + 3; } gdirectangle = new GDIRectangle(); gdirectangle.g = g; gdirectangle.pen = pen; gdirectangle.Id = i; gdirectangle.FillRec = new Rectangle(intX + 4, intY + 4, intWidth - 8, intHeight - 8); gdirectangle.FillDrawRec(); gdirectangle.Rec = new Rectangle(intX + 2, intY + 2, (intWidth * 12 + 22) / 12 - 5, (intHeight * 8 + 22) / 8 - 5); gdirectangle.DrawRec(); intX += intWidth + 2; lstGdiRectangle.Add(gdirectangle); } #endregion } }
private void All(Graphics _g) { using (Graphics g = _g) { Pen pen = new Pen(Color.Black); pen.Width = 2; #region 画列头 Rectangle Rec = new Rectangle(2, 2, 30, 15); g.DrawEllipse(pen, Rec); int num = 1; for (int i = 0; i < 12; i++) { //Label labColumnHead = new Label(); //labColumnHead.AutoSize = false; //labColumnHead.TextAlign = ContentAlignment.MiddleCenter; //labColumnHead.Text = num.ToString(); intX += intSpacing + intWidth; //labColumnHead.Location = new Point(intX, intY); //labColumnHead.Width = intWidth; //labColumnHead.Height = intHeight; //labColumnHead.BackColor = Color.Transparent; //panel1.Controls.Add(labColumnHead); Rec = new Rectangle(intX, intY, 40, 25); g.DrawRectangle(pen, Rec); Font myFont = new Font("宋体", 12, FontStyle.Bold); Brush bush = new SolidBrush(Color.Black);//填充的颜色 g.DrawString(num.ToString(), myFont, bush, intX + 8, intY + 3); num++; } #endregion #region 画行头 for (int j = 0; j < 8; j++) { intX = 0 + intSpacing;//初始化X intY += intHeight + intSpacing; Rec = new Rectangle(intX, intY, 40, 25); g.DrawRectangle(pen, Rec); Font myFont = new Font("宋体", 12, FontStyle.Bold); Brush bush = new SolidBrush(Color.Black);//填充的颜色 g.DrawString(character[j].ToString(), myFont, bush, intX + 5, intY + 3); } #endregion #region 画内容格子 intX = intWidth; intY = intHeight; GDIRectangle gdirectangle = new GDIRectangle(); pen.Width = 1.5f; pen.Color = Color.FromArgb(128, 128, 128); gdirectangle.First = new Point(intX, intY); gdirectangle.Rec = new Rectangle(intX, intY, intWidth * 12 + 23, intHeight * 8 + 23); gdirectangle.g = g;//必须放在画笔之后?? gdirectangle.pen = pen; gdirectangle.DrawRec(); //intX = intWidth; //intY = intHeight; //pen.Width = 1.5f; //pen.Color = Color.FromArgb(128, 128, 128); //Rec = new Rectangle(intX, intY, intWidth * 12 + 23, intHeight * 8 + 23); //g.DrawRectangle(pen, Rec); pen.Color = Color.Black; for (int i = 0; i < 96; i++) { if (i % 12 == 0 && i == 0) { gdirectangle = new GDIRectangle(); gdirectangle.Id = i; gdirectangle.g = g; gdirectangle.pen = pen; gdirectangle.FillRec = new Rectangle(intX + 4, intY + 4, intWidth - 8, intHeight - 8); gdirectangle.FillDrawRec(); gdirectangle.Rec = new Rectangle(intX + 2, intY + 2, (intWidth * 12 + 22) / 12 - 5, (intHeight * 8 + 22) / 8 - 5); gdirectangle.DrawRec(); //Rec = new Rectangle(intX + 2, intY + 2, (intWidth * 12 + 22) / 12 - 5, (intHeight * 8 + 22) / 8 - 5); //g.DrawRectangle(pen, Rec); //Rec = new Rectangle(intX + 4, intY + 4, intWidth - 8, intHeight - 8); //g.FillRectangle(new SolidBrush(Color.White), Rec); intX += intWidth + 2; lstGdiRectangle.Add(gdirectangle); } else { if (i % 12 == 0) { intX = intWidth; intY += intHeight + 3; } gdirectangle = new GDIRectangle(); gdirectangle.g = g; gdirectangle.pen = pen; gdirectangle.Id = i; gdirectangle.FillRec = new Rectangle(intX + 4, intY + 4, intWidth - 8, intHeight - 8); gdirectangle.FillDrawRec(); gdirectangle.Rec = new Rectangle(intX + 2, intY + 2, (intWidth * 12 + 22) / 12 - 5, (intHeight * 8 + 22) / 8 - 5); gdirectangle.DrawRec(); //Rec = new Rectangle(intX + 2, intY + 2, (intWidth * 12 + 22) / 12 - 5, (intHeight * 8 + 22) / 8 - 5); //g.DrawRectangle(pen, Rec); //Rec = new Rectangle(intX + 4, intY + 4, intWidth - 8, intHeight - 8); //g.FillRectangle(new SolidBrush(Color.White), Rec); intX += intWidth + 2; lstGdiRectangle.Add(gdirectangle); } } #endregion g.Dispose(); } }