g.DrawRectangle(new Pen(Color.White, 400), 0, 0, img.Width, img.Height);
//定義黑色過渡型筆刷
LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.Black, Color.Black, 1.2F, true);
//定義藍色過渡型筆刷
LinearGradientBrush Bluebrush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.Blue, Color.Blue, 1.2F, true);
//繪製大標題
g.DrawString(ds.Tables[0].Rows[0]["sendid"].ToString() + "號訂單發送情況曲線圖", Bfont, brush, 40, 5);
//取得當前發送量
int nums=0;
for (int i = 0; i < count; i++)
{
nums+=Convert.ToInt32(ds.Tables[0].Rows[i]["sendnum"]);
}
//繪製資訊簡報
string info="訂單發送時間:"+ds.Tables[0].Rows[0]["sendtime"].ToString()+" 曲線圖產生時間:"+DateTime.Now.ToString()+" 訂單總量:"+Tnum.ToString()+" 當前發送總量:"+nums.ToString();
g.DrawString(info, Tfont, Bluebrush, 40, 25);
//繪製圖片邊框
g.DrawRectangle(Bp, 0, 0, img.Width - 1, img.Height - 1);
//繪製豎座標線
for (int i = 0; i < count; i++)
{
g.DrawLine(Sp, 40+20 * i, 60, 40+20 * i, 360);
}
//繪製時間軸座標標籤
for (int i = 0; i < count; i+=2)
{
string st = Convert.ToDateTime(ds.Tables[0].Rows[i]["sendtime"]).ToString("hh:mm");
g.DrawString(st, font, brush, 30 + 20 * i, 370);
}
//繪製橫座標線
for (int i = 0; i < 10; i++)
{
g.DrawLine(Sp, 40, 60+30*i, 40+20*(count-1), 60+30*i);
int s = 2500 - 50 * i * 5;
//繪製發送量軸座標標籤
g.DrawString(s.ToString(), font, brush, 10, 60 + 30 * i);
}
//繪製深度軸
g.DrawLine(Bp, 40, 55, 40, 360);
//繪製橫座標軸
g.DrawLine(Bp, 40, 360, 45 + 20 * (count - 1), 360);
//定義曲線轉折點
Point[] p = new Point[count];
for (int i = 0; i < count; i++)
{
p[i].X = 40 + 20 * i;
p[i].Y = 360- Convert.ToInt32(ds.Tables[0].Rows[i]["sendnum"]) / 5*3/5;
}
//繪製發送曲線
g.DrawLines(Rp, p);
for (int i = 0; i < count; i++)
{
//繪製發送記錄點的發送量
g.DrawString(ds.Tables[0].Rows[i]["sendnum"].ToString(), font, Bluebrush, p[i].X, p[i].Y - 10);
//繪製發送記錄點
g.DrawRectangle(Rp, p[i].X - 1, p[i].Y - 1, 2, 2);
}
//繪製豎座標標題
g.DrawString("發送量", Tfont, brush, 5, 40);
//繪製橫座標標題
g.DrawString("發送時間", Tfont, brush, 40, 385);
//儲存繪製的圖片
MemoryStream stream = new MemoryStream();
img.Save(stream, ImageFormat.Jpeg);
//圖片輸出
page.Response.Clear();
page.Response.ContentType = "image/jpeg";
page.Response.BinaryWrite(stream.ToArray());
}
}