/// <summary>
        /// Converts this attribute to a Dextop container.
        /// </summary>
        /// <param name="memberName">Name of the member.</param>
        /// <param name="memberType">Type of the member.</param>
        /// <returns></returns>
        public virtual DextopFormContainer ToContainer(String memberName, Type memberType)
        {
            var res = new DextopFormContainer
            {
                xtype         = xtype,
                itemId        = itemId,
                title         = title,
                layout        = layout,
                margins       = margins,
                fieldDefaults = fieldDefaults,
                defaults      = defaults,
                Level         = Level,
                style         = style,
                bodyStyle     = bodyStyle,
                border        = NullableUtil.DefaultNull(border, true),
                autoHeight    = autoHeight,
                PrependItems  = PrependItems,
                AppendItems   = AppendItems,
                Raw           = RawJS,
                anchor        = anchor,
                flex          = NullableUtil.DefaultNull(flex, 0),
                columnWidth   = NullableUtil.DefaultNull(columnWidth, 0),
                width         = NullableUtil.DefaultNull(width, 0),
            };

            if (this is IDextopFormLabelable)
            {
                res.ApplyLabelable((IDextopFormLabelable)this);
            }
            return(res);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Converts this attribute to a Dextop container.
        /// </summary>
        /// <param name="memberName">Name of the member.</param>
        /// <param name="memberType">Type of the member.</param>
        /// <returns></returns>
        public override DextopFormContainer ToContainer(string memberName, Type memberType)
        {
            DextopFormContainer container = base.ToContainer(memberName, memberType);

            if (!allowBlank)
            {
                container["allowBlank"] = allowBlank;
            }
            if (vertical)
            {
                container["vertical"] = vertical;
            }
            if (columns > 0)
            {
                container["columns"] = columns;
            }
            else if (columnWidths != null)
            {
                container["columns"] = columnWidths;
            }
            if (fieldLabel != null)
            {
                container["fieldLabel"] = fieldLabel;
            }
            return(container);
        }
Exemplo n.º 3
0
        public static IList <DextopFormObject> BuildForm(Type type)
        {
            var attributes = new List <Tuple <String, Type, MemberInfo, DextopFormFieldAttribute> >();
            var properties = type.GetProperties();

            foreach (var p in properties)
            {
                DextopFormFieldAttribute att;
                if (AttributeHelper.TryGetAttribute <DextopFormFieldAttribute>(p, out att, false))
                {
                    attributes.Add(Tuple.Create(p.Name, p.PropertyType, (MemberInfo)p, att));
                }
            }

            foreach (var p in type.GetFields())
            {
                DextopFormFieldAttribute att;
                if (AttributeHelper.TryGetAttribute <DextopFormFieldAttribute>(p, out att, false))
                {
                    attributes.Add(Tuple.Create(p.Name, p.FieldType, (MemberInfo)p, att));
                }
            }

            var root = new DextopFormContainer
            {
                Level = int.MinValue
            };

            var cstack = new Stack <DextopFormContainer>();

            cstack.Push(root);

            //stable sort
            foreach (var field in attributes.OrderBy(a => a.Item4.Order))
            {
                var containers = AttributeHelper.GetCustomAttributes <DextopFormContainerAttribute>(field.Item3, false).OrderBy(a => a.Level).Select(a => a.ToContainer(field.Item1, field.Item2)).ToArray();
                foreach (var container in containers)
                {
                    while (cstack.Peek().Level >= container.Level)
                    {
                        cstack.Pop();
                    }

                    if (!container.Hollow)
                    {
                        cstack.Peek().Items.Add(container);
                        cstack.Push(container);
                    }
                }
                if (!field.Item4.Dummy)
                {
                    foreach (var f in field.Item4.ToFields(field.Item1, field.Item2))
                    {
                        cstack.Peek().Items.Add(f);
                    }
                }
            }

            return(root.Items);
        }
Exemplo n.º 4
0
        public static IList<DextopFormObject> BuildForm(Type type)
        {
			var attributes = new List<Tuple<String, Type, MemberInfo, DextopFormFieldAttribute>>();
            var properties = type.GetProperties();
            foreach (var p in properties)
            {
                DextopFormFieldAttribute att;				
                if (AttributeHelper.TryGetAttribute<DextopFormFieldAttribute>(p, out att, false))
                    attributes.Add(Tuple.Create(p.Name, p.PropertyType, (MemberInfo)p, att));
                
            }
            
            foreach (var p in type.GetFields())
            {
                DextopFormFieldAttribute att;				
				if (AttributeHelper.TryGetAttribute<DextopFormFieldAttribute>(p, out att, false))
					attributes.Add(Tuple.Create(p.Name, p.FieldType, (MemberInfo)p, att));
            }

            var root = new DextopFormContainer
            {
                Level = int.MinValue
            };

            var cstack = new Stack<DextopFormContainer>();
            cstack.Push(root);

            //stable sort
            foreach (var field in attributes.OrderBy(a => a.Item4.Order))
            {
				var containers = AttributeHelper.GetCustomAttributes<DextopFormContainerAttribute>(field.Item3, false).OrderBy(a => a.Level).Select(a => a.ToContainer(field.Item1, field.Item2)).ToArray();                
                foreach (var container in containers)
                {
                    while (cstack.Peek().Level >= container.Level)
                        cstack.Pop();

					if (!container.Hollow)
					{
						cstack.Peek().Items.Add(container);
						cstack.Push(container);
					}
                }
				if (!field.Item4.Dummy)
				{
					foreach (var f in field.Item4.ToFields(field.Item1, field.Item2))
						cstack.Peek().Items.Add(f);
				}
            }

            return root.Items;
        }
        /// <summary>
        /// Converts this attribute to a Dextop container.
        /// </summary>
        /// <param name="memberName">Name of the member.</param>
        /// <param name="memberType">Type of the member.</param>
        /// <returns></returns>
        public override DextopFormContainer ToContainer(string memberName, Type memberType)
        {
            DextopFormContainer container = base.ToContainer(memberName, memberType);

            if (checkboxToggle)
            {
                container["checkboxToggle"] = checkboxToggle;
                container["checkboxName"]   = checkboxName ?? memberName;
            }
            if (collapsed)
            {
                container["collapsed"] = collapsed;
            }
            if (collapsible)
            {
                container["collapsible"] = collapsible;
            }
            return(container);
        }
        /// <summary>
        /// Converts this attribute to a Dextop container.
        /// </summary>
        /// <param name="memberName">Name of the member.</param>
        /// <param name="memberType">Type of the member.</param>		
        /// <returns></returns>
        public virtual DextopFormContainer ToContainer(String memberName, Type memberType)
        {
            var res = new DextopFormContainer
            {
                xtype = xtype,
                itemId = itemId,
                title = title,
                layout = layout,
                margins = margins,
                fieldDefaults = fieldDefaults,
                defaults = defaults,
                Level = Level,
                style = style,
                bodyStyle = bodyStyle,
                border = NullableUtil.DefaultNull(border, true),
                autoHeight = autoHeight,
                PrependItems = PrependItems,
                AppendItems = AppendItems,
                Raw = RawJS,
                anchor = anchor,
                flex = NullableUtil.DefaultNull(flex, 0),
                columnWidth = NullableUtil.DefaultNull(columnWidth, 0),
                width = NullableUtil.DefaultNull(width, 0),

            };
            if (this is IDextopFormLabelable)
                res.ApplyLabelable((IDextopFormLabelable)this);
            return res;
        }