private void Page_Load(object sender, System.EventArgs e)
		{
			Estatística.Db.Gráfico	gráfico;
			Desenhista				desenhista = new Desenhista();
			MemoryStream			memStream = new MemoryStream();
			Bitmap					bmp;
			Hashtable				propriedades;
			IDbCommand              cmd;
//			string []				legenda;

			gráfico = new Estatística.Db.Gráfico();
			gráfico.CarregarDefinições(ObterDefinições());

			cmd = ObterConexão().CreateCommand();
			ObterParâmetros(cmd);

			gráfico.ConfigurarGráfico(cmd, Request.QueryString["ref"].Replace("\t", ""), desenhista);

			propriedades = Estatística.Desenhista.ObterPropriedades();
			propriedades["limparFundo"] = Brushes.White;

			bmp = desenhista.Desenhar(
				int.Parse(Request.QueryString["largura"]),
				int.Parse(Request.QueryString["altura"]),
				propriedades);

			bmp.Save(memStream, System.Drawing.Imaging.ImageFormat.Jpeg);

			Response.Clear();
			Response.Cache.SetCacheability(HttpCacheability.NoCache);
			Response.ContentType = "image/jpeg";
			Response.BinaryWrite(memStream.ToArray());
			Response.End();
		}
Example #2
0
		/// <summary> 
		/// Render this control to the output parameter specified.
		/// </summary>
		/// <param name="output"> The HTML writer to write out to </param>
		//protected override void Render(HtmlTextWriter output)
		protected override void RenderContents(HtmlTextWriter output)
		{
			Estatística.Db.Gráfico	gráfico;
			MemoryStream			memStream = new MemoryStream();
			Hashtable				propriedades;
			string []				legenda;
			IDbCommand              cmd;

			propriedades = Estatística.Desenhista.ObterPropriedades();
			propriedades["limparFundo"] = Brushes.White;

			gráfico = new Estatística.Db.Gráfico();
			gráfico.CarregarDefinições(ObterDefinições());

			cmd = Conexão.CreateCommand();
			
			ObterParâmetros(cmd);

			legenda = gráfico.ObterLegendas(cmd, referência);

			output.WriteLine("<table border=0 cellspacing=2px cellpadding=0>");

			// Desenhar legenda
			for (int i = 0; i < legenda.Length; i++)
			{
				Pen pen = (Pen) propriedades["vérticePen" + i.ToString()];

				output.WriteLine("<tr>");
				output.WriteLine("<td style='background-color: "
					+ "#" + pen.Color.R.ToString("X2")
					+ pen.Color.G.ToString("X2")
					+ pen.Color.B.ToString("X2")
					+ "; font-family: sans-serif; font-size: 12px'>::</td>");

				output.WriteLine("<td style='color: "
					+ "#" + pen.Color.R.ToString("X2")
					+ pen.Color.G.ToString("X2")
					+ pen.Color.B.ToString("X2")
					+ "; font-family: sans-serif; font-size: 12px'>" + legenda[i] + "</td>");

				output.WriteLine("</tr>");
			}

			output.WriteLine("</table>");
		}