Example #1
0
        private void UpdateAmbientValueFromSceneElement(SceneElement element, PropertyReference propertyReference)
        {
            bool strictTypeCheck = true;
            PropertyReference propertyReference1 = SceneNodeObjectSet.FilterProperty((SceneNode)element, propertyReference, strictTypeCheck);

            if (!element.IsViewObjectValid || propertyReference1 == null || propertyReference1.PlatformMetadata != element.Platform.Metadata)
            {
                return;
            }
            AmbientPropertyManager.AmbientPropertyValue ambientPropertyValue = this.GetAmbientPropertyValue(propertyReference1.FirstStep);
            if (ambientPropertyValue == null)
            {
                return;
            }
            using (element.ViewModel.ForceBaseValue())
            {
                if (element.IsSet(propertyReference1) == PropertyState.Unset)
                {
                    ambientPropertyValue.Value = null;
                }
                else
                {
                    DocumentNodePath valueAsDocumentNode = element.GetLocalValueAsDocumentNode(propertyReference1);
                    if (!this.HasValidValue(element.ViewModel, valueAsDocumentNode))
                    {
                        return;
                    }
                    ambientPropertyValue.Value = valueAsDocumentNode.Node;
                }
            }
        }
Example #2
0
 private object InternalGetAmbientValue(ReferenceStep property, SceneNode targetNode)
 {
     AmbientPropertyManager.AmbientPropertyValue ambientPropertyValue = this.GetAmbientPropertyValue(property);
     if (ambientPropertyValue != null)
     {
         if (ambientPropertyValue.Value == DependencyProperty.UnsetValue)
         {
             return(ambientPropertyValue.DefaultValue);
         }
         DocumentNode node = ambientPropertyValue.Value as DocumentNode;
         if (node == null)
         {
             return(DependencyProperty.UnsetValue);
         }
         if (targetNode == null && (DocumentNodeUtilities.IsStaticResource(node) || DocumentNodeUtilities.IsDynamicResource(node) || DocumentNodeUtilities.IsTemplateBinding(node)))
         {
             return(ambientPropertyValue.DefaultValue);
         }
         DocumentCompositeNode documentCompositeNode = node as DocumentCompositeNode;
         if (DocumentNodeUtilities.IsStaticResource(node) || DocumentNodeUtilities.IsDynamicResource(node))
         {
             DocumentNode resourceKey = ResourceNodeHelper.GetResourceKey(documentCompositeNode);
             bool         flag        = new ExpressionEvaluator((IDocumentRootResolver)targetNode.ProjectContext).EvaluateResource(targetNode.DocumentNodePath, DocumentNodeUtilities.IsStaticResource(node) ? ResourceReferenceType.Static : ResourceReferenceType.Dynamic, resourceKey) != null;
             if (!flag)
             {
                 object instance = targetNode.ViewModel.CreateInstance(new DocumentNodePath(resourceKey, resourceKey));
                 if (instance != null)
                 {
                     flag = targetNode.ViewModel.FindResource(instance) != null;
                 }
             }
             if (!flag)
             {
                 return(ambientPropertyValue.DefaultValue);
             }
         }
         else if (DocumentNodeUtilities.IsTemplateBinding(node))
         {
             ExpressionEvaluator expressionEvaluator = new ExpressionEvaluator((IDocumentRootResolver)targetNode.ProjectContext);
             if (documentCompositeNode == null || expressionEvaluator.EvaluateTemplateBinding(targetNode.DocumentNodePath, documentCompositeNode) == null)
             {
                 return(ambientPropertyValue.DefaultValue);
             }
         }
         return((object)node);
     }
     if (targetNode == null || !object.Equals(ambientPropertyValue.DefaultValue, targetNode.GetDefaultValueAsWpf((IPropertyId)property)))
     {
         return(ambientPropertyValue.DefaultValue);
     }
     return(DependencyProperty.UnsetValue);
 }