示例#1
0
    public static string GenerateWireFrame(string FilePath, string TemplateName)
    {
        try
        {
            //Check For Default Layout
            BlockParser.CheckFilePath(FilePath.ToLower());
            List <XmlTag> lstXmlTags   = new List <XmlTag>();
            XmlParser     parser       = new XmlParser();
            string        templatePath = Decide.IsTemplateDefault(TemplateName.Trim()) ? Utils.GetTemplatePath_Default(TemplateName) : Utils.GetTemplatePath(TemplateName);
            string        filePath     = FilePath.ToLower().Equals("core") ? string.Format("{0}/Layouts/standard/All.xml", Utils.GetTemplatePath_Default("Default")) : string.Format("{0}/layouts/{1}.xml", templatePath, FilePath);

            lstXmlTags = parser.GetXmlTags(filePath, "layout/section");
            List <XmlTag>       lstWrappers = parser.GetXmlTags(filePath, "layout/wrappers");
            ModulePaneGenerator wg          = new ModulePaneGenerator();
            return(wg.GenerateHTML(lstXmlTags, lstWrappers, 0));
        }
        catch (Exception)
        {
            if (FilePath.ToLower().Equals("core"))
            {
                return("<div class='sfMessage sfErrormsg'>Invalid XML document<input type='button' class='sfResetCore' id='btnReset' value='Reset Core'/></div>");
            }
            else
            {
                return("<div class='sfMessage sfErrormsg'>Invalid XML document</div>");
            }
        }
    }
示例#2
0
    public static void CreateLayoutControls(string TemplateName, string filePath)
    {
        BlockParser.CheckFilePath();
        string templatePath        = Decide.IsTemplateDefault(TemplateName) ? Utils.GetTemplatePath_Default(TemplateName) : Utils.GetTemplatePath(TemplateName);
        string presetPath          = Decide.IsTemplateDefault(TemplateName) ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName);
        ModulePaneGenerator mg     = new ModulePaneGenerator();
        XmlParser           parser = new XmlParser();

        try
        {
            List <XmlTag> lstXmlTag   = parser.GetXmlTags(filePath, "layout/section");
            List <XmlTag> lstWrappers = parser.GetXmlTags(filePath, "layout/wrappers");
            string        html        = mg.GenerateHTML(lstXmlTag, lstWrappers, 2);
            //html = Utils.FormatHtmlOutput(html);
            string controlclass = Path.GetFileNameWithoutExtension(filePath);
            string controlname  = string.Format("{0}.ascx", controlclass);
            if (!File.Exists(templatePath + "/" + controlname))
            {
                FileStream fs = null;
                using (fs = File.Create(templatePath + "/" + controlname))
                {
                }
            }
            else
            {
                File.Delete(templatePath + "/" + controlname);
                FileStream fs = null;
                using (fs = File.Create(templatePath + "/" + controlname))
                {
                }
            }
            using (StreamWriter sw = new StreamWriter(templatePath + "/" + controlname))
            {
                sw.Write("<%@ Control Language=\"C#\" ClassName=" + controlclass + " %>");
                sw.Write(Environment.NewLine);
                sw.Write(html);
            }
        }
        catch (Exception)
        {
            throw;
        }
    }