Ejemplo n.º 1
0
 public void setRgbColor(CommonTimeNode commonTimeNode, PPTSlide Slide)
 {
     RGBColor = "[0,0,0]";
     foreach (Object xmlEl in commonTimeNode.Descendants())
     {
         if (xmlEl.GetType().Equals(typeof(RgbColorModelHex)))
         {
             RgbColorModelHex rgb = (RgbColorModelHex)xmlEl;
             RGBColor = convertHEXtoRGB(((RgbColorModelHex)rgb).Val);
         }
         else if (xmlEl.GetType().Equals(typeof(SchemeColor)))
         {
             string schemeCol = ((SchemeColor)xmlEl).Val;
             DocumentFormat.OpenXml.Drawing.ColorScheme allSchemeCols =
                 Slide.SlideLayoutPart.SlideMasterPart.ThemePart.Theme.ThemeElements.ColorScheme;
             foreach (OpenXmlCompositeElement desc in allSchemeCols.Descendants())
             {
                 string currSchemeCol = desc.LocalName;
                 if (schemeCol == currSchemeCol ||
                     (schemeCol == "bg1" && currSchemeCol == "lt1") ||
                     (schemeCol == "bg2" && currSchemeCol == "lt2") ||
                     (schemeCol == "tx1" && currSchemeCol == "dk1") ||
                     (schemeCol == "tx2" && currSchemeCol == "dk2"))
                 {
                     if (typeof(RgbColorModelHex) == desc.FirstChild.GetType())
                     {
                         RGBColor = convertHEXtoRGB(((RgbColorModelHex)desc.FirstChild).Val);
                     }
                     else if (typeof(SystemColor) == desc.FirstChild.GetType())
                     {
                         RGBColor = convertHEXtoRGB(((SystemColor)desc.FirstChild).LastColor);
                     }
                 }
             }
             break;
         }
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public MotionPathAnimation(CommonTimeNode commonTimeNode, int slideIndex, SlideSize SlideSizes)
        {
            this.SlideSizes = SlideSizes;
            InitialState    = 4;
            timingType      = commonTimeNode.NodeType;
            Type            = AnimationTypes.MotionPath;
            AnimateMotion motion = null;

            foreach (Object xmlEl in commonTimeNode.Descendants())
            {
                if (xmlEl.GetType().Equals(typeof(AnimateMotion)))
                {
                    motion = (AnimateMotion)xmlEl;
                }
            }
            if (motion == null)
            {
                return;
            }
            String path = motion.Path.Value;

            String[] parts = path.Split();
            motionPath = new List <PathPart>();
            int  indexPart = -1;
            bool isX       = true;

            foreach (string part in parts)
            {
                if ("".Equals(part) || "E".Equals(part))  //We add our End tag
                {
                    continue;
                }
                Double coords = 0.0;
                if (!Double.TryParse(part, NumberStyles.Float, CultureInfo.InvariantCulture, out coords))
                {
                    isX = true;
                    if (indexPart >= 0)
                    {  //FIX FOR POINTS WITH 3 COORDINATES UNTIL WE KNOW WHAT THEY ARE.
                        List <PathPoint> previousPartPoints = motionPath[indexPart].points;
                        if (previousPartPoints[previousPartPoints.Count - 1].Y.CompareTo(0) == 0)
                        {
                            previousPartPoints.Remove(previousPartPoints[previousPartPoints.Count - 1]);
                        }
                    }

                    indexPart++;
                    motionPath.Add(new PathPart());
                    motionPath[indexPart].typeCharacter = part;
                }
                else if (isX)
                {
                    coords = coords * MultiplierX();
                    PathPoint newPoint = new PathPoint();
                    newPoint.X = coords;
                    motionPath[indexPart].points.Add(newPoint);   // We have a new point
                    isX = !isX;
                }
                else
                {
                    coords = coords * MultiplierY();
                    motionPath[indexPart].points[motionPath[indexPart].points.Count - 1].Y = coords;  //Set Y for the last point
                    isX = !isX;
                }
            }


            FixAnimationTimings(motion.CommonBehavior, slideIndex);
            generateAdditionDataString(motionPath);
        }