コード例 #1
0
ファイル: PPTSlide.cs プロジェクト: pecata11/myprojects
        public void AddAnimations(OpenXmlCompositeElement element, List <IAnimation> resultList, SlideSize SlideSizes)
        {
            if (element == null)
            {
                return;
            }

            List <AnimateMotion> motions = new List <AnimateMotion>();
            IAnimation           animationForThisNode = null;

            if (element.GetType().Equals(typeof(CommonTimeNode)))
            {
                CommonTimeNode node = (CommonTimeNode)element;
                animationForThisNode = new JSONGenerator(this).getSimpleAnimationFromCommonTimeNodePreset(node, SlideSizes);

                if (animationForThisNode != null)
                {
                    resultList.Add(animationForThisNode);
                    //Check if object id is presented in animation list.
                    CheckAndSetAnimatableProperty(animationForThisNode.ObjectId);

                    if ((animationForThisNode.InnerAnimations == null ||
                         animationForThisNode.InnerAnimations.Count == 0) &&
                        animationForThisNode.IsItEntranceAnimation())
                    {
                        MakeShapeInvisible("s1s" + animationForThisNode.ObjectId);
                    }
                    else if (animationForThisNode.InnerAnimations != null)
                    {
                        foreach (IAnimation anAnimation in animationForThisNode.InnerAnimations)
                        {
                            if (anAnimation.IsItEntranceAnimation())
                            {
                                MakeShapeInvisible("s1s" + animationForThisNode.ObjectId);
                            }
                        }
                    }
                    return;
                }
                else
                {
                    /*
                     * Sometimes there are common time nodes without animations in them. They are used for grouping animations.
                     * Usually animations are grouped for timing purposes like adding delay to all, or start a group after another.
                     * It's a tree structure and here we try to follow it as much as possible. Later we will strip the unnecessary nodes
                     */

                    animationForThisNode = new SimpleAnimation();
                    if (node.NodeType != null)
                    {
                        ((SimpleAnimation)animationForThisNode).timingType = node.NodeType;
                    }
                    int delay = 0;
                    if (node.StartConditionList != null)
                    {
                        foreach (Condition cond in node.StartConditionList)
                        {
                            if (cond.Delay != null && "indefinite" != cond.Delay.Value && cond.Delay.HasValue)
                            {
                                delay = delay + int.Parse(cond.Delay.Value);
                            }
                        }
                    }
                    if (delay > 0)
                    {
                        animationForThisNode.Start = delay;
                    }
                }

                if (animationForThisNode != null)
                {
                    animationForThisNode.InnerAnimations = new List <IAnimation>();
                    resultList.Add(animationForThisNode);
                }
            }

            //Go recursive in the Open XML tree

            foreach (OpenXmlElement obj in element.ChildElements)
            {
                if (obj.GetType().IsSubclassOf(typeof(OpenXmlCompositeElement)))
                {
                    if (animationForThisNode == null)
                    {
                        AddAnimations((OpenXmlCompositeElement)obj, resultList, SlideSizes);
                    }
                    else
                    {
                        AddAnimations((OpenXmlCompositeElement)obj, animationForThisNode.InnerAnimations, SlideSizes);
                    }
                }
            }
        }