private double getTransparence(CommonTimeNode commonTimeNode) { if (typeof(AnimateEffect) == commonTimeNode.LastChild.LastChild.GetType()) { AnimateEffect animEffect = (AnimateEffect)commonTimeNode.LastChild.LastChild; string value = animEffect.PropertyList.Value; if (value != null && value.IndexOf("opacity:") != -1) { string opacityStr = value.Substring(9);//we need 0.75 from "opacity: 0.75" double opacity = double.Parse(opacityStr, CultureInfo.GetCultureInfo("en-US").NumberFormat); return(1 - opacity); } } return(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; } } }
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); }
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); }
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); }
public ParallelTiming(CommonTimeNode ctn) { _ctn = ctn; }
public StepTiming(CommonTimeNode ctn) { _ctn = ctn; }
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); } } } }
public static void InitTiming(Slide slide) { Timing timing1 = new Timing(); TimeNodeList timeNodeList1 = new TimeNodeList(); ParallelTimeNode parallelTimeNode1 = new ParallelTimeNode(); CommonTimeNode commonTimeNode1 = new CommonTimeNode() { Id = (UInt32Value)1U, Duration = "indefinite", Restart = TimeNodeRestartValues.Never, NodeType = TimeNodeValues.TmingRoot }; ChildTimeNodeList childTimeNodeList1 = new ChildTimeNodeList(); SequenceTimeNode sequenceTimeNode1 = new SequenceTimeNode() { Concurrent = true, NextAction = NextActionValues.Seek }; CommonTimeNode commonTimeNode2 = new CommonTimeNode() { Id = (UInt32Value)2U, Restart = TimeNodeRestartValues.WhenNotActive, Fill = TimeNodeFillValues.Hold, EventFilter = "cancelBubble", NodeType = TimeNodeValues.InteractiveSequence }; StartConditionList startConditionList1 = new StartConditionList(); Condition condition1 = new Condition() { Event = TriggerEventValues.OnClick, Delay = "0" }; TargetElement targetElement1 = new TargetElement(); ShapeTarget shapeTarget1 = new ShapeTarget() { ShapeId = "3" }; targetElement1.Append(shapeTarget1); condition1.Append(targetElement1); startConditionList1.Append(condition1); EndSync endSync1 = new EndSync() { Event = TriggerEventValues.End, Delay = "0" }; RuntimeNodeTrigger runtimeNodeTrigger1 = new RuntimeNodeTrigger() { Val = TriggerRuntimeNodeValues.All }; endSync1.Append(runtimeNodeTrigger1); ChildTimeNodeList childTimeNodeList2 = new ChildTimeNodeList(); ParallelTimeNode parallelTimeNode2 = new ParallelTimeNode(); CommonTimeNode commonTimeNode3 = new CommonTimeNode() { Id = (UInt32Value)3U, Fill = TimeNodeFillValues.Hold }; StartConditionList startConditionList2 = new StartConditionList(); Condition condition2 = new Condition() { Delay = "0" }; startConditionList2.Append(condition2); ChildTimeNodeList childTimeNodeList3 = new ChildTimeNodeList(); ParallelTimeNode parallelTimeNode3 = new ParallelTimeNode(); CommonTimeNode commonTimeNode4 = new CommonTimeNode() { Id = (UInt32Value)4U, Fill = TimeNodeFillValues.Hold }; StartConditionList startConditionList3 = new StartConditionList(); Condition condition3 = new Condition() { Delay = "0" }; startConditionList3.Append(condition3); ChildTimeNodeList childTimeNodeList4 = new ChildTimeNodeList(); ParallelTimeNode parallelTimeNode4 = new ParallelTimeNode(); CommonTimeNode commonTimeNode5 = new CommonTimeNode() { Id = (UInt32Value)5U, PresetId = 2, PresetClass = TimeNodePresetClassValues.MediaCall, PresetSubtype = 0, Fill = TimeNodeFillValues.Hold, NodeType = TimeNodeValues.ClickEffect }; StartConditionList startConditionList4 = new StartConditionList(); Condition condition4 = new Condition() { Delay = "0" }; startConditionList4.Append(condition4); ChildTimeNodeList childTimeNodeList5 = new ChildTimeNodeList(); Command command1 = new Command() { Type = CommandValues.Call, CommandName = "togglePause" }; CommonBehavior commonBehavior1 = new CommonBehavior(); CommonTimeNode commonTimeNode6 = new CommonTimeNode() { Id = (UInt32Value)6U, Duration = "1", Fill = TimeNodeFillValues.Hold }; TargetElement targetElement2 = new TargetElement(); ShapeTarget shapeTarget2 = new ShapeTarget() { ShapeId = "3" }; targetElement2.Append(shapeTarget2); commonBehavior1.Append(commonTimeNode6); commonBehavior1.Append(targetElement2); command1.Append(commonBehavior1); childTimeNodeList5.Append(command1); commonTimeNode5.Append(startConditionList4); commonTimeNode5.Append(childTimeNodeList5); parallelTimeNode4.Append(commonTimeNode5); childTimeNodeList4.Append(parallelTimeNode4); commonTimeNode4.Append(startConditionList3); commonTimeNode4.Append(childTimeNodeList4); parallelTimeNode3.Append(commonTimeNode4); childTimeNodeList3.Append(parallelTimeNode3); commonTimeNode3.Append(startConditionList2); commonTimeNode3.Append(childTimeNodeList3); parallelTimeNode2.Append(commonTimeNode3); childTimeNodeList2.Append(parallelTimeNode2); commonTimeNode2.Append(startConditionList1); commonTimeNode2.Append(endSync1); commonTimeNode2.Append(childTimeNodeList2); NextConditionList nextConditionList1 = new NextConditionList(); Condition condition5 = new Condition() { Event = TriggerEventValues.OnClick, Delay = "0" }; TargetElement targetElement3 = new TargetElement(); ShapeTarget shapeTarget3 = new ShapeTarget() { ShapeId = "3" }; targetElement3.Append(shapeTarget3); condition5.Append(targetElement3); nextConditionList1.Append(condition5); sequenceTimeNode1.Append(commonTimeNode2); sequenceTimeNode1.Append(nextConditionList1); Video video1 = new Video(); CommonMediaNode commonMediaNode1 = new CommonMediaNode() { Volume = 80000 }; CommonTimeNode commonTimeNode7 = new CommonTimeNode() { Id = (UInt32Value)7U, Fill = TimeNodeFillValues.Hold, Display = false }; StartConditionList startConditionList5 = new StartConditionList(); Condition condition6 = new Condition() { Delay = "indefinite" }; startConditionList5.Append(condition6); commonTimeNode7.Append(startConditionList5); TargetElement targetElement4 = new TargetElement(); ShapeTarget shapeTarget4 = new ShapeTarget() { ShapeId = "3" }; targetElement4.Append(shapeTarget4); commonMediaNode1.Append(commonTimeNode7); commonMediaNode1.Append(targetElement4); video1.Append(commonMediaNode1); childTimeNodeList1.Append(sequenceTimeNode1); childTimeNodeList1.Append(video1); commonTimeNode1.Append(childTimeNodeList1); parallelTimeNode1.Append(commonTimeNode1); timeNodeList1.Append(parallelTimeNode1); timing1.Append(timeNodeList1); slide.Append(timing1); }
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); }