示例#1
0
        /// <summary>
        ///Obtain starting placeholder.
        ///1.Check for classes like no-wrap and no-main.
        ///2.Check for wrap-inner and main-inner classes.
        ///3.If Wrap-inner is not defined simply create a wrap class and a id from the key.
        ///4.Check for main inner and other wrappers.
        ///5.If we are using special markup tags this is the place to begin the markups.
        ///6.Generate main-inner wrappers if present.
        /// </summary>
        /// <param name="placeholder">Object of XmlTag class.</param>
        /// <returns>String format of placeholder markup.</returns>
        public static string GeneratePlaceholderStart(XmlTag placeholder)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(String.Format("<div id=\"id-{0}\" class=\"sf{1}\">", Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME), Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME)));
            return(sb.ToString());
        }
示例#2
0
        public List <CustomWrapper> ProcessWrappers(List <XmlTag> lstTags, List <XmlTag> lstWrappers)
        {
            List <CustomWrapper> lstCustomWrappers = new List <CustomWrapper>();
            int index = 0;

            foreach (XmlTag wrapper in lstWrappers[0].LSTChildNodes)
            {
                string type = Utils.GetAttributeValueByName(wrapper, XmlAttributeTypes.TYPE);
                switch (type)
                {
                case "position":
                    foreach (XmlTag tag in lstTags)
                    {
                        foreach (XmlTag pch in tag.LSTChildNodes)
                        {
                            if (pch.InnerHtml.ToLower().Contains(wrapper.InnerHtml.ToLower()))
                            {
                                CustomWrapper obj = new CustomWrapper();
                                obj.Name         = Utils.GetAttributeValueByName(wrapper, XmlAttributeTypes.NAME);
                                obj.Class        = Utils.GetAttributeValueByName(wrapper, XmlAttributeTypes.CLASS);
                                obj.Depth        = Utils.GetAttributeValueByName(wrapper, XmlAttributeTypes.DEPTH) == "" ? 1 : int.Parse(Utils.GetAttributeValueByName(wrapper, XmlAttributeTypes.DEPTH));
                                obj.Start        = wrapper.PositionsArr[0];
                                obj.End          = wrapper.PositionsArr[wrapper.PositionsArr.Length - 1];
                                obj.LSTPositions = wrapper.PositionsArr.ToList();
                                obj.Type         = Utils.GetAttributeValueByName(wrapper, XmlAttributeTypes.TYPE);
                                obj.Index        = index;
                                lstCustomWrappers.Add(obj);
                                break;
                            }
                        }
                    }
                    break;

                case "placeholder":
                    foreach (XmlTag tag in lstTags)
                    {
                        if (tag.Placeholders.ToLower().Contains(wrapper.InnerHtml.ToLower()) || wrapper.InnerHtml == "left,middle" || wrapper.InnerHtml == "right,middle")
                        {
                            CustomWrapper obj = new CustomWrapper();
                            obj.Name         = Utils.GetAttributeValueByName(wrapper, XmlAttributeTypes.NAME);
                            obj.Class        = Utils.GetAttributeValueByName(wrapper, XmlAttributeTypes.CLASS);
                            obj.Depth        = Utils.GetAttributeValueByName(wrapper, XmlAttributeTypes.DEPTH) == "" ? 1 : int.Parse(Utils.GetAttributeValueByName(wrapper, XmlAttributeTypes.DEPTH));
                            obj.Start        = wrapper.PositionsArr[0];
                            obj.End          = wrapper.PositionsArr[wrapper.PositionsArr.Length - 1];
                            obj.LSTPositions = wrapper.PositionsArr.ToList();
                            obj.Type         = Utils.GetAttributeValueByName(wrapper, XmlAttributeTypes.TYPE);
                            obj.Index        = index;
                            lstCustomWrappers.Add(obj);
                            break;
                        }
                    }
                    break;
                }
                index++;
            }
            return(lstCustomWrappers);
        }
示例#3
0
        public static bool IsSpotLight(XmlTag placeholder)
        {
            string pchName = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME);
            bool   status  = false;

            if (Utils.CompareStrings(pchName, "spotlight"))
            {
                status = true;
            }
            return(status);
        }
示例#4
0
        /// <summary>
        /// Obtain block wrapper.
        /// </summary>
        /// <param name="pch">Object of  XmlTag class.</param>
        /// <param name="wrapperdepth">List of wrapper depth.</param>
        /// <returns>String format of block wrapper.</returns>
        public static string GenerateBlockWrappers(XmlTag pch, ref List <int> wrapperdepth)
        {
            StringBuilder sb          = new StringBuilder();
            int           wrapinner   = int.Parse(Utils.GetAttributeValueByName(pch, XmlAttributeTypes.WRAPINNER, "1"));
            int           wrapouter   = int.Parse(Utils.GetAttributeValueByName(pch, XmlAttributeTypes.WRAPOUTER, "1"));
            string        customclass = Utils.GetAttributeValueByName(pch, XmlAttributeTypes.CLASS);

            wrapperdepth.Add(wrapouter);
            wrapperdepth.Add(wrapinner);
            if (wrapouter != 0)
            {
                for (int i = 1; i <= wrapouter; i++)
                {
                    if (i == 1)
                    {
                        string wrapperclass = wrapouter > 1 ? "sfOuterwrapper" : "sfOuterwrapper clearfix";
                        wrapperclass = customclass != "" ? string.Format("{0} {1}", wrapperclass, customclass) : wrapperclass;
                        sb.Append(string.Format("<div id='sf{0}' class='{1}'>", Utils.UppercaseFirst(Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME)), wrapperclass));
                    }
                    else
                    {
                        string wrapperclass = wrapouter == i?string.Format("sfOuterwrapper{0} clearfix", i - 1) : string.Format("sfOuterwrapper{0}", i - 1);

                        wrapperclass = customclass != "" ? string.Format("{0} {1}", wrapperclass, customclass) : wrapperclass;
                        sb.Append(string.Format("<div class='{0}'>", wrapperclass));
                    }
                }
            }
            else if (wrapouter == 0)
            {
                sb.Append(string.Format("<div id='sf{0}'>", Utils.UppercaseFirst(Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME))));
            }
            if (wrapinner != 0)
            {
                for (int i = 1; i <= wrapinner; i++)
                {
                    if (i == 1)
                    {
                        string wrapperclass = wrapinner > 1 ? "sfInnerwrapper" : "sfInnerwrapper clearfix";
                        sb.Append(string.Format("<div class='{0}'>", wrapperclass));
                    }
                    else
                    {
                        string wrapperclass = wrapinner == i?string.Format("sfInnerwrapper{0} clearfix", i - 1) : string.Format("sfInnerwrapper{0}", i - 1);

                        sb.Append(string.Format("<div class='{0}'>", wrapperclass));
                    }
                }
            }



            return(sb.ToString());
        }
示例#5
0
        public static bool HasBlock(Placeholders pch, XmlTag middleBlock)
        {
            bool status = false;

            status = middleBlock.LSTChildNodes.Exists(
                delegate(XmlTag tag)
            {
                return(Utils.CompareStrings(Utils.GetAttributeValueByName(tag, XmlAttributeTypes.NAME), pch));
            }
                );
            return(status);
        }
示例#6
0
        /// <summary>
        /// Obtain inner HTML tag.
        /// </summary>
        /// <param name="pch">Placeholders.<see cref="T:SageFrame.Templating.Placeholders"/></param>
        /// <param name="middleBlock"></param>
        /// <returns></returns>
        public static string GetTagInnerHtml(Placeholders pch, XmlTag middleBlock)
        {
            XmlTag currentTag = new XmlTag();

            currentTag = middleBlock.LSTChildNodes.Find(
                delegate(XmlTag tag)
            {
                return(Utils.CompareStrings(Utils.GetAttributeValueByName(tag, XmlAttributeTypes.NAME), pch));
            }
                );
            return(currentTag.InnerHtml);
        }
示例#7
0
        public string GenerateHTML(List <XmlTag> lstTags, List <XmlTag> lstWrappers, int Mode)
        {
            string markup = "";
            List <CustomWrapper> lstCustomWrappers = new List <CustomWrapper>();

            if (lstWrappers.Count > 0)
            {
                lstCustomWrappers = ProcessWrappers(lstTags, lstWrappers);
            }
            foreach (XmlTag tag in lstTags)
            {
                if (tag.TagType == XmlTagTypes.Section)
                {
                    foreach (CustomWrapper start in lstCustomWrappers)
                    {
                        if (start.Type == "block" && Utils.GetAttributeValueByName(tag, XmlAttributeTypes.NAME).Equals(start.Start))
                        {
                            string style = string.Format("sfSectionwrap {0}", start.Class);
                            int    depth = start.Depth;
                            for (int i = 1; i <= depth; i++)
                            {
                                if (i == 1)
                                {
                                    style   = start.Depth > 1 ? string.Format("sfSectionwrap sfWrap{0}{1}", start.Index, start.Class == "" ? "" : string.Format(" {0}", start.Class)) : string.Format("sfSectionwrap sfWrap{0}{1} clearfix", start.Index, start.Class == "" ? "" : string.Format(" {0}", start.Class));;
                                    markup += "<div class='" + style + "'>";
                                }
                                else
                                {
                                    style = start.Depth == i?string.Format("sfSectionwrap sf{0}{1} clearfix", i - 1, start.Class == ""? "" : string.Format(" {0}", start.Class)) : string.Format("sfSectionwrap sf{0}{1}", i - 1, start.Class == "" ? "" : string.Format(" {0}", start.Class));

                                    markup += "<div class='" + style + "'>";
                                }
                            }
                        }
                    }
                    markup += GenerateSectionMarkup(tag, lstCustomWrappers, Mode);

                    foreach (CustomWrapper start in lstCustomWrappers)
                    {
                        if (start.Type == "block" && Utils.GetAttributeValueByName(tag, XmlAttributeTypes.NAME).Equals(start.End))
                        {
                            for (int i = 1; i <= start.Depth; i++)
                            {
                                markup += "</div>";
                            }
                        }
                    }
                }
            }


            return(GenerateExternalWrapper(markup));
        }
        public static string GeneratePlaceholderStart(XmlTag placeholder)
        {
            //1.Check for classes like no-wrap and no-main
            //2.Check for wrap-inner and main-inner classes
            //3.If Wrap-inner is not defined simply create a wrap class and a id from the key
            //4.Check for main inner and other wrappers
            //5.If we are using special markup tags this is the place to begin the markups
            //6.Generate main-inner wrappers if present

            StringBuilder sb = new StringBuilder();

            sb.Append(String.Format("<div id=\"id-{0}\" class=\"sf{1}\">", Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME), Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME)));
            return(sb.ToString());
        }
示例#9
0
        public static bool IsCustomBlockDefined(XmlTag placeholder)
        {
            string activeTemplate = HttpContext.Current.Session["SageFrame.ActiveTemplate"] != null ? HttpContext.Current.Session["SageFrame.ActiveTemplate"].ToString() : "Default";
            string pchName        = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME);
            string FilePath       = "E://DotNetProjects//sftemplating//SageFrame//" + activeTemplate + "//sections";
            bool   status         = false;

            if (Directory.Exists(FilePath))
            {
                DirectoryInfo dir = new DirectoryInfo(FilePath);
                foreach (FileInfo file in dir.GetFiles("*.htm"))
                {
                    if (Utils.CompareStrings(Path.GetFileNameWithoutExtension(file.Name), pchName))
                    {
                        status = true;
                        break;
                    }
                }
            }
            return(status);
        }
示例#10
0
        /// <summary>
        /// Calculates the column width for the middle block
        /// Takes the ColumnWidth from the Parent Node which applies to right and left
        /// However the inline "width" attributes overrides the Parent's colwidth attribute
        /// </summary>
        /// <param name="section">XmlTag class containing xml details.</param>
        /// <param name="_type">Placeholders <see cref="T:SageFrame.Templating.Placeholders"/></param>
        /// <returns>Column width.</returns>
        public static string CalculateColumnWidth(XmlTag section, Placeholders _type)
        {
            string width = "20";

            foreach (XmlTag tag in section.LSTChildNodes)
            {
                if (Utils.CompareStrings(_type, Utils.GetAttributeValueByName(tag, XmlAttributeTypes.NAME)))
                {
                    int widthIndex = -1;
                    widthIndex = tag.LSTAttributes.FindIndex(
                        delegate(LayoutAttribute tagAttr)
                    {
                        return(Utils.CompareStrings(tagAttr.Name, XmlAttributeTypes.WIDTH));
                    }
                        );
                    if (widthIndex > -1)
                    {
                        width = tag.LSTAttributes[widthIndex].Value;
                    }
                    else
                    {
                        foreach (LayoutAttribute attr in section.LSTAttributes)
                        {
                            if (Utils.CompareStrings(attr.Name, XmlAttributeTypes.WIDTH))
                            {
                                width = attr.Value;
                            }
                            else if (Utils.CompareStrings(attr.Name, XmlAttributeTypes.COLWIDTH))
                            {
                                width = attr.Value;
                            }
                        }
                    }
                }
            }
            return(width);
        }
示例#11
0
        /// <summary>
        /// Obtain left right placeholder.
        /// </summary>
        /// <param name="placeholder">Placeholders<see cref="T:SageFrame.Templating.Placeholders"/></param>
        /// <param name="middleblock">Object of XmlTag class.</param>
        /// <param name="lstWrapper">List of CustomWrapper class.</param>
        /// <param name="_Mode">Mode</param>
        /// <param name="Width">Width</param>
        /// <returns>String format of placeholder</returns>
        public static string ProcessLeftRightPlaceholders(Placeholders placeholder, XmlTag middleblock, List <CustomWrapper> lstWrapper, int _Mode, string Width)
        {
            Mode = _Mode;
            StringBuilder sb          = new StringBuilder();
            bool          isAvailable = false;

            foreach (XmlTag pch in middleblock.LSTChildNodes)
            {
                if (Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME).ToLower() == placeholder.ToString().ToLower())
                {
                    foreach (CustomWrapper start in lstWrapper)
                    {
                        if (start.Type == "placeholder" && Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME).ToLower().Equals(start.Start))
                        {
                            string style = "";
                            for (int i = 1; i <= start.Depth; i++)
                            {
                                if (i == 1)
                                {
                                    style = start.Depth > 1 ? string.Format("sfBlockwrap {0}", start.Class) : string.Format("sfBlockwrap {0} clearfix", start.Class);
                                    sb.Append("<div class='" + style + "'>");
                                }
                                else
                                {
                                    style = start.Depth == i?string.Format("sfBlockwrap {0} sf{1} clearfix", start.Class, i) : string.Format("sfBlockwrap {0} sf{1}", start.Class, i);

                                    sb.Append("<div class='" + style + "'>");
                                }
                            }
                        }
                    }

                    string[] positions    = pch.InnerHtml.Split(',');
                    int      mode         = Utils.GetAttributeValueByName(pch, XmlAttributeTypes.MODE) == "" ? 0 : 1;
                    string   wrapperclass = string.Format("sf{0} clearfix", Utils.UppercaseFirst(Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME)));
                    wrapperclass = string.Format("{0} {1}", wrapperclass, Utils.GetAttributeValueByName(pch, XmlAttributeTypes.CLASS));
                    //string colwidth = string.Format("class='{0}' style='width:{1}'", wrapperclass, Width);
                    string colwidth = string.Format("class='{0} {1}'", wrapperclass, sfCol + Width);
                    sb.Append("<div " + colwidth + ">");
                    switch (mode)
                    {
                    case 0:
                        sb.Append(ParseNormalLeftRightBlocks(pch, lstWrapper));
                        break;

                    case 1:
                        sb.Append(ParseFixedBlocks(pch, lstWrapper));
                        break;
                    }
                    sb.Append("</div>");
                    foreach (CustomWrapper start in lstWrapper)
                    {
                        string pchName = Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME).ToLower();
                        if (start.Type == "placeholder" && pchName.Equals(start.End))
                        {
                            for (int i = 1; i <= start.Depth; i++)
                            {
                                sb.Append("</div>");
                            }
                        }
                    }
                    isAvailable = true;
                }
            }
            if (!isAvailable)
            {
                sb.Append(Mode == 2 ? "<div class='" + placeholder.ToString().ToLower() + "'><div class='sfWrapper'>" : "<div class='" + placeholder.ToString().ToLower() + "'><div class='sfWrapper sfCurve'>");
                sb.Append(HtmlBuilder.AddPlaceholder(placeholder.ToString().ToLower(), Mode));
                sb.Append("</div></div>");
            }

            return(sb.ToString());
        }
示例#12
0
        /// <summary>
        /// Parsing left right block.
        /// </summary>
        /// <param name="placeholder">Object of XmlTag class.</param>
        /// <param name="lstWrapper">List of CustomWrapper class.</param>
        /// <returns>String format of left right block markup.</returns>
        static string ParseNormalLeftRightBlocks(XmlTag placeholder, List <CustomWrapper> lstWrapper)
        {
            StringBuilder sb        = new StringBuilder();
            string        positions = placeholder.InnerHtml;

            string[] positionsAr = positions.Split(',');
            bool     fullWidth   = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.WIDTH) == "" ? true : false;

            string[] arrWidth = (Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.WIDTH) == "" ? "100" : Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.WIDTH)).Split(',');
            if (positionsAr.Length > 1)
            {
                sb.Append(Mode == 2 ? "<div class='sfMoreblocks clearfix'>" : "<div class='sfMoreblocks sfCurve clearfix'>");
            }
            for (int i = 0; i < positionsAr.Length; i++)
            {
                string style = "";
                foreach (CustomWrapper start in lstWrapper)
                {
                    if (start.Type == "position")
                    {
                        List <KeyValue> lstWidths    = new List <KeyValue>();
                        int             wrapperwidth = Calculator.CalculateWrapperWidth(positionsAr, arrWidth, start.LSTPositions.ToArray(), "normal", out lstWidths);

                        if (start.Start.ToLower() == positionsAr[i])
                        {
                            string divwidth = string.Format("{0}%", (wrapperwidth).ToString());
                            for (int j = 1; j <= start.Depth; j++)
                            {
                                if (j == 1)
                                {
                                    string wrapstyle = start.Depth > 1 ? string.Format("sfWrap sfInnerwrap{0}{1}", start.Index, start.Class == "" ? "" : string.Format(" {0}", start.Class)) : string.Format("sfWrap sfInnerwrap{0}{1} clearfix", start.Index, start.Class == "" ? "" : string.Format(" {0}", start.Class));
                                    //string floatstyle = divwidth == "100%" ? string.Format("width:{0}", divwidth) : string.Format("width:{0};float:left", divwidth);
                                    string floatstyle = sfCol + wrapperwidth.ToString();// == "100%" ? string.Format("width:{0}", divwidth) : string.Format("width:{0};float:left", divwidth);
                                    //sb.Append("<div style='" + floatstyle + "' class='" + wrapstyle + "'>");
                                    sb.Append("<div class='" + wrapstyle + " " + floatstyle + "'>");
                                }
                                else
                                {
                                    string multiplewrappers = start.Depth == j?string.Format("sfWrap {0} sf{1} clearfix", start.Class, j) : string.Format("sfWrap {0} sf{1}", start.Class == "" ? "" : string.Format(" {0}", start.Class), j);

                                    //string floatstyle = divwidth == "100%" ? string.Format("width:{0}", divwidth) : string.Format("width:{0};float:left", divwidth);
                                    string floatstyle = sfCol + wrapperwidth.ToString();
                                    //sb.Append("<div style='" + floatstyle + "' class='" + multiplewrappers + "'>");
                                    sb.Append("<div class='" + multiplewrappers + " " + floatstyle + "'>");
                                }
                            }
                        }
                        if (start.LSTPositions.Contains(positionsAr[i]))
                        {
                            int width = Calculator.CalculatePostWrapWidth(start.LSTPositions.ToArray(), positionsAr[i], wrapperwidth, "normal", lstWidths);
                            //style = Mode == 0 ? string.Format("width:{0}%;float:left", width) : width == 100 ? "float:left" : string.Format("width:{0}%;float:left", width);
                            style = sfCol + width.ToString();// Mode == 0 ? string.Format("width:{0}%;float:left", width) : width == 100 ? "float:left" : string.Format("width:{0}%;float:left", width);
                        }
                    }
                }
                string customStyle = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT) == "" ? string.Format("{0}", style) : string.Format("{0};min-height:{1}px", style, Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT));
                if (customStyle != "")
                {
                    string id = string.Format("sf{0}", Utils.UppercaseFirst(positionsAr[i]));
                    sb.Append("<div id=" + id + " style='" + customStyle + "'>");
                    //sb.Append("<div id=" + id + " class='" + style.Replace('%','') + "'>");
                }
                sb.Append(Mode == 2 ? "<div class='sfWrapper'>" : "<div class='sfWrapper sfCurve'>");
                //sb.Append(positionsAr[i]);
                sb.Append(HtmlBuilder.AddPlaceholder(positionsAr[i], Mode));
                sb.Append("</div>");
                if (customStyle != "")
                {
                    sb.Append("</div>");
                }

                if (arrWidth.Length == i)
                {
                    //sb.Append("<div class='clearfix'></div>");
                }
                foreach (CustomWrapper start in lstWrapper)
                {
                    if (start.End.ToLower() == positionsAr[i] && start.Type == "position")
                    {
                        for (int j = 1; j <= start.Depth; j++)
                        {
                            sb.Append("</div>");
                        }
                    }
                }
            }
            if (positionsAr.Length > 1)
            {
                sb.Append("</div>");
            }
            return(sb.ToString());
        }
示例#13
0
        /// <summary>
        /// Obtain place holder.
        /// </summary>
        /// <param name="placeholder">Object of XmlTag class.</param>
        /// <param name="lstWrapper">List of CustomWrapper class.</param>
        /// <param name="_Mode">Mode</param>
        /// <returns>String format of placeholder markup.</returns>
        public static string ProcessPlaceholder(XmlTag placeholder, List <CustomWrapper> lstWrapper, int _Mode)
        {
            Mode = _Mode;
            ///1.Check for outer wrappers(skipping for now)
            ///2.Check for the wrapper="inner,3" attribute, Split the positions and inline styles according to width and mode attribute
            StringBuilder sb = new StringBuilder();

            foreach (XmlTag pch in placeholder.LSTChildNodes)
            {
                string[] positions = pch.InnerHtml.Split(',');
                int      mode      = Utils.GetAttributeValueByName(pch, XmlAttributeTypes.MODE) == "" ? 0 : 1;
                foreach (CustomWrapper start in lstWrapper)
                {
                    if (start.Type == "placeholder" && Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME).ToLower().Equals(start.Start))
                    {
                        string style = string.Format("sfBlockwrap {0}", start.Class);
                        int    depth = start.Depth;
                        for (int i = 1; i <= depth; i++)
                        {
                            if (i == 1)
                            {
                                style = start.Depth > 1 ? string.Format("sfBlockwrap sfWrap{0}{1}", start.Index, start.Class == "" ? "" : string.Format(" {0}", start.Class)) : string.Format("sfBlockwrap sfWrap{0}{1} clearfix", start.Index, start.Class == "" ? "" : string.Format(" {0}", start.Class));;
                                sb.Append("<div class='" + style + "'>");
                            }
                            else
                            {
                                style = start.Depth == i?string.Format("sfBlockwrap sf{0}{1} clearfix", i - 1, start.Class == ""? "" : string.Format(" {0}", start.Class)) : string.Format("sfBlockwrap sf{0}{1}", i - 1, start.Class == "" ? "" : string.Format(" {0}", start.Class));

                                sb.Append("<div class='" + style + "'>");
                            }
                        }
                    }
                }

                List <int> wrapperdepth = new List <int>();
                sb.Append(GenerateBlockWrappers(pch, ref wrapperdepth));

                switch (mode)
                {
                case 0:
                    sb.Append(ParseNormalBlocks(pch, lstWrapper));
                    break;

                case 1:
                    sb.Append(ParseFixedBlocks(pch, lstWrapper));
                    break;
                }

                sb.Append(HtmlBuilder.GenerateBlockWrappersEnd(wrapperdepth));
                foreach (CustomWrapper start in lstWrapper)
                {
                    string pchName = Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME).ToLower();
                    if (start.Type == "placeholder" && pchName.Equals(start.End))
                    {
                        for (int i = 1; i <= start.Depth; i++)
                        {
                            sb.Append("</div>");
                        }
                    }
                }
            }
            return(sb.ToString());
        }
示例#14
0
        /// <summary>
        /// Parsing normal block.
        /// </summary>
        /// <param name="placeholder">object of XmlTag class.</param>
        /// <param name="lstWrapper">List of CustomWrapper class. </param>
        /// <returns>String format of normal block markup.</returns>
        static string ParseNormalBlocks(XmlTag placeholder, List <CustomWrapper> lstWrapper)
        {
            string pchName      = string.Format("{0}{1}{2}", "sf", Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME).ToLower(), "_mytable");
            string checkpchName = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME).ToLower();
            bool   chkPch       = false;

            string[] checkpch = { "lefttop", "leftbottom", "righttop", "rightbottom" };
            foreach (string pch in checkpch)
            {
                if (checkpchName == pch)
                {
                    chkPch = true;
                    break;
                }
                else
                {
                    chkPch = false;
                }
            }
            if (Flag)
            {
                chkPch = true;
            }
            StringBuilder sb        = new StringBuilder();
            string        positions = placeholder.InnerHtml;

            string[] positionsAr = positions.Split(',');
            bool     fullWidth   = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.WIDTH) == "" ? true : false;

            string[] arrWidth = (Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.WIDTH) == "" ? "100" : Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.WIDTH)).Split(',');
            // if (positionsAr.Length > 1)
            //{
            // sb.Append(Mode == 2 ? "<div class='sfMoreblocks clearfix'>" : "<div class='sfMoreblocks sfCurve clearfix'>");
            if (chkPch)
            {
                sb.Append(Mode == 2 ? "<div class='sfMoreblocks clearfix'>" : "<div class='sfMoreblocks sfCurve clearfix'>");
            }
            else
            {
                sb.Append(Mode == 2 ? "<table class='sfMoreblocks sfFullWidth' id=" + pchName + "><thead><tr>" : "<table  class='sfMoreblocks sfCurve sfFullWidth'id=" + pchName + "><thead><tr>");
            }
            //}
            for (int i = 0; i < positionsAr.Length; i++)
            {
                string style = "";
                if (!fullWidth)
                {
                    if (arrWidth.Length > i)
                    {
                        if (chkPch)
                        {
                            //style += arrWidth[i] == "100" ? "float:left" : string.Format("width:{0}%;float:left", arrWidth[i]);
                            style += sfCol + arrWidth[i];// == "100" ? "float:left" : string.Format("width:{0}%;float:left", arrWidth[i]);
                        }
                        else
                        {
                            style += sfCol + arrWidth[i];
                        }
                    }
                    else if (i == arrWidth.Length)
                    {
                        var remaining  = Calculator.GetRemainingWidth(arrWidth);
                        int finalWidth = remaining == 0 ? 100 : remaining;
                        if (chkPch)
                        {
                            //style += finalWidth == 100 ? "float:left" : string.Format("width:{0}%;float:left", finalWidth);
                            style += sfCol + finalWidth;
                        }
                        else
                        {
                            //    style += finalWidth == 100 ? "" : string.Format("width:{0}%;", finalWidth);
                            //style += finalWidth == 100 ? "" : sfCol + finalWidth;
                            style += sfCol + finalWidth;
                        }
                    }
                }
                else
                {
                    style += "";
                }

                foreach (CustomWrapper start in lstWrapper)
                {
                    if (start.Type == "position")
                    {
                        List <KeyValue> lstWidths    = new List <KeyValue>();
                        int             wrapperwidth = Calculator.CalculateWrapperWidth(positionsAr, arrWidth, start.LSTPositions.ToArray(), "normal", out lstWidths);
                        if (start.Start.ToLower() == positionsAr[i])
                        {
                            string divwidth = string.Format("{0}%", (wrapperwidth).ToString());
                            for (int j = 1; j <= start.Depth; j++)
                            {
                                if (j == 1)
                                {
                                    string wrapstyle = start.Depth > 1 ? string.Format("sfWrap sfInnerwrap{0}{1}", start.Index, start.Class == "" ? "" : string.Format(" {0}", start.Class)) : string.Format("sfWrap sfInnerwrap{0}{1} clearfix", start.Index, start.Class == "" ? "" : string.Format(" {0}", start.Class));
                                    //string floatstyle = divwidth == "100%" ? string.Format("width:{0}", divwidth) : string.Format("width:{0};float:left", divwidth);
                                    //sb.Append("<div style='" + floatstyle + "' class='" + wrapstyle + "'>");
                                    sb.Append("<div class='" + wrapstyle + " " + sfCol + wrapperwidth + "'>");
                                }
                                else
                                {
                                    string multiplewrappers = start.Depth == j?string.Format("sfWrap {0} sf{1} clearfix", start.Class, j) : string.Format("sfWrap {0} sf{1}", start.Class == "" ? "" : string.Format(" {0}", start.Class), j);

                                    //string floatstyle = divwidth == "100%" ? string.Format("width:{0}", divwidth) : string.Format("width:{0};float:left", divwidth);
                                    //sb.Append("<div style='" + floatstyle + "' class='" + multiplewrappers + "'>");
                                    sb.Append("<div class='" + multiplewrappers + " " + sfCol + wrapperwidth + "'>");
                                }
                            }
                        }
                        if (start.LSTPositions.Contains(positionsAr[i]))
                        {
                            int width = Calculator.CalculatePostWrapWidth(start.LSTPositions.ToArray(), positionsAr[i], wrapperwidth, "normal", lstWidths);
                            style = sfCol + width; // Mode == 0 ? string.Format("width:{0}%;float:left", width) : width == 100 ? "float:left" : string.Format("width:{0}%;float:left", width);
                        }
                    }
                }
                string customStyle = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT) == "" ? string.Format("{0}", style) : string.Format("{0};min-height:{1}px", style, Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT));
                if (customStyle != "")
                {
                    string id = string.Format("sf{0}", Utils.UppercaseFirst(positionsAr[i]));
                    if (chkPch)
                    {
                        //sb.Append("<div id=" + id + "  style='" + customStyle + "'>");
                        sb.Append("<div id=" + id + "  class='" + customStyle + "'>");
                    }
                    else
                    {
                        sb.Append("<th id=" + id + " class='" + customStyle + "'>");
                    }
                }
                else
                {
                    string id = string.Format("sf{0}", Utils.UppercaseFirst(positionsAr[i]));
                    //sb.Append("<div id=" + id + " style='" + customStyle + "'>");
                    if (!chkPch)
                    {
                        sb.Append("<th id=" + id + " style='Width=100%' class='sfCol_100'>");
                    }
                    else
                    {
                        sb.Append("<div class='sfCol_100'>");
                    }
                }
                sb.Append(Mode == 2 ? "<div class='sfWrapper'>" : "<div class='sfWrapper sfCurve'>");
                //sb.Append(positionsAr[i]);
                sb.Append(HtmlBuilder.AddPlaceholder(positionsAr[i], Mode));
                sb.Append("</div>");
                if (customStyle != "")
                {
                    if (chkPch)
                    {
                        sb.Append("</div>");
                    }
                    else
                    {
                        sb.Append("</th>");
                    }
                }
                else
                {
                    if (!chkPch)
                    {
                        sb.Append("</th>");
                    }
                    else
                    {
                        sb.Append("</div>");
                    }
                }

                if (arrWidth.Length == i)
                {
                    //sb.Append("<div class='clearfix'></div>");
                }
                foreach (CustomWrapper start in lstWrapper)
                {
                    if (start.End.ToLower() == positionsAr[i] && start.Type == "position")
                    {
                        for (int j = 1; j <= start.Depth; j++)
                        {
                            sb.Append("</div>");
                        }
                    }
                }
            }
            //if (positionsAr.Length > 1)
            // {
            if (chkPch)
            {
                sb.Append("</div>");
            }
            else
            {
                sb.Append("</tr></thead></table>");
            }

            //}
            return(sb.ToString());
        }
示例#15
0
        /// <summary>
        /// Parsing fixed block.
        /// </summary>
        /// <param name="placeholder">Object of XmlTag class.</param>
        /// <param name="lstWrapper">List of CustomWrapper class.</param>
        /// <returns>String format of fixed block markup.</returns>
        public static string ParseFixedBlocks(XmlTag placeholder, List <CustomWrapper> lstWrapper)
        {
            string pchName = string.Format("{0}{1}{2}", "sf", Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.NAME).ToLower(), "_mytable");

            StringBuilder sb        = new StringBuilder();
            string        tableID   = placeholder.PresetName;
            string        positions = placeholder.InnerHtml;

            string[] positionsAr = positions.Split(',');
            double   spotWidth   = 100 / positionsAr.Length;
            string   col         = spotWidth.ToString();
            string   width       = col + "%";
            string   minheight   = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT, "200px");

            if (positionsAr.Length > 1)
            {
                if (Flag)
                {
                    sb.Append(Mode == 2 ? "<div class='sfMoreblocks  clearfix'>" : "<div class='sfMoreblocks sfCurve clearfix'>");
                }
                else
                {
                    sb.Append(Mode == 2 ? "<table id=" + pchName + " class='sfMoreblocks sfFullWidth'><thead><tr>" : "<table id=" + pchName + "  class='sfMoreblocks sfCurve sfFullWidth'><thead><tr>");
                }
            }
            for (int i = 0; i < positionsAr.Length; i++)
            {
                string adjustedWidth = width;
                if (positionsAr.Length % 2 != 0 && i == positionsAr.Length - 1)
                {
                    adjustedWidth = string.Format("{0}%", (int.Parse(width.Replace("%", "")) + 1).ToString());
                }
                string style = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.CLASS);
                if (i == 0)
                {
                    style += " sfFirst";
                }
                if (i == positionsAr.Length - 1)
                {
                    style += " sfLast";
                }
                foreach (CustomWrapper start in lstWrapper)
                {
                    if (start.Type == "position")
                    {
                        List <KeyValue> lstWidths  = new List <KeyValue>();
                        int             totalwidth = Calculator.CalculateWrapperWidth(positionsAr, positionsAr, start.LSTPositions.ToArray(), "fixed", out lstWidths);
                        if (start.Start.ToLower() == positionsAr[i])
                        {
                            string wrapperwidth = string.Format("{0}%", (totalwidth).ToString());
                            for (int j = 1; j <= start.Depth; j++)
                            {
                                if (j == 1)
                                {
                                    string wrapstyle = start.Depth > 1 ? string.Format("sfWrap sfInnerwrap{0}{1}", start.Index, start.Class == "" ? "" : string.Format(" {0}", start.Class)) : string.Format("sfWrap sfInnerwrap{0}{1} clearfix", start.Index, start.Class == "" ? "" : string.Format(" {0}", start.Class));
                                    //sb.Append("<div style='float:left;width:" + wrapperwidth + "' class='" + wrapstyle + "'>");
                                    sb.Append("<div class='" + wrapstyle + " " + sfCol + wrapperwidth + "'>");
                                }
                                else
                                {
                                    string multiplewrappers = start.Depth == j?string.Format("sfWrap {0} sf{1} clearfix", start.Class == ""? "" : string.Format(" {0}", start.Class), j - 1) : string.Format("sfWrap {0} sf{1}", start.Class == "" ? "" : string.Format(" {0}", start.Class), j - 1);

                                    sb.Append("<div class='" + multiplewrappers + "'>");
                                }
                            }
                        }
                        if (start.LSTPositions.Contains(positionsAr[i]))
                        {
                            int fixedWidth = Calculator.CalculatePostWrapWidth(positionsAr, positionsAr[i], totalwidth, "fixed", lstWidths);

                            adjustedWidth = string.Format("{0}%", fixedWidth.ToString());
                        }
                    }
                }
                string customStyle = "";
                if (Flag)
                {
                    customStyle = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT) == "" ? string.Format("float:left;width:{0}", adjustedWidth) : string.Format("float:left;width:{0};min-height:{1}px", adjustedWidth, Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT));
                }
                else
                {
                    customStyle = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT) == "" ? string.Format("width:{0}", adjustedWidth) : string.Format("width:{0};min-height:{1}px", adjustedWidth, Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT));
                }


                //if (customStyle != "")
                //{
                //    string styleClass = string.Format("class='sfFixed{0}'", i + 1);
                //    if (Flag)
                //        sb.Append("<div " + styleClass + " style='" + customStyle + "'>");
                //    else
                //        sb.Append("<th " + styleClass + " style='" + customStyle + "'>");
                //}
                if (customStyle != "")
                {
                    string styleClass = string.Format("class='sfFixed {0}'", sfCol + col);
                    if (Flag)
                    {
                        // sb.Append("<div " + styleClass + " style='" + customStyle + "'>");
                        sb.Append("<div " + styleClass + ">");
                    }
                    else
                    {
                        // sb.Append("<th " + styleClass + " style='" + customStyle + "'>");
                        sb.Append("<th " + styleClass + " class='" + customStyle + "'>");
                    }
                }
                sb.Append(Mode == 2 ? "<div class='sfWrapper'>" : "<div class='sfWrapper sfCurve'>");
                sb.Append(HtmlBuilder.AddPlaceholder(positionsAr[i], Mode));
                sb.Append("</div>");
                if (customStyle != "")
                {
                    if (Flag)
                    {
                        sb.Append("</div>");
                    }
                    else
                    {
                        sb.Append("</th>");
                    }
                }


                foreach (CustomWrapper start in lstWrapper)
                {
                    if (start.End.ToLower() == positionsAr[i] && start.Type == "position")
                    {
                        for (int j = 1; j <= start.Depth; j++)
                        {
                            sb.Append("</div>");
                        }
                    }
                }
            }
            if (positionsAr.Length > 1)
            {
                if (Flag)
                {
                    sb.Append("</div>");
                }
                else
                {
                    sb.Append("</tr></thead></table>");
                }
            }

            return(sb.ToString());
        }
示例#16
0
        public static string ParseFixedBlocks(XmlTag placeholder, List <CustomWrapper> lstWrapper)
        {
            StringBuilder sb        = new StringBuilder();
            string        positions = placeholder.InnerHtml;

            string[] positionsAr = positions.Split(',');
            double   spotWidth   = 100 / positionsAr.Length;
            string   width       = spotWidth.ToString() + "%";
            string   minheight   = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT, "200px");

            if (positionsAr.Length > 1)
            {
                sb.Append("<div class='sfMoreblocks sfCurve clearfix'>");
            }
            for (int i = 0; i < positionsAr.Length; i++)
            {
                string adjustedWidth = width;

                string style = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.CSSCLASS);
                if (i == 0)
                {
                    style += " sfFirst";
                }
                if (i == positionsAr.Length - 1)
                {
                    style += " sfLast";
                }
                foreach (CustomWrapper start in lstWrapper)
                {
                    if (start.Type == "position")
                    {
                        List <KeyValue> lstWidths  = new List <KeyValue>();
                        int             totalwidth = Calculator.CalculateWrapperWidth(positionsAr, positionsAr, start.LSTPositions.ToArray(), "fixed", out lstWidths);
                        if (start.Start.ToLower() == positionsAr[i])
                        {
                            string wrapperwidth = string.Format("{0}%", (totalwidth).ToString());
                            for (int j = 1; j <= start.Depth; j++)
                            {
                                if (j == 1)
                                {
                                    string wrapstyle = start.Depth > 1 ? string.Format("sfWrap sfInnerwrap{0}{1}", start.Index, start.Class == "" ? "" : string.Format(" {0}", start.Class)) : string.Format("sfWrap sfInnerwrap{0}{1} clearfix", start.Index, start.Class == "" ? "" : string.Format(" {0}", start.Class));
                                    sb.Append("<div style='float:left;width:" + wrapperwidth + "' class='" + wrapstyle + "'>");
                                }
                                else
                                {
                                    string multiplewrappers = start.Depth == j?string.Format("sfWrap {0} sf{1} clearfix", start.Class == ""? "" : string.Format(" {0}", start.Class), j - 1) : string.Format("sfWrap {0} sf{1}", start.Class == "" ? "" : string.Format(" {0}", start.Class), j - 1);

                                    sb.Append("<div class='" + multiplewrappers + "'>");
                                }
                            }
                        }
                        if (start.LSTPositions.Contains(positionsAr[i]))
                        {
                            adjustedWidth = string.Format("{0}%", Calculator.CalculatePostWrapWidth(positionsAr, positionsAr[i], totalwidth, "fixed", lstWidths).ToString());
                        }
                    }
                }

                string customStyle = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT) == "" ? string.Format("float:left;width:{0}", adjustedWidth) : string.Format("float:left;width:{0};min-height:{1}px", adjustedWidth, Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT));
                sb.Append("<div style='" + customStyle + "'>");
                sb.Append("<div class='sfWrapper sfCurve'>");
                sb.Append(HtmlBuilder.AddPlaceholder(positionsAr[i], Mode));
                sb.Append("</div></div>");

                foreach (CustomWrapper start in lstWrapper)
                {
                    if (start.End.ToLower() == positionsAr[i] && start.Type == "position")
                    {
                        for (int j = 1; j <= start.Depth; j++)
                        {
                            sb.Append("</div>");
                        }
                    }
                }
            }
            if (positionsAr.Length > 1)
            {
                sb.Append("</div>");
            }

            return(sb.ToString());
        }