Esempio n. 1
0
        private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            InspectorPropertyData dataContext = (InspectorPropertyData)this.DataContext;

            this.inspectorFactory = new InspectorFactory(
                dataContext.EditorContext,
                dataContext.EditorContext != null ? dataContext.EditorContext.LocalizationContext : null);

            InspectorPropertyAttribute inspectorProperty = dataContext.InspectorProperty;

            this.itemType = inspectorProperty.AttributeType ?? inspectorProperty.PropertyType.GetGenericArguments()[0];
            this.itemInspectorProperty = inspectorProperty.Clone();
            this.itemInspectorProperty.PropertyType = this.itemType;

            // Set items.
            this.ClearItemControls();

            if (dataContext.Value != null)
            {
                // Backwards compatibility if the attribute was a single item first and
                // changed to a list now.
                IList items = dataContext.Value as IList;
                if (items != null)
                {
                    foreach (var item in items)
                    {
                        this.AddItemControl(item);
                    }
                }
                else
                {
                    this.AddItemControl(dataContext.Value);
                }
            }
        }
Esempio n. 2
0
        private IList GetListToModify()
        {
            // Copy inherited value if necessary.
            IList list;
            InspectorPropertyData dataContext = (InspectorPropertyData)this.DataContext;

            if (dataContext.Value == null || dataContext.ValueInherited)
            {
                list = this.CopyInheritedValue((IList)dataContext.Value);
                dataContext.ValueInherited = false;
                dataContext.Value          = list;
            }
            else
            {
                // Convert value to list if necessary for backwards compatibility.
                list = dataContext.Value as IList;
                if (list == null)
                {
                    IList newList = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(this.itemType));
                    newList.Add(dataContext.Value);
                    list = newList;
                    dataContext.Value = list;
                }
            }
            return(list);
        }
Esempio n. 3
0
        private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            InspectorPropertyData  dataContext            = (InspectorPropertyData)this.DataContext;
            InspectorDataAttribute inspectorDataAttribute = (InspectorDataAttribute)dataContext.InspectorProperty;

            this.value            = (IAttributeTable)dataContext.Value;
            this.inspectorFactory = new InspectorFactory(dataContext.EditorContext, null);

            InspectorType typeInfo = InspectorType.GetInspectorType(inspectorDataAttribute.PropertyType);

            this.inspectorFactory.AddInspectorControls(typeInfo, this.Controls, this.GetPropertyValue, this.OnPropertyValueChanged, false);
        }
Esempio n. 4
0
        private void OnPropertyValueChanged(InspectorPropertyAttribute inspectorProperty, object newValue)
        {
            if (this.value == null)
            {
                this.value = new AttributeTable();
            }

            this.value.SetValue(inspectorProperty.Name, newValue);

            InspectorPropertyData dataContext = (InspectorPropertyData)this.DataContext;

            dataContext.Value = this.value;
        }
Esempio n. 5
0
        private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            InspectorPropertyData dataContext = (InspectorPropertyData)this.DataContext;

            this.inspectorFactory = new InspectorFactory(
                dataContext.EditorContext,
                dataContext.EditorContext != null ? dataContext.EditorContext.LocalizationContext : null);

            EntityConfiguration entityConfiguration = (EntityConfiguration)this.Value;

            if (entityConfiguration != null)
            {
                // Select correct blueprint view model.
                this.CbBlueprint.SelectedBlueprintId = entityConfiguration.BlueprintId;
            }

            this.UpdateAttributeTable();
        }