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.IO;
using Spaces;
namespace Dottext.Web
{
	/// <summary>
	/// EmoticonGallery 的摘要说明。
	/// </summary>
	public partial class EmoticonsGallery : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Image Image1;
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			System.IO.StreamReader sr=new System.IO.StreamReader(MapPath("Script")+"\\Emoticon.js");
			this.RegisterClientScriptBlock("EmoticonScript",sr.ReadToEnd());
			sr.Close();

			int ColumnCount=10;
			int index=0;
			if(Request.QueryString["rif"]==null)
			{
				return;
			}
			//string imagepath=Request.QueryString["rif"];
			//string path=MapPath(imagepath);
            string imagepath = Globals.ApplicationPath + "/images/Emoticons/qq";
            string path = MapPath(imagepath);
			System.IO.DirectoryInfo dir=new System.IO.DirectoryInfo(path);
			TableRow row=new TableRow();
			foreach (FileInfo file in dir.GetFiles())
			{
				TableCell cell=new TableCell();
				
				//System.Web.UI.WebControls.Image image=new System.Web.UI.WebControls.Image();
				//image.ImageUrl=imagepath+"/"+file.Name;
                //System.Drawing.Image myimg=System.Drawing.Image.FromFile(file.FullName);
				//string width=myimg.Width.ToString();
				//string height=myimg.Height.ToString();
                string width = "20";
                string height = "20";
				string apppath=Globals.ApplicationPath;
                string celltext = "<div ondblclick=\"returnImage('" + imagepath + "/" + file.Name + "','" + width + "','" + height + "')\">";
				celltext+="<img src='"+imagepath+"/"+file.Name+"'>";
				celltext+="</div>";
				cell.Text=celltext;
				//image.Attributes.Add("ondblclick","returnImage('"+image.ImageUrl+"','"+width+"','"+height+"')");
				//cell.Controls.Add(image);
				row.Cells.Add(cell);
				index++;
				if(index % ColumnCount == 0)
				{
					EmoticonsTable.Rows.Add(row);
					row=new TableRow();
				}

			}
			//Response.Write(MapPath(folder));
			Response.Expires=-1;
		}

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

		}
		#endregion
	}
}
