Exemplo n.º 1
0
        public static PropertyValueEditor GetPropertyEditorTemplate(PropertyReferenceProperty property)
        {
            bool                flag                = false;
            IProjectContext     projectContext      = property.ObjectSet.ProjectContext;
            PropertyValueEditor propertyValueEditor = PropertyEditorTemplateLookup.GetPropertyEditorTemplate(projectContext, property.ObjectSet.DesignerContext, property.PropertyTypeId);

            if (propertyValueEditor == PropertyEditorTemplateLookup.ObjectEditorTemplate && property.PropertyValue.CanConvertFromString)
            {
                flag = true;
                propertyValueEditor = (PropertyValueEditor)null;
            }
            SceneNodeProperty sceneNodeProperty = property as SceneNodeProperty;

            if (propertyValueEditor == null)
            {
                if (property.Converter != null && property.Converter.GetPropertiesSupported())
                {
                    return(PropertyEditorTemplateLookup.ObjectEditorTemplate);
                }
                if (sceneNodeProperty != null && UriEditor.IsPropertySupportedOnType((PropertyReferenceProperty)sceneNodeProperty, sceneNodeProperty.SceneNodeObjectSet.ObjectType))
                {
                    DataTemplate inlineEditorTemplate = new DataTemplate();
                    inlineEditorTemplate.VisualTree = new FrameworkElementFactory(typeof(UriEditor));
                    propertyValueEditor             = new PropertyValueEditor(inlineEditorTemplate);
                }
            }
            if (propertyValueEditor == null && !flag)
            {
                IType computedValueTypeId = property.ComputedValueTypeId;
                if (computedValueTypeId != null)
                {
                    propertyValueEditor = PropertyEditorTemplateLookup.GetPropertyEditorTemplate(projectContext, property.ObjectSet.DesignerContext, computedValueTypeId);
                    if (propertyValueEditor is PropertyEditorTemplateLookup.CollectionDialogPropertyValueEditor)
                    {
                        propertyValueEditor = (PropertyValueEditor)null;
                    }
                }
            }
            if (property.IsReadOnly && !(propertyValueEditor is PropertyEditorTemplateLookup.CollectionDialogPropertyValueEditor) && !ProjectNeutralTypes.LayoutPathCollection.IsAssignableFrom((ITypeId)property.PropertyTypeId))
            {
                return((PropertyValueEditor)null);
            }
            if (sceneNodeProperty != null && propertyValueEditor is PropertyEditorTemplateLookup.CollectionDialogPropertyValueEditor)
            {
                bool         isMixed;
                DocumentNode valueAsDocumentNode = sceneNodeProperty.GetLocalValueAsDocumentNode(true, out isMixed);
                if (valueAsDocumentNode != null && valueAsDocumentNode is DocumentPrimitiveNode)
                {
                    return((PropertyValueEditor)null);
                }
                if (property.PropertyTypeId.IsArray && !property.PropertyTypeId.PlatformMetadata.ResolveType(PlatformTypes.ArrayExtension).IsResolvable)
                {
                    return((PropertyValueEditor)null);
                }
            }
            return(propertyValueEditor);
        }
Exemplo n.º 2
0
        public override void OnRebuildComplete(PropertyValue activePropertyValue)
        {
            if (this.transactionHelper != null)
            {
                this.transactionHelper.CommitOutstandingTransactions(0);
            }
            if (this.sceneNodePropertyLookup != null)
            {
                this.sceneNodePropertyLookup.ClearProperties();
                this.sceneNodePropertyLookup.Unhook();
                this.sceneNodePropertyLookup = (SceneNodePropertyLookup)null;
            }
            if (activePropertyValue == null)
            {
                return;
            }
            SceneNodeProperty sceneNodeProperty = (SceneNodeProperty)activePropertyValue.get_ParentProperty();

            this.sceneNodePropertyLookup = new SceneNodePropertyLookup(sceneNodeProperty.SceneNodeObjectSet, sceneNodeProperty.Reference);
            using (IEnumerator <PropertyEntry> enumerator = activePropertyValue.get_SubProperties().GetEnumerator())
            {
                while (((IEnumerator)enumerator).MoveNext())
                {
                    SceneNodeProperty property = enumerator.Current as SceneNodeProperty;
                    if (property != null)
                    {
                        this.sceneNodePropertyLookup.AddProperty(property.Reference, property);
                    }
                }
            }
            bool         isMixed;
            DocumentNode valueAsDocumentNode = sceneNodeProperty.GetLocalValueAsDocumentNode(true, out isMixed);

            SceneNode[] selectedObjects;
            if (valueAsDocumentNode != null)
            {
                selectedObjects = new SceneNode[1]
                {
                    sceneNodeProperty.SceneNodeObjectSet.ViewModel.GetSceneNode(valueAsDocumentNode)
                }
            }
            ;
            else
            {
                selectedObjects = new SceneNode[0];
            }
            foreach (CategoryBase categoryBase in (IEnumerable <CategoryBase>) this.Categories)
            {
                SceneNodeCategory sceneNodeCategory = categoryBase as SceneNodeCategory;
                if (sceneNodeCategory != null)
                {
                    sceneNodeCategory.OnSelectionChanged(selectedObjects);
                }
            }
        }
        public override void OnRebuildComplete(Microsoft.Windows.Design.PropertyEditing.PropertyValue activePropertyValue)
        {
            if (this.transactionHelper != null)
            {
                this.transactionHelper.CommitOutstandingTransactions(0);
            }
            if (this.sceneNodePropertyLookup != null)
            {
                this.sceneNodePropertyLookup.ClearProperties();
                this.sceneNodePropertyLookup.Unhook();
                this.sceneNodePropertyLookup = (SceneNodePropertyLookup)null;
            }
            if (activePropertyValue == null)
            {
                return;
            }
            SceneNodeProperty sceneNodeProperty = (SceneNodeProperty)activePropertyValue.ParentProperty;

            this.sceneNodePropertyLookup = new SceneNodePropertyLookup(sceneNodeProperty.SceneNodeObjectSet, sceneNodeProperty.Reference);
            foreach (PropertyEntry propertyEntry in activePropertyValue.SubProperties)
            {
                SceneNodeProperty property = propertyEntry as SceneNodeProperty;
                if (property != null)
                {
                    this.sceneNodePropertyLookup.AddProperty(property.Reference, property);
                }
            }
            bool         isMixed;
            DocumentNode valueAsDocumentNode = sceneNodeProperty.GetLocalValueAsDocumentNode(true, out isMixed);

            SceneNode[] selectedObjects;
            if (valueAsDocumentNode != null)
            {
                selectedObjects = new SceneNode[1]
                {
                    sceneNodeProperty.SceneNodeObjectSet.ViewModel.GetSceneNode(valueAsDocumentNode)
                }
            }
            ;
            else
            {
                selectedObjects = new SceneNode[0];
            }
            foreach (CategoryBase categoryBase in (IEnumerable <CategoryBase>) this.Categories)
            {
                SceneNodeCategory sceneNodeCategory = categoryBase as SceneNodeCategory;
                if (sceneNodeCategory != null)
                {
                    sceneNodeCategory.OnSelectionChanged(selectedObjects);
                }
            }
        }
        public DataStorePropertyEntry FindMatchDataStorePropertyEntry(SceneNodeProperty property, string propertyName)
        {
            if (property == null)
            {
                return((DataStorePropertyEntry)null);
            }
            bool         isMixed             = false;
            DocumentNode valueAsDocumentNode = property.GetLocalValueAsDocumentNode(false, out isMixed);

            if (valueAsDocumentNode != null && property.SceneNodeObjectSet.ViewModel.IsExternal(valueAsDocumentNode))
            {
                return((DataStorePropertyEntry)null);
            }
            BindingSceneNode bindingSceneNode = property.SceneNodeObjectSet.ViewModel.GetSceneNode(valueAsDocumentNode) as BindingSceneNode;

            if (bindingSceneNode == null)
            {
                return((DataStorePropertyEntry)null);
            }
            string path                = propertyName ?? bindingSceneNode.Path;
            string dataStore           = (string)null;
            DocumentCompositeNode node = bindingSceneNode.Source as DocumentCompositeNode;

            if (node != null && PlatformTypes.StaticResource.IsAssignableFrom((ITypeId)node.Type))
            {
                DocumentPrimitiveNode documentPrimitiveNode = ResourceNodeHelper.GetResourceKey(node) as DocumentPrimitiveNode;
                if (documentPrimitiveNode != null)
                {
                    dataStore = documentPrimitiveNode.GetValue <string>();
                }
            }
            return(Enumerable.FirstOrDefault <DataStorePropertyEntry>(Enumerable.Where <DataStorePropertyEntry>((IEnumerable <DataStorePropertyEntry>) this.Properties, (Func <DataStorePropertyEntry, bool>)(entry =>
            {
                if (entry.Name == path)
                {
                    return entry.DataSetName == dataStore;
                }
                return false;
            }))));
        }
Exemplo n.º 5
0
        public static string GetElementNameFromBoundProperty(SceneNodeProperty property)
        {
            if (property == null || property.SceneNodeObjectSet == null || property.SceneNodeObjectSet.ViewModel == null)
            {
                return((string)null);
            }
            bool             isMixed;
            BindingSceneNode bindingSceneNode = property.SceneNodeObjectSet.ViewModel.GetSceneNode(property.GetLocalValueAsDocumentNode(true, out isMixed)) as BindingSceneNode;

            if (bindingSceneNode == null)
            {
                return((string)null);
            }
            if (!string.IsNullOrEmpty(bindingSceneNode.ElementName))
            {
                if (!string.IsNullOrEmpty(bindingSceneNode.Path))
                {
                    return(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}.{1}", new object[2]
                    {
                        (object)bindingSceneNode.ElementName,
                        (object)bindingSceneNode.Path
                    }));
                }
                return(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}", new object[1]
                {
                    (object)bindingSceneNode.ElementName
                }));
            }
            return(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}", new object[1]
            {
                (object)bindingSceneNode.Path
            }));
        }