动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   .Net → 阅读文章

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

作者来源: 
阅读 2518 人次 , 2006-4-26 10:05:00 

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

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

namespace Yeefly
{
 /// <summary>
 /// Graph 的摘要说明。
 /// </summary>
 public class topn3dpie : System.Web.UI.Page
 {
  private void Page_Load(object sender, System.EventArgs e)
  {
   Response.ContentType = "image/jpeg";
   const int width = 300, height = 300;
   int x = 30, y = 50;

   int pieWidth = 120, pieHeight = 40, pieShadow = 15;
   int[] arrVote = {70,90,80,20,60,40};
   Random oRan = new Random();
 

   Bitmap objBitmap = new Bitmap(width, height);
   Graphics objGraphics = Graphics.FromImage(objBitmap);
   objGraphics.DrawRectangle(new Pen(Color.Black),0,0,width,height);
   objGraphics.FillRectangle(new SolidBrush(Color.White), 1, 1,width - 2, height - 2);
   SolidBrush objBrush = new SolidBrush(Color.Blue);
   objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
 
   int iCurrentPos   = 0;

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

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

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

   iCurrentPos  = 0;
   for(int i = 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);
   // clean up...
   objGraphics.Dispose();
   objBitmap.Dispose();
  }

  #region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
 
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {   
   this.Load += new System.EventHandler(this.Page_Load);
  }
  #endregion
 }
}

  
 本文TagsC#  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:学了一段时间的Asp.Net 2.0后,心里一些想法
· 下一篇:asp.net 2.0中用GRIDVIEW插入新记录
· 用ASP.NET 1.1 新特征防止Script攻击
· 10天学会ASP.net之第三天
· IIS组建Intranet完全手册(一)
· 关于webcontrol和pagelet的一点看法
· ASP.NET入门经典-First Experience with ASP.NET in DWMX


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077