当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > Asp.Net 使用 GDI+ 绘制3D饼图入门篇源码

ASP.NET
谈谈ASP.net2.0中App_GlobalResources的用途
.Net Framework 4.0 功能介绍
ASP.NET教程:浅谈Asp.net实现的邮件发送引擎
ASP.NET教程:绝对路径与相对路径的拼合方法
ASP.NET开发电子商务网站学习经验
ASP.NET与PHP构建web程序的方法的优缺点
ASp.NET教程:页面传值的五种方法
ASP.NET教程:数据缓存和输出缓存
ASP.NET比拼PHP的测试环境
ASP.NET MVC 2的客户端验证扩展
ASP.NET实例:无刷新的文件上传
ASP.NET实例: GridView删除时弹出确认对话框
ASP.NET获取不到js写的cookie解决方法
ASP.NET MVC教程:数据库表的增删改
ASP.NET教程:form验证用户登录的Cookie
如何让.NET程序脱离.NET框架
ASP.NET开发网站程序常见错误汇总
C#教程:匿名类型和隐式类型变量的区别
C#3.0教程:自动属性和扩展方法
使用XmlDocument读取XML节点所有数据

ASP.NET 中的 Asp.Net 使用 GDI+ 绘制3D饼图入门篇源码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 150 ::
收藏到网摘: n/a

topn3dpie.aspx
------------------
<%@Pagelanguage="c#"CodeBehind="topn3dpie.aspx.cs"AutoEventWireup="false"Inherits="Yeefly.topn3dpie"%>

topn3dpie.aspx.cs
-----------------
usingSystem;
usingSystem.Collections;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Web;
usingSystem.Web.SessionState;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.HtmlControls;
usingSystem.Drawing.Imaging;
usingSystem.Drawing.Drawing2D;
usingSystem.IO;

namespaceYeefly
{
///<summary>
///Graph的摘要说明。
///</summary>
publicclasstopn3dpie:System.Web.UI.Page
{
privatevoidPage_Load(objectsender,System.EventArgse)
{
Response.ContentType="image/jpeg";
constintwidth=300,height=300;
intx=30,y=50;

intpieWidth=120,pieHeight=40,pieShadow=15;
int[]arrVote={70,90,80,20,60,40};
RandomoRan=newRandom();

BitmapobjBitmap=newBitmap(width,height);
GraphicsobjGraphics=Graphics.FromImage(objBitmap);
objGraphics.DrawRectangle(newPen(Color.Black),0,0,width,height);
objGraphics.FillRectangle(newSolidBrush(Color.White),1,1,width-2,height-2);
SolidBrushobjBrush=newSolidBrush(Color.Blue);
objGraphics.SmoothingMode=SmoothingMode.AntiAlias;

intiCurrentPos=0;

Color[]arrColor={Color.Red,Color.Red,Color.Red,Color.Red,Color.Red,Color.Red};

for(inti=arrVote.Length-1;i>=0;i--)
{
arrColor[i]=Color.FromArgb(oRan.Next(255),oRan.Next(255),oRan.Next(255));
}

for(inti=arrVote.Length-1;i>=0;i--)
{
objBrush.Color=arrColor[i];
for(intiLoop2=0;iLoop2<pieShadow;iLoop2++)
objGraphics.FillPie(newHatchBrush(HatchStyle.Percent50,objBrush.Color),x,y+iLoop2,pieWidth,pieHeight,iCurrentPos,arrVote[i]);
iCurrentPos+=arrVote[i];
}

iCurrentPos=0;
for(inti=arrVote.Length-1;i>=0;i--)
{
objBrush.Color=arrColor[i];
objGraphics.FillPie(objBrush,x,y,pieWidth,pieHeight,iCurrentPos,arrVote[i]);
iCurrentPos+=arrVote[i];
}

objBitmap.Save(Response.OutputStream,ImageFormat.Jpeg);
//cleanup...
objGraphics.Dispose();
objBitmap.Dispose();
}

#regionWeb窗体设计器生成的代码
overrideprotectedvoidOnInit(EventArgse)
{
//
//CODEGEN:该调用是ASP.NETWeb窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

///<summary>
///设计器支持所需的方法-不要使用代码编辑器修改
///此方法的内容。
///</summary>
privatevoidInitializeComponent()
{
this.Load+=newSystem.EventHandler(this.Page_Load);
}
#endregion
}
}