Exemple #1
0
    public override void Create_Table(PUGameObject container, TableSpec spec)
    {
        float margin = DefaultFontSize();

        currentY -= paragraphSpacing();

        float savedY = currentY;

        PUGridLayoutGroup tableGroup = new PUGridLayoutGroup();

        tableGroup.SetFrame(padding.left + 2, currentY, container.size.Value.x, 100, 0, 1, "top,left");
        tableGroup.LoadIntoPUGameObject(container);

        // Fill out the group, then figure out the height / widths needed based upon the content
        float maxCellWidth  = 0;
        float maxCellHeight = 0;
        int   numberOfCols  = 0;
        int   numberOfRows  = 0;

        if (spec.Headers != null)
        {
            for (int i = 0; i < spec.Headers.Count; i++)
            {
                string          header    = spec.Headers [i];
                ColumnAlignment alignment = spec.Columns [i];

                TMPro.TextAlignmentOptions tmAlignment = TMPro.TextAlignmentOptions.Left;
                if (alignment == ColumnAlignment.Right)
                {
                    tmAlignment = TMPro.TextAlignmentOptions.Right;
                }
                if (alignment == ColumnAlignment.Center)
                {
                    tmAlignment = TMPro.TextAlignmentOptions.Center;
                }

                PUTMPro text = AddTextWithOptions(tableGroup, header, DefaultFont(), textColor(), 1.0f, "Bold", tmAlignment);
                Vector2 size = text.rectTransform.sizeDelta + new Vector2(margin * 2.0f, margin);

                text.rectTransform.pivot     = Vector2.zero;
                text.rectTransform.anchorMax = Vector2.one;
                text.rectTransform.anchorMin = Vector2.zero;

                PutTextInBox(tableGroup, text, 2, new Color32(204, 204, 204, 255), new Color32(255, 255, 255, 255));
                text.SetStretchStretch(margin * 0.5f, margin, margin * 0.5f, margin);

                if (size.x > maxCellWidth)
                {
                    maxCellWidth = size.x;
                }
                if (size.y > maxCellHeight)
                {
                    maxCellHeight = size.y;
                }
            }
        }

        numberOfCols = spec.Rows[0].Count;
        numberOfRows = spec.Rows.Count;

        if (spec.Headers != null && spec.Headers.Count > 0)
        {
            numberOfRows++;
        }

        for (int i = 0; i < spec.Rows.Count; i++)
        {
            List <string> rows = spec.Rows[i];

            for (int j = 0; j < rows.Count; j++)
            {
                string row = rows[j];

                ColumnAlignment alignment = spec.Columns[j];

                TMPro.TextAlignmentOptions tmAlignment = TMPro.TextAlignmentOptions.Left;
                if (alignment == ColumnAlignment.Right)
                {
                    tmAlignment = TMPro.TextAlignmentOptions.Right;
                }
                if (alignment == ColumnAlignment.Center)
                {
                    tmAlignment = TMPro.TextAlignmentOptions.Center;
                }


                PUTMPro text = AddTextWithOptions(tableGroup, row, DefaultFont(), textColor(), 1.0f, "Normal", tmAlignment);
                Vector2 size = text.rectTransform.sizeDelta + new Vector2(margin * 2.0f, margin);

                text.rectTransform.pivot     = Vector2.zero;
                text.rectTransform.anchorMax = Vector2.one;
                text.rectTransform.anchorMin = Vector2.zero;

                if (i % 2 != 0)
                {
                    PutTextInBox(tableGroup, text, 2, new Color32(204, 204, 204, 255), new Color32(248, 248, 248, 255));
                }
                else
                {
                    PutTextInBox(tableGroup, text, 2, new Color32(204, 204, 204, 255), new Color32(255, 255, 255, 255));
                }
                text.SetStretchStretch(margin * 0.5f, margin, margin * 0.5f, margin);

                if (size.x > maxCellWidth)
                {
                    maxCellWidth = size.x;
                }
                if (size.y > maxCellHeight)
                {
                    maxCellHeight = size.y;
                }
            }
        }

        tableGroup.layout.cellSize         = new Vector2(maxCellWidth, maxCellHeight);
        tableGroup.rectTransform.sizeDelta = new Vector2(maxCellWidth * numberOfCols, maxCellHeight * numberOfRows);
        currentY = savedY - tableGroup.rectTransform.sizeDelta.y;
    }
Exemple #2
0
        TableSpec Parse(string str)
        {
            var s = new StringScanner(str);

            return(TableSpec.Parse(s));
        }
        internal static void AddExpandRelation(this ODataTranslatorParser parser, string name, Dictionary <string, string> props)
        {
            if (parser.tableSpec.Relations == null)
            {
                throw new System.Exception("Relations are not specified in the table.");
            }
            if (!parser.tableSpec.Relations.ContainsKey(name))
            {
                throw new System.Exception("Relation " + name + " is not found in the table.");
            }
            TableSpec relation = parser.tableSpec.Relations[name];
            QuerySpec s        = null;

            if (props != null && props.Count > 0)
            {
                var top  = -1;
                var skip = -1;
                if ((props.ContainsKey("top") && props["top"] != null)
                    ||
                    (props.ContainsKey("skip") && props["skip"] != null)) // recover actual value that lexer sanitized and replaced with parameter.
                {
                    foreach (var p in parser.querySpec.parameters)
                    {
                        if (props.ContainsKey("top") && props["top"] != null && p.ParameterName == props["top"])
                        {
                            top = System.Convert.ToInt16(p.Value);
                        }
                        if (props.ContainsKey("skip") && props["skip"] != null && p.ParameterName == props["skip"])
                        {
                            skip = System.Convert.ToInt16(p.Value);
                        }

                        // if top is not provided or already set and if $skip is not provided or already set, skip the further search.
                        if ((!props.ContainsKey("top") || props["top"] == null || top != -1)
                            &&
                            (!props.ContainsKey("skip") || props["skip"] == null || skip != -1))
                        {
                            break;
                        }
                    }
                }
                s = new QuerySpec()
                {
                    select    = props.ContainsKey("select") ? props["select"] : relation.columnList,
                    top       = top,
                    skip      = skip,
                    predicate = props.ContainsKey("filter") ? relation.primaryKey + " AND (" + props["filter"] + ")": relation.primaryKey
                };

                if (props.ContainsKey("orderBy"))
                {
                    s.order = new System.Collections.Hashtable();
                    s.order.Add(props["orderBy"], "");
                }
            }
            else
            {
                s = new QuerySpec()
                {
                    select    = relation.columnList,
                    predicate = relation.primaryKey
                }
            };
            parser.Relations.Add(name, s);
        }
        public static QuerySpec Parse(TableSpec tabSpec, HttpRequest Request)
        {
            if (_log == null)
            {
                _log = StartUp.GetLogger <RequestHandler>();
            }

            var spec = new QuerySpec();

            if (Request.Query["$format"].Count == 1 && Request.Query["$format"].ToString().ToLower() != "json")
            {
                if (_log != null)
                {
                    _log.ErrorFormat("Unsupported {parameter} {value} provided to {type} Uri parser", "$format", Request.Query["$format"], "OData");
                }
                throw new ArgumentException("Parameter $format is not supported.");
            }
            foreach (var p in Request.Query.Keys)
            {
                if (p.StartsWith("$") &&
                    !(p == "$select" || p == "$orderby" || p == "$format" ||
                      p == "$apply" || p == "$systemat" ||
                      p == "$top" || p == "$skip" ||
                      p == "$filter" || p == "$search" ||
                      p == "$expand"))
                {
                    if (_log != null)
                    {
                        _log.ErrorFormat("Unsupported {parameter} {value} provided to {type} Uri parser", p, Request.Query[p], "OData");
                    }
                    throw new ArgumentException("Parameter " + p + " is not supported.");
                }
            }
            spec.count = Request.Path.Value.EndsWith("/$count");
            if (Request.Query.ContainsKey("$skip"))
            {
                spec.skip = Convert.ToInt32(Request.Query["$skip"]);
            }
            if (Request.Query.ContainsKey("$top"))
            {
                spec.top = Convert.ToInt32(Request.Query["$top"]);
            }
            spec.select = Request.Query["$select"];
            ParseExpand(Request.Query["$expand"], spec, tabSpec);
            spec.keyword = Request.Query["$search"];
            ParseSearch(Request.Query["$filter"], spec, tabSpec);
            ParseGroupBy(Request.Query["$apply"], spec, tabSpec);
            ParseOrderBy(tabSpec, Request.Query["$orderby"], spec);
            if (Request.Query.ContainsKey("$systemat"))
            {
                spec.systemTimeAsOf = Request.Query["$systemat"];
                DateTime asof;
                if (!DateTime.TryParse(spec.systemTimeAsOf, out asof))
                {
                    if (_log != null)
                    {
                        _log.ErrorFormat("Invalid date {value} provided as {parameter} in {type} Uri parser", spec.systemTimeAsOf, "$systemat", "OData");
                    }
                    throw new ArgumentException(spec.systemTimeAsOf + " is not valid date.");
                }
            }

            tabSpec.Validate(spec);
            return(spec);
        }
        public async Task OData()
        {
            var tableSpec = new TableSpec("Application", "People", "PersonID,FullName,PhoneNumber");

            await this.OData(tableSpec, queryService).Process();
        }
Exemple #6
0
 public virtual void Create_Table(PUGameObject container, TableSpec table)
 {
 }