📄 tubiao.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
public partial class tubiao : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.CreateImage();
}
private void CreateImage()
{
Count cou = new Count();
Operation oper = new Operation();
if (oper.count(cou))
{
int All = cou.All;//参加服务调查的总人数
int Good = cou.Good;//满意人数
int Bad = cou.Bad;//不满意人数
int Common = cou.Common;//感觉一般人数
int width = 330, height = 285;
Bitmap bitmap = new Bitmap(width, height);
Graphics g = Graphics.FromImage(bitmap);
try
{
//清空背景色
g.Clear(Color.White);
Pen pen1 = new Pen(Color.Red);
Brush brush1 = new SolidBrush(Color.White);
Brush brush2 = new SolidBrush(Color.Blue);
Brush brush3 = new SolidBrush(Color.Brown);
Brush brush4 = new SolidBrush(Color.Green);
Brush brush5 = new SolidBrush(Color.CornflowerBlue);
Font font1 = new Font("Courier New", 12, FontStyle.Bold);
Font font2 = new Font("Courier New", 8);
g.FillRectangle(brush1, 0, 0, width, height); //绘制背景图
g.DrawString("服务调查示意图", font1, brush5, new Point(90, 20)); //书写标题
int piex = 80, piey = 50, piew = 150, pieh = 150;
float angle1 = Convert.ToSingle((360 /Convert.ToSingle(All)) * Convert.ToSingle(Good)); //满意人数在圆中分配的角度
float angle2 = Convert.ToSingle((360 / Convert.ToSingle(All)) * Convert.ToSingle(Bad));//不满意人数在圆中分配的角度
float angle3 = Convert.ToSingle((360 / Convert.ToSingle(All)) * Convert.ToSingle(Common));//感觉一般人数在圆中分配的角度
g.FillPie(brush2, piex, piey, piew, pieh, 0, angle1); ///满意人数所占比例
g.FillPie(brush3, piex, piey, piew, pieh, angle1, angle2); //不满意人数所占比例
g.FillPie(brush4, piex, piey, piew, pieh, angle1 + angle2, angle3); //感觉一般人数所占比例
//绘制标识
g.DrawRectangle(pen1, 50, 210, 230, 70); //绘制范围框
g.FillRectangle(brush2, 60, 220, 20, 10); //绘制小矩形
g.DrawString("满意总人数比例:" + Convert.ToSingle(Good) * 100 / Convert.ToSingle(All) + "%", font2, brush2, 90, 220);
g.FillRectangle(brush3, 60, 240, 20, 10);
g.DrawString("不满意总人数比例:" + Convert.ToSingle(Bad) * 100 / Convert.ToSingle(All) + "%", font2, brush3, 90, 240);
g.FillRectangle(brush4, 60, 260, 20, 10);
g.DrawString("感觉一般总人数比例:" + Convert.ToSingle(Common) * 100 / Convert.ToSingle(All) + "%", font2, brush4, 90, 260);
}
catch (Exception md)
{
Response.Write(md.Message);
}
System.IO.MemoryStream ms = new System.IO.MemoryStream();
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
Response.ClearContent();
Response.ContentType = "image/Jpeg";
Response.BinaryWrite(ms.ToArray());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -