コード例 #1
0
        void Grid(List <String> rows)
        {
            var hStyle = new List <UIStyle>();
            var header = rows[1].Trim('|').Split('|');
            var grid   = new List <List <WebMeta> >();
            int flexs  = 0;

            foreach (var h in header)
            {
                var st = new UIStyle();
                var s  = h.Trim();
                if (s.StartsWith(":") && s.EndsWith(":"))
                {
                    st.AlignCenter();
                }
                else if (s.EndsWith(":"))
                {
                    st.AlignRight();
                }
                else
                {
                    st.AlignLeft();
                }
                int flex = s.Split('-').Length - 1;
                st.Name("flex", flex);
                flexs += flex;
                hStyle.Add(st);
            }
            rows.RemoveAt(1);
            foreach (var row in rows)
            {
                var cells = row.Trim('|').Split('|');
                var cdata = new List <WebMeta>();
                for (int i = 0; i < hStyle.Count; i++)
                {
                    var cstyle = new UIStyle();
                    cstyle.Copy(hStyle[i]);
                    this.style    = cstyle;
                    this.data     = new WebMeta();
                    this.dataText = new StringBuilder();
                    if (i < cells.Length)
                    {
                        CheckRow(cells[i].Trim(), 0, false);
                    }
                    if (dataText.Length > 0)
                    {
                        this.data.Put("m" + data.Count.ToString(), dataText.ToString().Trim());
                    }
                    var sb = new StringBuilder();
                    for (int c = 0; c < data.Count; c++)
                    {
                        sb.Append("{m");
                        sb.Append(c);
                        sb.Append("}");
                    }
                    cdata.Add(new WebMeta().Put("format", sb.ToString()).Put("data", this.data).Put("style", this.style));
                }
                grid.Add(cdata);
            }

            var cell = UICell.Create("CMSGrid", new WebMeta().Put("grid", grid).Put("flex", flexs));

            cells.Add(cell);
            data     = new WebMeta();
            style    = new UIStyle();
            dataText = new StringBuilder();
        }