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 Spaces;
namespace Dottext.Web
{
	/// <summary>
	/// InsertCode 的摘要说明。
	/// </summary>
	public partial class InsertCode : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox CodeTextBox;
		
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			Response.Expires=-1;
			if(!IsPostBack)
			{

               
			}

		}

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

		}
		#endregion

		protected void HighlightButton_Click(object sender, System.EventArgs e)
		{
			string lanuage=LanguageDropDownList.SelectedItem.Value;
           
             HighLighter hl = new HighLighter();
                hl.ReplaceEnter = true;
            string path=Server.MapPath(string.Format("{0}/include/defs/",Globals.ApplicationPath));
            string html = hl.colorText1(CodeText.Text, path, lanuage);
            html = html.Replace("\"", "\\\"");
            html = html.Replace("\r\n", "\"+\r\n\"");
            //	html=Dottext.Framework.Util.Globals.ReplaceSpace(html);
            string imgpath = Globals.ApplicationPath;  //Dottext.Framework.Util.Globals.GetAppUrl(Request)+"Images/";
            //html = html.Replace("...", "<img src='" + imgpath + "dot.gif'>");
            //html=html.Replace("<div>",string.Empty);
            //html=html.Replace("</div>",string.Empty);
            //html=html.Replace(" ","&nbsp;");
            //html=html.Replace("\r","\"+\r");
            //html=html.Replace("\n","\"\n");
            /*System.IO.StreamWriter sw=new System.IO.StreamWriter("f:\\test.txt");
            sw.Write(html);
            sw.Flush();
            sw.Close();*/
            string divstr = @"<div style='BORDER-RIGHT: windowtext 0.5pt solid;PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px;PADDING-TOP: 4px; 	BORDER-LEFT: windowtext 0.5pt solid;WIDTH: 98%;	BORDER-BOTTOM: windowtext 0.5pt solid'>";
            divstr = string.Empty;
            Response.Write(@"
				<script language='javascript'>
                 alert(""" + divstr + html + @""");
				window.parent.returnValue = """ + divstr + html + @""";
				window.parent.close();
				</script>");

        /* 	string divstr=@"<div style='BORDER-RIGHT: windowtext 0.5pt solid;PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px;PADDING-TOP: 4px; 	BORDER-LEFT: windowtext 0.5pt solid;WIDTH: 98%;	BORDER-BOTTOM: windowtext 0.5pt solid'>";
            Response.Write(@"
            <script language='javascript'>
            window.parent.returnValue = """+divstr+html+@"</div>"";
            window.parent.close();
            </script>");
        */
			
		}

		public void CodeHighlighter_PostRender(object sender, System.EventArgs e)
		{
			if(IsPostBack)
			{
			
			}
								
		}
		
		
	}
}
