示例#1
0
        void UpdatePropertices()
        {
            mChildren.Clear();
            this.Controls.Clear();
            this.Controls.Add(this.TitleButton);

            FieldInfo[] fields = mTarget.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public);

            int h = 0;

            foreach (var field in fields)
            {
                InspectorItem item = InspectorItem.Create(field.FieldType);
                if (item == null)
                {
                    continue;
                }
                this.Controls.Add(item);
                mChildren.Add(item);
                item.Location = new Point(0, h + this.TitleButton.Height);
                item.Target   = this.Target;
                item.Width    = this.Width;
                item.Dock     = DockStyle.Bottom;
                item.Field    = field;
                item.OnInit();
                h += item.Height;
                item.Show();
            }

            mOrignalHeight = this.TitleButton.Height + h;
            this.Size      = new Size(this.Width, mOrignalHeight);
        }
示例#2
0
        public static InspectorItem Create(Type type)
        {
            if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List <>))
            {
                type = typeof(List <>);
            }
            else
            {
                if (type.BaseType == typeof(Enum))
                {
                    type = typeof(Enum);
                }
            }

            Type inspectorItemType;

            if (InspectorItemCreators.TryGetValue(type, out inspectorItemType))
            {
                InspectorItem item = (InspectorItem)inspectorItemType.GetConstructor(Type.EmptyTypes).Invoke(null);
                return(item);
            }
            return(null);
        }