Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
0
        static string ParseNormalBlocks(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("<div class='sfMoreblocks sfCurve clearfix'>");
            }
            for (int i = 0; i < positionsAr.Length; i++)
            {
                string style = "";
                if (!fullWidth)
                {
                    if (arrWidth.Length > i)
                    {
                        style += string.Format("width:{0}%;float:left", arrWidth[i]);
                    }
                    else if (i == arrWidth.Length)
                    {
                        style += string.Format("width:{0}%;float:left", Calculator.GetRemainingWidth(arrWidth));
                    }
                }
                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 + "'>");
                                }
                                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 + "'>");
                                }
                            }
                        }
                        if (start.LSTPositions.Contains(positionsAr[i]))
                        {
                            style = string.Format("width:{0}%;float:left", Calculator.CalculatePostWrapWidth(start.LSTPositions.ToArray(), positionsAr[i], wrapperwidth, "normal", lstWidths));
                        }
                    }
                }
                string customStyle = Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT) == "" ? string.Format("{0}", style) : string.Format("{0};min-height:{1}px", style, Utils.GetAttributeValueByName(placeholder, XmlAttributeTypes.MINHEIGHT));

                sb.Append("<div style='" + customStyle + "'>");
                sb.Append("<div class='sfWrapper sfCurve'>");
                //sb.Append(positionsAr[i]);
                sb.Append(HtmlBuilder.AddPlaceholder(positionsAr[i], Mode));
                sb.Append("</div></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());
        }