Beispiel #1
0
        void BuildRow(RowDescriptor row)
        {
            row.Spacing(HorizontalSpacing);

            var elements      = GetRowElements().ToList();
            var columnsWidth  = elements.Sum(x => x.Columns);
            var emptySpace    = ColumnsCount - columnsWidth;
            var hasEmptySpace = emptySpace >= Size.Epsilon;

            if (Alignment == HorizontalAlignment.Center)
            {
                emptySpace /= 2;
            }

            if (hasEmptySpace && Alignment != HorizontalAlignment.Left)
            {
                row.RelativeItem(emptySpace);
            }

            elements.ForEach(x => row.RelativeItem(x.Columns).Element(x.Child));

            if (hasEmptySpace && Alignment != HorizontalAlignment.Right)
            {
                row.RelativeItem(emptySpace);
            }
        }
Beispiel #2
0
        public static void Row(this IContainer element, Action <RowDescriptor> handler)
        {
            var descriptor = new RowDescriptor();

            handler(descriptor);
            element.Element(descriptor.Row);
        }
Beispiel #3
0
 internal PropertyDescriptorCollection GetRowPropertyDescriptors()
 {
     if (this.m_cache == null)
     {
         PropertyDescriptor[] properties = new PropertyDescriptor[this.Names.Length];
         for (int i = 0; i < this.Names.Length; i++)
         {
             properties[i] = new RowDescriptor(this.Names[i]);
         }
         this.m_cache = new PropertyDescriptorCollection(properties);
     }
     return(this.m_cache);
 }
Beispiel #4
0
 internal PropertyDescriptorCollection GetRowPropertyDescriptors()
 {
     if (this.m_cache == null)
     {
         PropertyDescriptor[] properties = new PropertyDescriptor[this.Names.Length];
         for (int i = 0; i < this.Names.Length; i++)
         {
             properties[i] = new RowDescriptor(this.Names[i]);
         }
         this.m_cache = new PropertyDescriptorCollection(properties);
     }
     return this.m_cache;
 }
        /// <summary>
        /// 生成默认视图
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public (Domain.QueryView DefaultView, List <Dependency.Domain.Dependency> Dependents) Get(Schema.Domain.Entity entity, List <Schema.Domain.Attribute> attributes)
        {
            Domain.QueryView view = new Domain.QueryView
            {
                Name        = entity.LocalizedName,
                EntityId    = entity.EntityId,
                EntityName  = entity.Name,
                IsDefault   = true,
                StateCode   = Core.RecordState.Enabled,
                IsPrivate   = false,
                QueryViewId = Guid.NewGuid(),
                CreatedBy   = entity.CreatedBy
            };
            //fetch
            QueryExpression _queryExpression = new QueryExpression(entity.Name, _appContext.GetFeature <ICurrentUser>().UserSettings.LanguageId);

            _queryExpression.Distinct = false;
            _queryExpression.NoLock   = true;
            _queryExpression.AddOrder("createdon", OrderType.Descending);
            var primaryField = attributes.Find(n => n.IsPrimaryField);

            _queryExpression.ColumnSet = new ColumnSet(primaryField.Name.ToLower(), "createdon");
            if (entity.EntityMask == EntityMaskEnum.User)
            {
                _queryExpression.ColumnSet.AddColumn("ownerid");
            }
            view.FetchConfig = _queryExpression.SerializeToJson();
            //layout
            GridDescriptor grid = new GridDescriptor();
            RowDescriptor  row  = new RowDescriptor();

            row.AddCell(new CellDescriptor()
            {
                Name = primaryField.Name.ToLower(), EntityName = entity.Name, IsHidden = false, IsSortable = true, Width = 150
            });
            row.AddCell(new CellDescriptor()
            {
                Name = "createdon", EntityName = entity.Name, IsHidden = false, IsSortable = true, Width = 150
            });
            if (entity.EntityMask == EntityMaskEnum.User)
            {
                row.AddCell(new CellDescriptor()
                {
                    Name = "ownerid", EntityName = entity.Name, IsHidden = false, IsSortable = true, Width = 150
                });
            }
            grid.AddRow(row);
            grid.AddSort(new QueryColumnSortInfo("createdon", false));
            view.LayoutConfig = grid.SerializeToJson(false);

            var dependents = new List <Dependency.Domain.Dependency>();

            foreach (var item in attributes.Where(x => x.Name.IsCaseInsensitiveEqual(primaryField.Name) || x.Name.IsCaseInsensitiveEqual("createdon") || x.Name.IsCaseInsensitiveEqual("ownerid")))
            {
                var dp = new Dependency.Domain.Dependency();
                //dp.DependentComponentType = DependencyComponentTypes.Get(QueryViewDefaults.ModuleName);
                dp.DependentObjectId = view.QueryViewId;
                //dp.RequiredComponentType = DependencyComponentTypes.Get(AttributeDefaults.ModuleName);
                dp.RequiredObjectId = item.AttributeId;
                dependents.Add(dp);
            }
            return(view, dependents);
        }
Beispiel #6
0
        private void ParceMap(TextAsset textAss)
        {
            string text = textAss.ToString();

            string[]   lines  = text.Split('\n');
            string[][] tokens = new string[lines.Length][];
            for (int li = 0; li < lines.Length; li++)
            {
                string[] lineTokens = lines[li].Split(',');
                for (int i = 0; i < lineTokens.Length; i++)
                {
                    lineTokens[i] = lineTokens[i].Trim();
                }
                tokens[li] = lineTokens;
            }
            int             rowCount       = 0;
            int             maxColumnCount = 0;
            List <string[]> gridTmp        = new List <string[]>();

            for (int li = 0; li < lines.Length; li++)
            {
                string[] lineTokens = tokens[li];
                switch (lineTokens[0])
                {
                case "type":
                    Debug.Log(lineTokens[0]);
                    break;

                default:
                    rowCount++;
                    maxColumnCount = Mathf.Max(maxColumnCount, lineTokens.Length);
                    gridTmp.Add(lineTokens);
                    break;
                }
            }
            rows = new RowDescriptor[rowCount];
            for (int i = 0; i < rowCount; i++)
            {
                rows[i]       = new RowDescriptor();
                rows[i].cells = new CellDescriptor[maxColumnCount];
                for (int j = 0; j < maxColumnCount; j++)
                {
                    CellType type = CellType.EMPTY;
                    if (gridTmp[i].Length > j)
                    {
                        string attr = gridTmp[i][j];
                        foreach (char a in attr)
                        {
                            if (Enum.IsDefined(typeof(CellType), (int)a))
                            {
                                type = (CellType)(int)a;
                            }
                        }
                    }

                    rows[i].cells[j] = new CellDescriptor()
                    {
                        type = type, x = j, y = i
                    };
                }
            }
        }