Ejemplo n.º 1
0
        public void AddPropertyFields(string headerText = null)
        {
            if (DataObject == null) return;
            ContentItems.Clear();
            var ps = DataObject.GetPropertiesWithAttribute<InspectorProperty>().ToArray();
            if (ps.Length < 1) return;

            if (!string.IsNullOrEmpty(headerText))
                ContentItems.Add(new SectionHeaderViewModel()
                {
                    Name = headerText,
                });
            var data = DataObject;
            foreach (var property in ps)
            {
                PropertyInfo property1 = property.Key;
                var vm = new PropertyFieldViewModel()
                {
                    Type = property.Key.PropertyType,
                    Name = property.Key.Name,
                    InspectorType = property.Value.InspectorType,
                    CustomDrawerType = property.Value.CustomDrawerType,
                    Getter = () => property1.GetValue(data, null),
                    DataObject = data,
                    Setter = (d,v) =>
                    {

                        property1.SetValue(d, v, null);

                    }
                };
                ContentItems.Add(vm);
            }
            IsDirty = true;
        }
Ejemplo n.º 2
0
        public void AddPropertyFields(string headerText = null)
        {
            var ps = GraphItem.GetPropertiesWithAttribute <NodeProperty>().ToArray();

            if (ps.Length < 1)
            {
                return;
            }

            if (!string.IsNullOrEmpty(headerText))
            {
                ContentItems.Add(new SectionHeaderViewModel()
                {
                    Name = headerText,
                });
            }

            foreach (var property in ps)
            {
                PropertyInfo property1 = property.Key;
                var          vm        = new PropertyFieldViewModel(this)
                {
                    Type             = property.Key.PropertyType,
                    Name             = property.Key.Name,
                    InspectorType    = property.Value.InspectorType,
                    CustomDrawerType = property.Value.CustomDrawerType,
                    Getter           = () => property1.GetValue(GraphItem, null),
                    DataObject       = GraphItem,
                    DisableInputs    = true,
                    DisableOutputs   = true,
                    Setter           = (d, v) =>
                    {
                        property1.SetValue(d, v, null);
                    }
                };
                ContentItems.Add(vm);
            }
        }