예제 #1
0
 protected bool DoesStyleOrTemplateApply(IPropertyId styleOrTemplateProperty, DocumentNode value)
 {
     if (PlatformTypes.FrameworkElement.IsAssignableFrom((ITypeId)this.Type))
     {
         IType templateTargetType1 = DocumentNodeUtilities.GetStyleOrTemplateTargetType(value);
         Type  type = templateTargetType1 != null ? templateTargetType1.RuntimeType : (Type)null;
         Type  c    = this.TargetElement.ProjectContext.MetadataFactory.GetMetadata(this.Type.RuntimeType).GetStylePropertyTargetType(styleOrTemplateProperty);
         if (type == (Type)null)
         {
             return(true);
         }
         if (StyleNode.BasedOnProperty.Equals((object)styleOrTemplateProperty))
         {
             StyleNode styleNode = this.TargetElement as StyleNode;
             if (styleNode != null)
             {
                 IType templateTargetType2 = DocumentNodeUtilities.GetStyleOrTemplateTargetType(styleNode.DocumentNode);
                 c = templateTargetType2 != null ? templateTargetType2.RuntimeType : (Type)null;
             }
         }
         if (c == (Type)null && ControlStylingOperations.DoesPropertyAffectRoot((IPropertyId)this.TargetProperty))
         {
             c = this.Type.RuntimeType;
         }
         if (c != (Type)null && !type.IsAssignableFrom(c))
         {
             return(false);
         }
     }
     return(true);
 }
예제 #2
0
 public static bool DoesPropertyApply(SceneNode sceneNode, ReferenceStep referenceStep, SceneNode valueNode, out ReferenceStep appliedReferenceStep)
 {
     appliedReferenceStep = sceneNode.DesignerContext.PropertyManager.FilterProperty(sceneNode, referenceStep);
     if (appliedReferenceStep == null)
     {
         return(false);
     }
     if (DocumentNodeUtilities.IsStyleOrTemplate(appliedReferenceStep.PropertyType))
     {
         DocumentNode node = valueNode.DocumentNode;
         if (node.Type.IsExpression)
         {
             node = new ExpressionEvaluator(sceneNode.ViewModel.DocumentRootResolver).EvaluateExpression(sceneNode.DocumentNodePath, valueNode.DocumentNode);
         }
         if (node == null || !DocumentNodeUtilities.IsStyleOrTemplate(node.Type) || !appliedReferenceStep.PropertyType.IsAssignableFrom((ITypeId)node.Type))
         {
             return(false);
         }
         IType templateTargetType = DocumentNodeUtilities.GetStyleOrTemplateTargetType(node);
         Type  propertyTargetType = sceneNode.Metadata.GetStylePropertyTargetType((IPropertyId)appliedReferenceStep);
         if (templateTargetType != null && propertyTargetType != (Type)null && !templateTargetType.RuntimeType.IsAssignableFrom(propertyTargetType))
         {
             return(false);
         }
     }
     return(true);
 }
예제 #3
0
        protected bool BindsTwoWayByDefault(SceneNode targetNode, ReferenceStep targetProperty)
        {
            DependencyPropertyReferenceStep propertyReferenceStep = targetProperty as DependencyPropertyReferenceStep;

            if (propertyReferenceStep == null)
            {
                return(false);
            }
            Type targetType = targetNode.TargetType;

            if (DocumentNodeUtilities.IsStyleOrTemplate(targetNode.Type))
            {
                targetType = DocumentNodeUtilities.GetStyleOrTemplateTargetType(targetNode.DocumentNode).RuntimeType;
            }
            return(propertyReferenceStep.BindsTwoWayByDefault(targetType));
        }