public AnimationSceneNode GetAnimation(SceneNode targetElement, PropertyReference targetProperty)
        {
            if (targetElement == null || targetProperty == null)
            {
                return((AnimationSceneNode)null);
            }
            StyleNode styleNode = targetElement as StyleNode;

            if (styleNode != null)
            {
                BaseFrameworkElement targetElement1 = styleNode.TargetElement;
            }
            PropertyReference propertyReference = targetProperty;

            if (propertyReference == null)
            {
                return((AnimationSceneNode)null);
            }
            string path = propertyReference.Path;

            foreach (TimelineSceneNode timelineSceneNode in (IEnumerable <TimelineSceneNode>) this.Children)
            {
                AnimationSceneNode animationSceneNode = timelineSceneNode as AnimationSceneNode;
                if (animationSceneNode != null)
                {
                    TimelineSceneNode.PropertyNodePair elementAndProperty = animationSceneNode.TargetElementAndProperty;
                    if (elementAndProperty.SceneNode == targetElement && elementAndProperty.PropertyReference != null && (elementAndProperty.PropertyReference.Path == path && !AnimationProxyManager.IsOptimizedAnimation((TimelineSceneNode)animationSceneNode)))
                    {
                        return(animationSceneNode);
                    }
                }
            }
            return((AnimationSceneNode)null);
        }
Ejemplo n.º 2
0
        public static bool IsDefaultValue(DocumentNode node)
        {
            DocumentCompositeNode documentCompositeNode = node as DocumentCompositeNode;

            if (documentCompositeNode != null)
            {
                return(documentCompositeNode.GetValue <bool>(DesignTimeProperties.IsDefaultStyleProperty));
            }
            return(StyleNode.IsReferenceValue(node));
        }
Ejemplo n.º 3
0
 protected override object GetLocalValueInternal(PropertyReference propertyReference)
 {
     if (propertyReference.ReferenceSteps[0].Equals((object)BaseFrameworkElement.StyleProperty))
     {
         StyleNode style = this.Style;
         if (style != null && StyleNode.IsDefaultValue(style.DocumentNode))
         {
             return((object)null);
         }
     }
     return(base.GetLocalValueInternal(propertyReference));
 }
Ejemplo n.º 4
0
        private void RecacheTargetProperty(SceneNode targetElement)
        {
            if (this.cachedTargetAvalonElement != targetElement || (int)this.cachedChangeStamp != (int)this.ViewModel.ChangeStamp)
            {
                this.RecacheTargetElement();
            }
            object    localOrDefaultValue = this.GetLocalOrDefaultValue(StoryboardTimelineSceneNode.TargetPropertyProperty);
            StyleNode styleNode           = this.cachedTargetAvalonElement as StyleNode;
            SceneNode pathRoot            = styleNode != null ? (SceneNode)styleNode.TargetElement : this.cachedTargetAvalonElement;

            this.cachedTargetAvalonProperty = TimelineSceneNode.ResolvePropertyPath(this.DocumentContext.TypeResolver, this.Platform.ViewObjectFactory.Instantiate(localOrDefaultValue), pathRoot);
        }
Ejemplo n.º 5
0
        public virtual StyleNode ExpandDefaultStyle(IPropertyId propertyKey)
        {
            propertyKey = (IPropertyId)this.ProjectContext.ResolveProperty(propertyKey);
            if (this.IsSet(BaseFrameworkElement.StyleProperty) == PropertyState.Set)
            {
                return((StyleNode)null);
            }
            DocumentNode nodeForDefaultStyle = this.GetDocumentNodeForDefaultStyle(this.Type, propertyKey);
            StyleNode    styleNode1          = (StyleNode)null;

            if (nodeForDefaultStyle != null)
            {
                if (!StyleNode.IsReferenceValue(nodeForDefaultStyle))
                {
                    StyleNode styleNode2 = (StyleNode)this.ViewModel.GetSceneNode(nodeForDefaultStyle);
                    foreach (SetterSceneNode setter in (IEnumerable <SceneNode>)styleNode2.Setters)
                    {
                        DependencyPropertyReferenceStep property = setter.Property;
                        if (property != null && PlatformTypes.FrameworkTemplate.IsAssignableFrom((ITypeId)property.PropertyType))
                        {
                            this.ResolveTemplate(setter);
                        }
                    }
                    if (styleNode2.VisualTriggers != null)
                    {
                        foreach (TriggerBaseNode triggerBaseNode in (IEnumerable <TriggerBaseNode>)styleNode2.VisualTriggers)
                        {
                            BaseTriggerNode baseTriggerNode = triggerBaseNode as BaseTriggerNode;
                            if (baseTriggerNode != null)
                            {
                                foreach (SetterSceneNode setter in (IEnumerable <SceneNode>)baseTriggerNode.Setters)
                                {
                                    DependencyPropertyReferenceStep property = setter.Property;
                                    if (property != null && PlatformTypes.FrameworkTemplate.IsAssignableFrom((ITypeId)property.PropertyType))
                                    {
                                        this.ResolveTemplate(setter);
                                    }
                                }
                            }
                        }
                    }
                }
                styleNode1 = (StyleNode)this.ViewModel.GetSceneNode(nodeForDefaultStyle);
                using (this.ViewModel.ForceBaseValue())
                    this.SetValueAsSceneNode(propertyKey, (SceneNode)styleNode1);
            }
            return(styleNode1);
        }
Ejemplo n.º 6
0
        public static StyleNode CreateEmptyStyle(SceneViewModel sceneViewModel, IPropertyId propertyKey, ITypeId elementType)
        {
            IProperty       property       = sceneViewModel.ProjectContext.ResolveProperty(propertyKey);
            StyleNode       styleNode      = (StyleNode)sceneViewModel.CreateSceneNode(PlatformTypes.Style);
            IProjectContext projectContext = sceneViewModel.ProjectContext;
            Type            type1          = projectContext.MetadataFactory.GetMetadata(projectContext.ResolveType(elementType).RuntimeType).GetStylePropertyTargetType((IPropertyId)property);

            if (type1 == (Type)null && !projectContext.IsCapabilitySet(PlatformCapability.SupportsStyleWithoutTargetType))
            {
                type1 = projectContext.PlatformMetadata.ResolveType(PlatformTypes.FrameworkElement).RuntimeType;
            }
            if (type1 != (Type)null)
            {
                IType type2 = projectContext.GetType(type1);
                styleNode.StyleTargetTypeId = type2;
            }
            return(styleNode);
        }
Ejemplo n.º 7
0
 public StyleDocumentPropertyNodeReference(StyleNode styleNode, DependencyPropertyReferenceStep referenceStep)
 {
     this.styleNode     = styleNode;
     this.referenceStep = referenceStep;
 }
Ejemplo n.º 8
0
        protected virtual DocumentNode ResolveDefaultStyleAsDocumentNode(IType targetType, IPropertyId propertyKey)
        {
            DocumentNode node      = (DocumentNode)null;
            IViewStyle   viewStyle = (IViewStyle)null;

            if (this.IsViewObjectValid)
            {
                ReferenceStep referenceStep = propertyKey as ReferenceStep;
                if (referenceStep != null && this.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
                {
                    viewStyle = this.Platform.ViewObjectFactory.Instantiate(referenceStep.GetCurrentValue(this.ViewObject.PlatformSpecificObject)) as IViewStyle;
                    if (viewStyle != null && viewStyle.StyleTargetType != targetType.RuntimeType)
                    {
                        viewStyle = (IViewStyle)null;
                    }
                    if (viewStyle != null)
                    {
                        node = this.ViewModel.DefaultView.GetCorrespondingDocumentNode((IViewObject)viewStyle, true);
                        if (node == null && this.DesignerContext.DesignerDefaultPlatformService.DefaultPlatform == this.Platform)
                        {
                            node = this.CreateNode(viewStyle.PlatformSpecificObject);
                        }
                    }
                }
            }
            for (IType type = this.ProjectContext.GetType(this.MetadataFactory.GetMetadata(targetType.RuntimeType).GetStylePropertyTargetType(propertyKey)); node == null && type != null && !PlatformTypes.Object.Equals((object)type); type = type.BaseType)
            {
                IList <DocumentCompositeNode> auxillaryResources = (IList <DocumentCompositeNode>)null;
                if (PlatformTypes.IsPlatformType((ITypeId)type))
                {
                    node = this.DesignerContext.ThemeContentProvider.GetThemeResourceFromPlatform(this.Platform, (object)type.RuntimeType, out auxillaryResources);
                }
                else
                {
                    foreach (IProject project in this.DesignerContext.ProjectManager.CurrentSolution.Projects)
                    {
                        IProjectContext projectContext = (IProjectContext)ProjectXamlContext.GetProjectContext(project);
                        if (projectContext != null && type.RuntimeAssembly.Equals((object)projectContext.ProjectAssembly))
                        {
                            node = this.DesignerContext.ThemeContentProvider.GetThemeResourceFromProject(project, (object)type.RuntimeType, out auxillaryResources);
                            if (node == null && !this.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
                            {
                                node = this.DesignerContext.ThemeContentProvider.GetThemeResourceFromAssembly(this.ProjectContext, type.RuntimeAssembly, type.RuntimeAssembly, (object)type.RuntimeType, out auxillaryResources);
                            }
                        }
                    }
                }
                if (node != null)
                {
                    node = node.Clone(this.DocumentContext);
                    if (auxillaryResources != null && auxillaryResources.Count > 0)
                    {
                        StyleNode styleNode = (StyleNode)this.ViewModel.GetSceneNode(node);
                        if (styleNode.AreResourcesSupported)
                        {
                            if (styleNode.Resources == null)
                            {
                                styleNode.Resources = (ResourceDictionaryNode)this.ViewModel.CreateSceneNode(PlatformTypes.ResourceDictionary);
                            }
                            for (int index = auxillaryResources.Count - 1; index >= 0; --index)
                            {
                                DictionaryEntryNode dictionaryEntryNode = (DictionaryEntryNode)this.ViewModel.GetSceneNode(auxillaryResources[index].Clone(this.DocumentContext));
                                styleNode.Resources.Insert(0, dictionaryEntryNode);
                            }
                        }
                    }
                }
            }
            if (viewStyle == null && this.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
            {
                ReferenceStep referenceStep = propertyKey as ReferenceStep;
                if (referenceStep != null)
                {
                    System.Windows.Style style = referenceStep.GetDefaultValue(targetType.RuntimeType) as System.Windows.Style;
                    if (style != null)
                    {
                        node = this.CreateNode((object)style);
                    }
                }
            }
            return(node);
        }