コード例 #1
0
ファイル: JSONGenerator.cs プロジェクト: pecata11/myprojects
        /*
         * Generating the JSON for the animations for one slide only. It has some support for nested animations but not everything works.
         */

        public string GetAnimationsJSON()
        {
            if (Slide == null)
            {
                return("{s1:{t:{i:1000,c:1,v:0,n:0},g:0,a:0,f:0,c:0}}");
            }
            String result = "";

            int animations = 0;

            List <IAnimation> fixedAnimations = fixAnimationTimings(Slide.Animations);

            animations = fixedAnimations.Count;

            if (Slide.Transition == null)
            {
                result = "{s1:{t:{i:0,c:1,v:0,n:0},g:0,a:0,f:0,c:##ANIMATIONS_PLACEHOLDER##}}";
            }
            else
            {
                result = "{s1:{t:{i:" + (Slide.Transition.Length + Slide.Transition.Start) +
                         ",c:" + Slide.Transition.GetJsonString() + "},g:0,a:0,f:0,c:##ANIMATIONS_PLACEHOLDER##}}";
            }
            if (animations == 0)
            {
                result = result.Replace("##ANIMATIONS_PLACEHOLDER##", "0");
                return(result);
            }


            SimpleAnimation checkEffectFirstAnim = (SimpleAnimation)fixedAnimations[0];

            if (checkEffectFirstAnim.timingType.HasValue && checkEffectFirstAnim.timingType.Value != TimeNodeValues.ClickEffect)
            {
                result = result.Replace("n:0", "n:1");
                //If it is just one Animation we change this in the transition! - the transition is like the first Animation!
            }


            string animationsString = "{i:" + animations + getAnimationsString(fixedAnimations, true) + "}";



            result = result.Replace("##ANIMATIONS_PLACEHOLDER##", animationsString);

            return(result);
        }
コード例 #2
0
        public EmphasisAnimation(SimpleAnimation fromBase)
        {
            this.AdditionalData  = fromBase.AdditionalData;
            this.InitialState    = fromBase.InitialState;
            this.InnerAnimations = fromBase.InnerAnimations;
            this.Start           = fromBase.Start;
            this.Length          = fromBase.Length;
            this.ObjectId        = fromBase.ObjectId;
            this.Repetitions     = fromBase.Repetitions;
            this.timingType      = fromBase.timingType;
            this.Type            = fromBase.Type;

            this.RGBColor        = "[0,0,0]";
            this.Transparency    = 0;
            this.RotationDegrees = 0;
            this.ScaleX          = 0;
            this.ScaleY          = 0;
            e1 = 1;
            e2 = 0;
        }
コード例 #3
0
ファイル: JSONGenerator.cs プロジェクト: pecata11/myprojects
        private SimpleAnimation handleEntranceAnimation(CommonTimeNode commonTimeNode, SimpleAnimation result)
        {
            switch (commonTimeNode.PresetId.Value)  //Presets for Entrance/Exit
            {
            case 1: result.Type = AnimationTypes.Appear; break;

            case 54: result.Type = AnimationTypes.Glide; break;

            case 19: result.Type = AnimationTypes.Swivel; break;

            case 42: result.Type = AnimationTypes.Ascend; break;

            case 3: result.Type = AnimationTypes.Blinds; break;

            case 4: result.Type = AnimationTypes.Box; break;

            case 25: result.Type = AnimationTypes.Boomerang; break;

            case 43: result.Type = AnimationTypes.CenterRevolve; break;

            case 5: result.Type = AnimationTypes.Checkerboard; break;

            case 50: result.Type = AnimationTypes.Compress; break;

            case 7: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.CrawlIn : AnimationTypes.CrawlOut; break;

            case 47: result.Type = AnimationTypes.Descend; break;

            case 48: result.Type = AnimationTypes.Sling; break;

            case 29: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.EaseIn : AnimationTypes.EaseOut; break;

            case 55: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.Expand : AnimationTypes.Contract; break;

            case 10: result.Type = AnimationTypes.Fade; break;

            case 53: result.Type = AnimationTypes.FadedZoom; break;

            case 11: result.Type = AnimationTypes.FlashOnce; break;

            case 2: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.FlyIn : AnimationTypes.FlyOut; break;

            case 58: result.Type = AnimationTypes.Fold; break;

            case 31: result.Type = AnimationTypes.GrowTurn; break;

            case 12: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.PeekIn : AnimationTypes.PeekOut; break;

            case 16: result.Type = AnimationTypes.Split; break;

            case 35: result.Type = AnimationTypes.Pinwheel; break;

            case 14: result.Type = AnimationTypes.RandomBars; break;

            case 37: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.RiseUp : AnimationTypes.SinkDown; break;

            case 49: result.Type = AnimationTypes.Spinner; break;

            case 22: result.Type = AnimationTypes.Wipe; break;

            case 18: result.Type = AnimationTypes.Strips; break;

            case 26: result.Type = AnimationTypes.Bounce; result.Length = (int)((result.Length * 100) / 29); break;    //time tunning

            case 6: result.Type = AnimationTypes.Circle; break;

            case 28: result.Type = AnimationTypes.Credits; break;

            case 52: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.CurveUp : AnimationTypes.CurveDown; break;

            case 8: result.Type = AnimationTypes.Diamond; break;

            case 9: result.Type = AnimationTypes.Dissolve; break;

            case 30: result.Type = AnimationTypes.Float; break;

            case 34: result.Type = AnimationTypes.LightSpeed; result.Length = (int)((result.Length * 5) / 3); break;    //time tunning

            case 51: result.Type = AnimationTypes.Magnify; result.Length = (int)((result.Length * 200) / 77); break;    //time tunning

            case 13: result.Type = AnimationTypes.Plus; break;

            case 15: result.Type = AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass) ? AnimationTypes.SpiralIn : AnimationTypes.SpiralOut; break;

            case 17: result.Type = AnimationTypes.Stretch; break;

            case 39: result.Type = AnimationTypes.Thread; break;

            case 20: result.Type = AnimationTypes.Wedge; break;

            case 21: result.Type = AnimationTypes.Wheel; result.AdditionalData = "" + commonTimeNode.PresetSubtype.Value; break;

            case 23: result.Type = AnimationTypes.Zoom; break;

            default: return(null);
            }

            return(result);
        }
コード例 #4
0
ファイル: JSONGenerator.cs プロジェクト: pecata11/myprojects
        private EmphasisAnimation handleEmphasisAnimation(CommonTimeNode commonTimeNode, SimpleAnimation simpleAnim)
        {
            EmphasisAnimation result = new EmphasisAnimation(simpleAnim);

            result.setRgbColor(commonTimeNode, Slide);

            switch (commonTimeNode.PresetId.Value)  //Presets for Entrance/Exit
            {
            case 3: result.Type = AnimationTypes.ChangeFontColor; break;

            case 19: result.Type = AnimationTypes.ColorBlend; break;

            case 14: result.Type = AnimationTypes.Blast; break;

            case 26: result.Type = AnimationTypes.FlashBulb; break;

            case 35: result.Type = AnimationTypes.Blink; break;

            case 9:
            {
                result.Type         = AnimationTypes.Transparency;
                result.Transparency = getTransparence(commonTimeNode);
            } break;

            case 20:
            {
                result.Type    = AnimationTypes.ColorWave;
                result.Length *= 2;
                result.e2      = result.Length / 10;
                result.e1      = 2;
            } break;

            case 16:
            {
                result.Type = AnimationTypes.BrushOnColor;
                result.e2   = result.Length / 25;
                result.e1   = 2;
            } break;

            case 33:
            {
                result.Type    = AnimationTypes.VerticalHighlight;
                result.Length *= 2;
            } break;

            case 27:
            {
                result.Type    = AnimationTypes.Flicker;
                result.Length *= 2;
            } break;

            case 36:
            {
                result.Type    = AnimationTypes.Shimmer;
                result.e2      = result.Length / 5;
                result.Length *= 2;
                foreach (Object obj in commonTimeNode.Descendants())
                {
                    if (obj.GetType().Equals(typeof(AnimateScale)))
                    {
                        ((EmphasisAnimation)result).ScaleX = ((AnimateScale)obj).ToPosition.X.Value / 1000;
                        ((EmphasisAnimation)result).ScaleY = ((AnimateScale)obj).ToPosition.Y.Value / 1000;
                        break;
                    }
                }
            } break;

            case 28:
            {
                result.Type = AnimationTypes.GrowwithColor;
                result.e2   = result.Length / 10;
                result.e1   = 2;
            } break;

            case 32:
            {
                result.Type    = AnimationTypes.Teeter;
                result.Length *= 2;
            } break;

            case 34:
            {
                result.Type    = AnimationTypes.Wave;
                result.e2      = result.Length / 5;
                result.Length *= 2;
            } break;

            case 8:
            {
                result.Type = AnimationTypes.Spin;
                foreach (Object obj in commonTimeNode.Descendants())
                {
                    if (obj.GetType().Equals(typeof(AnimateRotation)))
                    {
                        ((EmphasisAnimation)result).RotationDegrees = ((AnimateRotation)obj).By / 60000;
                        break;
                    }
                }
            } break;

            case 6:
            {
                result.Type = AnimationTypes.GrowShrink;
                foreach (Object obj in commonTimeNode.Descendants())
                {
                    if (obj.GetType().Equals(typeof(AnimateScale)))
                    {
                        ((EmphasisAnimation)result).ScaleX = ((AnimateScale)obj).ByPosition.X.Value / 1000;
                        ((EmphasisAnimation)result).ScaleY = ((AnimateScale)obj).ByPosition.Y.Value / 1000;
                        break;
                    }
                }
            } break;

            default: return(null);
            }

            return(result);
        }
コード例 #5
0
ファイル: JSONGenerator.cs プロジェクト: pecata11/myprojects
        public SimpleAnimation getSimpleAnimationFromCommonTimeNodePreset(CommonTimeNode commonTimeNode, SlideSize SlideSizes)
        {
            SimpleAnimation result = new SimpleAnimation();

            if (AnimationTypes.TypePath.Equals(commonTimeNode.PresetClass))
            {
                return(new MotionPathAnimation(commonTimeNode, Slide.slideIndex, SlideSizes));
            }
            else if (AnimationTypes.TypeEntrance.Equals(commonTimeNode.PresetClass))
            {
                result.InitialState = 1;
            }
            else if (AnimationTypes.TypeExit.Equals(commonTimeNode.PresetClass))
            {
                result.InitialState = 2;
            }
            else if (AnimationTypes.TypeEmphasis.Equals(commonTimeNode.PresetClass))
            {
                result.InitialState = 3;
            }
            else
            {
                return(null);
            }
            if (commonTimeNode.PresetId == null)
            {
                return(null);
            }
            result.timingType = commonTimeNode.NodeType;

            //Get the speed from one of the nodes common behavior. Hopefully all nodes have the same speed (since the animation is the same).
            foreach (Object xmlEl in commonTimeNode.Descendants())
            {
                if (xmlEl.GetType().Equals(typeof(CommonBehavior)))
                {
                    CommonBehavior bhvr = ((CommonBehavior)xmlEl);

                    if (bhvr.CommonTimeNode != null)
                    {
                        result.FixAnimationTimings(bhvr, Slide.slideIndex);
                        if (result.Length <= 1)
                        {
                            continue;
                        }
                        if (result.Start == 0)
                        {
                            Condition condition = commonTimeNode.StartConditionList.FirstChild as Condition;
                            if (!condition.Delay.Equals("indefinite"))
                            {
                                result.Start = int.Parse(condition.Delay);
                            }
                        }
                        break;
                    }
                }
            }
            if (result.Length <= 1)
            {
                result.Length = 100;  //Default value??
            }
            if (AnimationTypes.TypeEmphasis.Equals(commonTimeNode.PresetClass))
            {
                result = handleEmphasisAnimation(commonTimeNode, result);
            }
            else
            {
                result = handleEntranceAnimation(commonTimeNode, result);
            }


            if (result.AdditionalData == null || result.AdditionalData == "0") //There are default values. Horizontal In = horizontal + in ;)
            {
                switch (commonTimeNode.PresetSubtype.Value)
                {
                case 0: result.AdditionalData = "0"; break;

                case 4: result.AdditionalData = "3"; break;      //From bottom

                case 2: result.AdditionalData = "2"; break;      //From right

                case 1: result.AdditionalData = "1"; break;      //From top

                case 8: result.AdditionalData = "4"; break;      //From left

                case 6: result.AdditionalData = "8"; break;      //Bottom right

                case 3: result.AdditionalData = "7"; break;      //Top right

                case 9: result.AdditionalData = "6"; break;      //Top right

                case 12: result.AdditionalData = "9"; break;     //Bottom left

                case 10: result.AdditionalData = "16"; break;    //Horizontal

                case 5: result.AdditionalData = "17"; break;     //Vertical

                case 26: result.AdditionalData = "23"; break;    //Horizontal in

                case 42: result.AdditionalData = "24"; break;    //Horizontal out

                case 21: result.AdditionalData = "25"; break;    //Vertical in

                case 37: result.AdditionalData = "26"; break;    //Vertical out

                case 16: result.AdditionalData = "19"; break;    //in

                case 32: result.AdditionalData = "20"; break;    //out
                }
            }

            checkIsText(result);
            return(result);
        }
コード例 #6
0
ファイル: JSONGenerator.cs プロジェクト: pecata11/myprojects
        /*
         * Fix the timing for animations that need to start without a click. Make the tree simpler by removing nodes that are empty or nested.
         *
         * When a node has a start type != ClickEffect , we add the Animations from this timenode to the animations list in the previous time node.
         * If it is type After the previous one we need to set Delay = Length of the previous one.
         *
         * Removing nested nodes:
         * Example 1: Node -> Node -> Node  - every node has a single child. In this case we can create one time node with the timing for both.
         * Example 2: We have only one node (one simple animation) and all the other are nested (inner animations) - we remove the parent time node and
         * add its timing to the timing of the nested animations.
         *
         */

        private List <IAnimation> fixAnimationTimings(List <IAnimation> animations)
        {
            animations = fixNestedAnimations(animations);


            List <IAnimation> result = new List <IAnimation>();

            if (animations == null || animations.Count == 0)
            {
                return(result);
            }
            //If we have only one animation and all the others are nested  - add the delay to the inner animations and remove this one.
            if (animations.Count == 1 && animations[0].InnerAnimations != null && animations[0].InnerAnimations.Count > 0)
            {
                foreach (IAnimation anim in animations[0].InnerAnimations)
                {
                    anim.Start += animations[0].Start;
                }
                return(fixAnimationTimings(animations[0].InnerAnimations));
            }
            IAnimation previousAnimation = null;

            foreach (IAnimation animation in animations)
            {
                SimpleAnimation sAnimation = (SimpleAnimation)animation;
                if (previousAnimation == null)
                {
                    previousAnimation = sAnimation;
                    continue;
                }
                //These are the cases where animation starts without a click. There migth be other cases which are not handled yet.
                else if (sAnimation.timingType.HasValue && (
                             TimeNodeValues.WithEffect.Equals(sAnimation.timingType.Value) ||
                             TimeNodeValues.AfterEffect.Equals(sAnimation.timingType.Value) ||
                             TimeNodeValues.WithGroup.Equals(sAnimation.timingType.Value) ||
                             TimeNodeValues.AfterGroup.Equals(sAnimation.timingType.Value)))
                {
                    int newLenegth = 0;
                    if (TimeNodeValues.AfterEffect.Equals(sAnimation.timingType.Value) ||
                        TimeNodeValues.AfterGroup.Equals(sAnimation.timingType.Value))
                    {
                        /*If animation is a part of a group then it has delay according to the start of the parent time node (animation).
                         * In this case we use this delay because it is the proper way power point handles such animations.
                         * If by some reason there isn't such delay and the animation type is set to 'After' previous
                         * we set the start point to right after the previous animation ends." */

                        if (sAnimation.Start <= previousAnimation.Length + previousAnimation.Start)
                        {
                            sAnimation.Start = previousAnimation.Length + previousAnimation.Start;
                        }
                        if (sAnimation.InnerAnimations != null)
                        {
                            foreach (IAnimation anim in sAnimation.InnerAnimations)
                            {
                                anim.Start = anim.Start + sAnimation.Start;
                            }
                        }
                        newLenegth = sAnimation.Length + sAnimation.Start;
                    }
                    else
                    {
                        newLenegth = (sAnimation.Length + sAnimation.Start >
                                      previousAnimation.Length + previousAnimation.Start)
                                              ? sAnimation.Length + sAnimation.Start
                                              : previousAnimation.Length + previousAnimation.Start;
                    }

                    /*Joins the current animation and the previous one and recalculates the length*/
                    if (previousAnimation.InnerAnimations != null && previousAnimation.InnerAnimations.Count > 0)
                    {
                        previousAnimation.Length = newLenegth;
                        if (sAnimation.InnerAnimations == null || sAnimation.InnerAnimations.Count == 0)
                        {
                            previousAnimation.InnerAnimations.Add(sAnimation);
                        }
                        else
                        {
                            previousAnimation.InnerAnimations.AddRange(sAnimation.InnerAnimations);
                        }
                        continue;
                    }
                    else
                    {
                        SimpleAnimation tempAnimation = new SimpleAnimation();
                        tempAnimation.Length          = newLenegth;
                        tempAnimation.timingType      = ((SimpleAnimation)previousAnimation).timingType;
                        tempAnimation.InnerAnimations = new List <IAnimation>();

                        if (previousAnimation.InnerAnimations == null || previousAnimation.InnerAnimations.Count == 0)
                        {
                            tempAnimation.InnerAnimations.Add(previousAnimation);
                        }
                        else
                        {
                            tempAnimation.InnerAnimations.AddRange(previousAnimation.InnerAnimations);
                        }

                        if (sAnimation.InnerAnimations == null || sAnimation.InnerAnimations.Count == 0)
                        {
                            tempAnimation.InnerAnimations.Add(sAnimation);
                        }
                        else
                        {
                            tempAnimation.InnerAnimations.AddRange(sAnimation.InnerAnimations);
                        }
                        previousAnimation = tempAnimation;
                        continue;
                    }
                }
                result.Add(previousAnimation);
                previousAnimation = sAnimation;
            }
            result.Add(previousAnimation);
            return(result);
        }