コード例 #1
0
            public virtual TimelineSceneNode InstantiateWithTarget(SceneViewModel viewModel, SceneNode targetElement, PropertyReference targetProperty, IStoryboardContainer referenceStoryboardContainer, ITypeId type)
            {
                TimelineSceneNode timelineSceneNode = (TimelineSceneNode)this.Instantiate(viewModel, type);

                timelineSceneNode.Initialize(targetElement, targetProperty, referenceStoryboardContainer);
                return(timelineSceneNode);
            }
コード例 #2
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);
        }
コード例 #3
0
        protected override void OnChildAdding(SceneNode child)
        {
            base.OnChildAdding(child);
            if (this.ShouldSerialize)
            {
                return;
            }
            TimelineSceneNode timelineSceneNode = child as TimelineSceneNode;

            if (timelineSceneNode == null || !timelineSceneNode.ShouldSerialize)
            {
                return;
            }
            this.ShouldSerialize = true;
        }
コード例 #4
0
        public static PropertyReference ResolvePropertyPath(ITypeResolver typeResolver, IViewObject propertyPath, SceneNode pathRoot)
        {
            if (propertyPath == null)
            {
                return((PropertyReference)null);
            }
            string path = (string)propertyPath.GetCurrentValue(typeResolver.ResolveProperty(typeResolver.PlatformMetadata.KnownProperties.PropertyPathPath));

            if (path == null)
            {
                return((PropertyReference)null);
            }
            IProperty           propertyKey = typeResolver.ResolveProperty(typeResolver.PlatformMetadata.KnownProperties.PropertyPathPathParameters);
            Collection <object> parameters  = propertyKey == null ? new Collection <object>() : (Collection <object>)propertyPath.GetCurrentValue(propertyKey);

            return(TimelineSceneNode.ResolvePropertyPathParts(typeResolver, path, parameters, pathRoot));
        }
コード例 #5
0
        protected override void OnChildRemoving(SceneNode child)
        {
            base.OnChildRemoving(child);
            TimelineSceneNode timeline = child as TimelineSceneNode;

            if (this.ViewModel.AnimationProxyManager != null && AnimationProxyManager.IsAnimationProxy(timeline))
            {
                this.ViewModel.AnimationProxyManager.UpdateOnDeletion(child as KeyFrameAnimationSceneNode);
            }
            VisualStateSceneNode controllingState = this.ControllingState;

            if (controllingState == null)
            {
                return;
            }
            TimelineSceneNode.PropertyNodePair propertyNodePair = timeline != null ? timeline.TargetElementAndProperty : new TimelineSceneNode.PropertyNodePair((SceneNode)null, (PropertyReference)null);
            VisualStateGroupSceneNode          stateGroup       = controllingState.StateGroup;

            if (propertyNodePair.SceneNode == null || propertyNodePair.PropertyReference == null || (!timeline.ShouldSerialize || stateGroup == null))
            {
                return;
            }
            List <KeyValuePair <VisualStateSceneNode, bool> > list = new List <KeyValuePair <VisualStateSceneNode, bool> >(stateGroup.States.Count);

            list.Add(new KeyValuePair <VisualStateSceneNode, bool>(controllingState, true));
            foreach (VisualStateTransitionSceneNode transitionSceneNode in (IEnumerable <VisualStateTransitionSceneNode>)stateGroup.Transitions)
            {
                if (transitionSceneNode.Storyboard != null && (!string.IsNullOrEmpty(transitionSceneNode.FromStateName) || !string.IsNullOrEmpty(transitionSceneNode.ToStateName)))
                {
                    VisualStateSceneNode fromState = transitionSceneNode.FromState;
                    VisualStateSceneNode toState   = transitionSceneNode.ToState;
                    if (fromState == controllingState || toState == controllingState)
                    {
                        TimelineSceneNode timelineSceneNode = (TimelineSceneNode)transitionSceneNode.Storyboard.GetAnimation(propertyNodePair.SceneNode, propertyNodePair.PropertyReference);
                        if (timelineSceneNode != null)
                        {
                            VisualStateSceneNode key = fromState == controllingState ? toState : fromState;
                            bool?nullable            = new bool?();
                            if (key == null)
                            {
                                nullable = new bool?(false);
                            }
                            if (!nullable.HasValue)
                            {
                                foreach (KeyValuePair <VisualStateSceneNode, bool> keyValuePair in list)
                                {
                                    if (keyValuePair.Key == key)
                                    {
                                        nullable = new bool?(keyValuePair.Value);
                                    }
                                }
                            }
                            if (!nullable.HasValue)
                            {
                                nullable = new bool?(key.Storyboard != null && key.Storyboard.GetAnimation(propertyNodePair.SceneNode, propertyNodePair.PropertyReference) != null);
                                list.Add(new KeyValuePair <VisualStateSceneNode, bool>(key, nullable.Value));
                            }
                            if (!nullable.Value)
                            {
                                transitionSceneNode.Storyboard.Children.Remove(timelineSceneNode);
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
        private static PropertyReference ResolvePropertyPathParts(ITypeResolver typeResolver, string path, Collection <object> parameters, SceneNode pathRoot)
        {
            if (path == "(0)")
            {
                if (parameters == null || parameters.Count == 0)
                {
                    return((PropertyReference)null);
                }
                DependencyProperty dependencyProperty = parameters[0] as DependencyProperty;
                if (dependencyProperty == null)
                {
                    return((PropertyReference)null);
                }
                Type targetType = pathRoot != null ? pathRoot.TargetType : dependencyProperty.OwnerType;
                DependencyPropertyReferenceStep referenceStep = DependencyPropertyReferenceStep.GetReferenceStep(typeResolver, targetType, dependencyProperty);
                if (referenceStep == null)
                {
                    return((PropertyReference)null);
                }
                return(new PropertyReference((ReferenceStep)referenceStep));
            }
            List <ReferenceStep> list = new List <ReferenceStep>();
            object obj = (object)null;

            if (typeResolver.IsCapabilitySet(PlatformCapability.SupportTypelessPropertyPath) && pathRoot != null && pathRoot.IsViewObjectValid)
            {
                obj = pathRoot.ViewObject.PlatformSpecificObject;
            }
            IType typeId = obj == null ? (pathRoot == null ? (parameters == null || parameters.Count <= 0 || !(parameters[0] is DependencyProperty) ? typeResolver.ResolveType(PlatformTypes.Object) : typeResolver.GetType(((DependencyProperty)parameters[0]).OwnerType)) : pathRoot.Type) : typeResolver.GetType(obj.GetType());

            for (int index1 = 0; index1 < path.Length; ++index1)
            {
                ReferenceStep referenceStep = (ReferenceStep)null;
                char          ch            = path[index1];
                switch (ch)
                {
                case '(':
                    int num1 = path.IndexOf(')', index1 + 1);
                    if (num1 < 0)
                    {
                        return((PropertyReference)null);
                    }
                    string s = path.Substring(index1 + 1, num1 - index1 - 1);
                    int    result1;
                    if (int.TryParse(s, out result1))
                    {
                        if (parameters == null || result1 < 0 || result1 >= parameters.Count)
                        {
                            return((PropertyReference)null);
                        }
                        DependencyProperty dependencyProperty = parameters[result1] as DependencyProperty;
                        if (dependencyProperty == null)
                        {
                            return((PropertyReference)null);
                        }
                        referenceStep = (ReferenceStep)DependencyPropertyReferenceStep.GetReferenceStep(typeResolver, typeId.NearestResolvedType.RuntimeType, dependencyProperty);
                        if (referenceStep == null)
                        {
                            PlatformTypes platformTypes = (PlatformTypes)typeResolver.PlatformMetadata;
                            Type          runtimeType   = typeId.NearestResolvedType.RuntimeType;
                            Type          ownerType     = dependencyProperty.OwnerType;
                            referenceStep = (ReferenceStep)(platformTypes.GetProperty(typeResolver, ownerType, MemberType.LocalProperty, dependencyProperty.Name) as DependencyPropertyReferenceStep);
                            if (referenceStep == null || !runtimeType.IsAssignableFrom(ownerType))
                            {
                                return((PropertyReference)null);
                            }
                        }
                    }
                    else
                    {
                        int    length = s.IndexOf('.');
                        string typeName;
                        if (length < 0)
                        {
                            if (!typeResolver.IsCapabilitySet(PlatformCapability.SupportTypelessPropertyPath))
                            {
                                return((PropertyReference)null);
                            }
                            typeName = typeId.Name;
                            length   = -1;
                        }
                        else
                        {
                            typeName = s.Substring(0, length);
                        }
                        string str = s.Substring(length + 1);
                        if (string.IsNullOrEmpty(typeName))
                        {
                            return((PropertyReference)null);
                        }
                        IType type = typeResolver.GetType((IXmlNamespace)typeResolver.GetCapabilityValue(PlatformCapability.DefaultXmlns), typeName);
                        if (type == null)
                        {
                            IProperty designTimeProperty = typeResolver.PlatformMetadata.GetDesignTimeProperty(str, (IType)null);
                            if (designTimeProperty != null && designTimeProperty.DeclaringType.Name == typeName)
                            {
                                referenceStep = (ReferenceStep)designTimeProperty;
                            }
                        }
                        if (referenceStep == null)
                        {
                            if (type == null)
                            {
                                type = typeId;
                            }
                            referenceStep = type.GetMember(MemberType.Property, str, MemberAccessTypes.Public) as ReferenceStep ?? TimelineSceneNode.ResolveReferenceStepFromValue(typeResolver, pathRoot, list, str);
                        }
                        if (referenceStep == null)
                        {
                            return((PropertyReference)null);
                        }
                    }
                    index1 = num1;
                    break;

                case '[':
                    int num2 = path.IndexOf(']', index1 + 1);
                    if (num2 < 0)
                    {
                        return((PropertyReference)null);
                    }
                    int result2;
                    if (!int.TryParse(path.Substring(index1 + 1, num2 - index1 - 1), out result2))
                    {
                        return((PropertyReference)null);
                    }
                    referenceStep = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep(typeResolver, typeId.RuntimeType, result2, false);
                    index1        = num2;
                    if (referenceStep == null)
                    {
                        return((PropertyReference)null);
                    }
                    break;

                default:
                    int startIndex = index1;
                    if ((int)ch == 46)
                    {
                        ++startIndex;
                    }
                    if (index1 >= path.Length - 1)
                    {
                        return((PropertyReference)null);
                    }
                    int index2 = index1 + 1;
                    if ((int)path[index2] != 40)
                    {
                        for (; index2 < path.Length; ++index2)
                        {
                            switch (path[index2])
                            {
                            case '.':
                            case '[':
                                goto label_52;

                            default:
                                goto default;
                            }
                        }
label_52:
                        if (index1 >= index2 - 1)
                        {
                            return((PropertyReference)null);
                        }
                        string str = path.Substring(startIndex, index2 - startIndex);
                        referenceStep = typeId.GetMember(MemberType.LocalProperty | MemberType.Field, str, TypeHelper.GetAllowableMemberAccess(typeResolver, typeId)) as ReferenceStep;
                        if (referenceStep == null)
                        {
                            referenceStep = TimelineSceneNode.ResolveReferenceStepFromValue(typeResolver, pathRoot, list, str);
                            if (referenceStep == null)
                            {
                                return((PropertyReference)null);
                            }
                        }
                        index1 = index2 - 1;
                        break;
                    }
                    break;
                }
                if (referenceStep != null)
                {
                    list.Add(referenceStep);
                    typeId = referenceStep.PropertyType;
                }
            }
            if (list == null || list.Count <= 0)
            {
                return((PropertyReference)null);
            }
            return(new PropertyReference(list));
        }