using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Text.RegularExpressions;
using EKETEAM.FrameWork;

namespace eFrameWork.Plugins
{
    public partial class FontIconSelect : System.Web.UI.Page
    {
        public string obj = eParameters.QueryString("obj");
        protected string fonticons()
        {
            StringBuilder sb = new StringBuilder();
            string html = eBase.ReadFile(Server.MapPath("fonticons.html"));

            Regex regex = new Regex(@"<body[^>]*>([\s\S]*)<\/body>", RegexOptions.IgnoreCase);
            Match ma = regex.Match(html);
            if (ma.Success)
            {
                html = ma.Groups[1].Value;
            }
            regex = new Regex(@"<section[^>]*?>([\s\S]*?)</section>", RegexOptions.IgnoreCase); //有换行
            for (Match mn = regex.Match(html); mn.Success; mn = mn.NextMatch())
            {
                string htm = mn.Groups[0].Value;
                Match _m = Regex.Match(htm, @"<h2[^>]*?>.*?</h2>");
                if (_m.Success)
                {
                    if (_m.Value.IndexOf("清空") > -1)
                    {
                        continue;
                    }
                    sb.Append(_m.Value + "\n");
                }
                Regex reg = new Regex(@"<i[^>]*?>.*?</i>", RegexOptions.IgnoreCase); //无换行
                for (Match m = reg.Match(htm); m.Success; m = m.NextMatch())
                {
                    // eBase.WriteHTML(m.Groups[0].Value);
                    sb.Append("<a class=\"fa-hover\" href=\"javascript:;\" onclick=\"seticon(this);\">" + m.Groups[0].Value + "</a>\r\n");
                }
            }
            /*
            Regex reg = new Regex(@"<i[^>]*?>.*?</i>", RegexOptions.IgnoreCase); //无换行
            for (Match m = reg.Match(html); m.Success; m = m.NextMatch())
            {
                // eBase.WriteHTML(m.Groups[0].Value);
                sb.Append("<a class=\"fa-hover\" href=\"javascript:;\" onclick=\"parent.setIco(this);\">" + m.Groups[0].Value + "</a>\r\n");
            }
            */

            //eBase.WriteHTML(html);
           // LitBody.Text = sb.ToString();

            return sb.ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //ht tps://fontawesome.com/v3/icons/
            //htt ps://fontawesome.com/v4/icons/
            StringBuilder sb = new StringBuilder();
            string str = eBase.ReadFile(Server.MapPath("fontico.txt"));
            Regex regx = new Regex(@"<section[^>]*?>([\s\S]*?)</section>", RegexOptions.IgnoreCase); //有换行
            for (Match mn = regx.Match(str); mn.Success; mn = mn.NextMatch())
            {
                string html = mn.Groups[0].Value;
                // if (html.IndexOf("mainParts") > -1 && html.IndexOf("fontawesome-icon-list") > -1)
                if ( html.IndexOf("fontawesome-icon-list") > -1)
                {

                    Match _m = Regex.Match(html, @"<h2[^>]*?>.*?</h2>");
                    if (_m.Success)
                    {
                        //eBase.Writeln(_m.Value);
                        if (_m.Value.IndexOf( "清空")>-1)
                        {

                            continue;
                        }
                        sb.Append(_m.Value + "\r\n");
                    }
                    Regex reg = new Regex(@"<i[^>]*?>.*?</i>", RegexOptions.IgnoreCase); //无换行
                    for (Match m = reg.Match(html); m.Success; m = m.NextMatch())
                    {
                        //eBase.Writeln(m.Groups[0].Value);
                        sb.Append("<a class=\"fa-hover\" href=\"javascript:;\" onclick=\"seticon(this);\">" + m.Groups[0].Value + "</a>\r\n");
                    }
                }
            }

            sb.Append(fonticons());

            LitBody.Text = sb.ToString();
        }




    }
}