110,533
社区成员
发帖
与我相关
我的任务
分享
private void drawPicture(Graphics aGraphics)
{
bool today = false;
int y = Convert.ToInt32(t.Year);
int m = Convert.ToInt32(t.Month);
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
int first = 0;
GraphicsPath firstPath = new GraphicsPath();
Point[] firstArr = new Point[4];
firstArr[0] = new Point(20, 10);
firstArr[1] = new Point(20 + with * 7, 10);
firstArr[2] = new Point(20 + with * 7, 10 + 30);
firstArr[3] = new Point(20, 10 + 30);
firstPath.AddLines(firstArr);
aGraphics.FillPath(Brushes.LightBlue, firstPath);
Point[] pntArr = new Point[4];
GraphicsPath secondPath = new GraphicsPath();
pntArr[0] = new Point(20 + with * 5, 10 + 30);
pntArr[1] = new Point(20 + with * 7, 10 + 30);
pntArr[2] = new Point(20 + with * 7, 10 + 30 + height * 6);
pntArr[3] = new Point(20 + with * 5, 10 + 30 + height * 6);
secondPath.AddLines(pntArr);
aGraphics.FillPath(Brushes.AliceBlue, secondPath);
if (count > 0)
{
first = findFirstDayCrossForwardOneMonth(ref m, ref y);
}
else if (count < 0)
{
first = findFirstDayCrossBackwardOneMonth(ref m, ref y);
}
else
{
first = findFirstDayOfCurrentMonth();
today = true;
}
drawAssignmentsOrTests(first, m, y, aGraphics); //draw assginments and tests
aGraphics.DrawString(y.ToString(), textMonth, new SolidBrush(Color.AliceBlue), new PointF(20 + with + 10, 10 + 35));//draw year
aGraphics.DrawString(getMonth(m), textMonth, new SolidBrush(Color.White), new PointF(20 + with * 6 + 10, 10 + 20), drawFormat); //draw month
drawTable(aGraphics); //draw table
drawMonth(first, getTotalDaysOfMonth(m, y), aGraphics);
if (today == true)
{
drawToday(first, aGraphics);
}
aGraphics.Dispose();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
bmp = new Bitmap(1100, 600);
Graphics g = Graphics.FromImage(bmp);
drawPicture(g);
CreateGraphics().DrawImage(bmp, 0, 0);
}
private void drawTable(Graphics g)
{
g.DrawLine(Pens.Black, new Point(20, 10), new Point(20 + with * 7, 10));
g.DrawLine(Pens.Black, new Point(20, 10 + 30), new Point(20 + with * 7, 10 + 30));
for (int i = 1; i <= 6; i++) //row
{
g.DrawLine(Pens.Black, new Point(20, 10 + 30 + height * i), new Point(20 + with * 7, 10 + 30 + height * i));
}
for (int i = 0; i < 8; i++) //column
{
g.DrawLine(Pens.Black, new Point(20 + with * i, 10), new Point(20 + with * i, 10 + 30 + height * 6));
}
for (int i = 0; i < 7; i++) //day
{
g.DrawString(day[i], head, new SolidBrush(Color.White), new PointF(20 + 20 + with * i, 15));
}
}