Skip to content

Commit ad1df93

Browse files
Merge pull request #25 from openize-com/muhammadumar-patch
Refactored Animation System + New Bounce Animation
2 parents 9241a8e + fd722a6 commit ad1df93

File tree

11 files changed

+1737
-964
lines changed

11 files changed

+1737
-964
lines changed

PowerPoint/Openize.Slides.Common/Enumerations.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public enum AnimationType
2828
Zoom, // Zoom in or out
2929
FlyIn, // Fly into the slide
3030
Spin, // Spin in place
31-
FloatIn // Custom animation defined by the user
31+
FloatIn, // FloatIn
32+
Bounce, // Bounce
3233
}
3334

3435
}

PowerPoint/Openize.Slides.Common/Utility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public OpenizeException (string message, Exception innerException) : base(messag
201201

202202
public static string ConstructMessage (Exception Ex, string Operation)
203203
{
204-
return $"Error in Operation {Operation} at Openize.Words: {Ex.Message} \n Inner Exception: {Ex.InnerException?.Message ?? "N/A"}";
204+
return $"Error in Operation {Operation} at Openize.OpenXML-SDK: {Ex.Message} \n Inner Exception: {Ex.InnerException?.Message ?? "N/A"}";
205205
}
206206
}
207207

PowerPoint/Openize.Slides.Facade/AnimationFacade.cs

Lines changed: 14 additions & 961 deletions
Large diffs are not rendered by default.

PowerPoint/Openize.Slides.Facade/Openize.Slides.Facade.Animations/Bounce.cs

Lines changed: 689 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using DocumentFormat.OpenXml;
5+
using DocumentFormat.OpenXml.Presentation;
6+
7+
8+
namespace Openize.Slides.Facade.Animations
9+
{
10+
internal class FloatIn : IAnimation
11+
{
12+
public Timing Generate(string shapeId, int duration)
13+
{
14+
Timing timing = GenerateFloatInTiming(shapeId, duration);
15+
return timing;
16+
}
17+
public Timing GenerateFloatInTiming(String shapeId, int duration)
18+
{
19+
Timing timing1 = new Timing();
20+
21+
TimeNodeList timeNodeList1 = new TimeNodeList();
22+
23+
ParallelTimeNode parallelTimeNode1 = new ParallelTimeNode();
24+
25+
CommonTimeNode commonTimeNode1 = new CommonTimeNode() { Id = (UInt32Value)1U, Duration = "indefinite", Restart = TimeNodeRestartValues.Never, NodeType = TimeNodeValues.TmingRoot };
26+
27+
ChildTimeNodeList childTimeNodeList1 = new ChildTimeNodeList();
28+
29+
SequenceTimeNode sequenceTimeNode1 = new SequenceTimeNode() { Concurrent = true, NextAction = NextActionValues.Seek };
30+
31+
CommonTimeNode commonTimeNode2 = new CommonTimeNode() { Id = (UInt32Value)2U, Duration = "indefinite", NodeType = TimeNodeValues.MainSequence };
32+
33+
ChildTimeNodeList childTimeNodeList2 = new ChildTimeNodeList();
34+
35+
ParallelTimeNode parallelTimeNode2 = new ParallelTimeNode();
36+
37+
CommonTimeNode commonTimeNode3 = new CommonTimeNode() { Id = (UInt32Value)3U, Fill = TimeNodeFillValues.Hold };
38+
39+
StartConditionList startConditionList1 = new StartConditionList();
40+
Condition condition1 = new Condition() { Delay = "indefinite" };
41+
42+
startConditionList1.Append(condition1);
43+
44+
ChildTimeNodeList childTimeNodeList3 = new ChildTimeNodeList();
45+
46+
ParallelTimeNode parallelTimeNode3 = new ParallelTimeNode();
47+
48+
CommonTimeNode commonTimeNode4 = new CommonTimeNode() { Id = (UInt32Value)4U, Fill = TimeNodeFillValues.Hold };
49+
50+
StartConditionList startConditionList2 = new StartConditionList();
51+
Condition condition2 = new Condition() { Delay = "0" };
52+
53+
startConditionList2.Append(condition2);
54+
55+
ChildTimeNodeList childTimeNodeList4 = new ChildTimeNodeList();
56+
57+
ParallelTimeNode parallelTimeNode4 = new ParallelTimeNode();
58+
59+
CommonTimeNode commonTimeNode5 = new CommonTimeNode() { Id = (UInt32Value)5U, PresetId = 42, PresetClass = TimeNodePresetClassValues.Entrance, PresetSubtype = 0, Fill = TimeNodeFillValues.Hold, GroupId = (UInt32Value)0U, NodeType = TimeNodeValues.ClickEffect };
60+
61+
StartConditionList startConditionList3 = new StartConditionList();
62+
Condition condition3 = new Condition() { Delay = "0" };
63+
64+
startConditionList3.Append(condition3);
65+
66+
ChildTimeNodeList childTimeNodeList5 = new ChildTimeNodeList();
67+
68+
SetBehavior setBehavior1 = new SetBehavior();
69+
70+
CommonBehavior commonBehavior1 = new CommonBehavior();
71+
72+
CommonTimeNode commonTimeNode6 = new CommonTimeNode() { Id = (UInt32Value)6U, Duration = "1", Fill = TimeNodeFillValues.Hold };
73+
74+
StartConditionList startConditionList4 = new StartConditionList();
75+
Condition condition4 = new Condition() { Delay = "0" };
76+
77+
startConditionList4.Append(condition4);
78+
79+
commonTimeNode6.Append(startConditionList4);
80+
81+
TargetElement targetElement1 = new TargetElement();
82+
ShapeTarget shapeTarget1 = new ShapeTarget() { ShapeId = shapeId };
83+
84+
targetElement1.Append(shapeTarget1);
85+
86+
AttributeNameList attributeNameList1 = new AttributeNameList();
87+
AttributeName attributeName1 = new AttributeName();
88+
attributeName1.Text = "style.visibility";
89+
90+
attributeNameList1.Append(attributeName1);
91+
92+
commonBehavior1.Append(commonTimeNode6);
93+
commonBehavior1.Append(targetElement1);
94+
commonBehavior1.Append(attributeNameList1);
95+
96+
ToVariantValue toVariantValue1 = new ToVariantValue();
97+
StringVariantValue stringVariantValue1 = new StringVariantValue() { Val = "visible" };
98+
99+
toVariantValue1.Append(stringVariantValue1);
100+
101+
setBehavior1.Append(commonBehavior1);
102+
setBehavior1.Append(toVariantValue1);
103+
104+
AnimateEffect animateEffect1 = new AnimateEffect() { Transition = AnimateEffectTransitionValues.In, Filter = "fade" };
105+
106+
CommonBehavior commonBehavior2 = new CommonBehavior();
107+
CommonTimeNode commonTimeNode7 = new CommonTimeNode() { Id = (UInt32Value)7U, Duration = duration.ToString() };
108+
109+
TargetElement targetElement2 = new TargetElement();
110+
ShapeTarget shapeTarget2 = new ShapeTarget() { ShapeId = shapeId };
111+
112+
targetElement2.Append(shapeTarget2);
113+
114+
commonBehavior2.Append(commonTimeNode7);
115+
commonBehavior2.Append(targetElement2);
116+
117+
animateEffect1.Append(commonBehavior2);
118+
119+
Animate animate1 = new Animate() { CalculationMode = AnimateBehaviorCalculateModeValues.Linear, ValueType = AnimateBehaviorValues.Number };
120+
121+
CommonBehavior commonBehavior3 = new CommonBehavior();
122+
CommonTimeNode commonTimeNode8 = new CommonTimeNode() { Id = (UInt32Value)8U, Duration = duration.ToString(), Fill = TimeNodeFillValues.Hold };
123+
124+
TargetElement targetElement3 = new TargetElement();
125+
ShapeTarget shapeTarget3 = new ShapeTarget() { ShapeId = shapeId };
126+
127+
targetElement3.Append(shapeTarget3);
128+
129+
AttributeNameList attributeNameList2 = new AttributeNameList();
130+
AttributeName attributeName2 = new AttributeName();
131+
attributeName2.Text = "ppt_x";
132+
133+
attributeNameList2.Append(attributeName2);
134+
135+
commonBehavior3.Append(commonTimeNode8);
136+
commonBehavior3.Append(targetElement3);
137+
commonBehavior3.Append(attributeNameList2);
138+
139+
TimeAnimateValueList timeAnimateValueList1 = new TimeAnimateValueList();
140+
141+
TimeAnimateValue timeAnimateValue1 = new TimeAnimateValue() { Time = "0" };
142+
143+
VariantValue variantValue1 = new VariantValue();
144+
StringVariantValue stringVariantValue2 = new StringVariantValue() { Val = "#ppt_x" };
145+
146+
variantValue1.Append(stringVariantValue2);
147+
148+
timeAnimateValue1.Append(variantValue1);
149+
150+
TimeAnimateValue timeAnimateValue2 = new TimeAnimateValue() { Time = "100000" };
151+
152+
VariantValue variantValue2 = new VariantValue();
153+
StringVariantValue stringVariantValue3 = new StringVariantValue() { Val = "#ppt_x" };
154+
155+
variantValue2.Append(stringVariantValue3);
156+
157+
timeAnimateValue2.Append(variantValue2);
158+
159+
timeAnimateValueList1.Append(timeAnimateValue1);
160+
timeAnimateValueList1.Append(timeAnimateValue2);
161+
162+
animate1.Append(commonBehavior3);
163+
animate1.Append(timeAnimateValueList1);
164+
165+
Animate animate2 = new Animate() { CalculationMode = AnimateBehaviorCalculateModeValues.Linear, ValueType = AnimateBehaviorValues.Number };
166+
167+
CommonBehavior commonBehavior4 = new CommonBehavior();
168+
CommonTimeNode commonTimeNode9 = new CommonTimeNode() { Id = (UInt32Value)9U, Duration = duration.ToString(), Fill = TimeNodeFillValues.Hold };
169+
170+
TargetElement targetElement4 = new TargetElement();
171+
ShapeTarget shapeTarget4 = new ShapeTarget() { ShapeId = shapeId };
172+
173+
targetElement4.Append(shapeTarget4);
174+
175+
AttributeNameList attributeNameList3 = new AttributeNameList();
176+
AttributeName attributeName3 = new AttributeName();
177+
attributeName3.Text = "ppt_y";
178+
179+
attributeNameList3.Append(attributeName3);
180+
181+
commonBehavior4.Append(commonTimeNode9);
182+
commonBehavior4.Append(targetElement4);
183+
commonBehavior4.Append(attributeNameList3);
184+
185+
TimeAnimateValueList timeAnimateValueList2 = new TimeAnimateValueList();
186+
187+
TimeAnimateValue timeAnimateValue3 = new TimeAnimateValue() { Time = "0" };
188+
189+
VariantValue variantValue3 = new VariantValue();
190+
StringVariantValue stringVariantValue4 = new StringVariantValue() { Val = "#ppt_y+.1" };
191+
192+
variantValue3.Append(stringVariantValue4);
193+
194+
timeAnimateValue3.Append(variantValue3);
195+
196+
TimeAnimateValue timeAnimateValue4 = new TimeAnimateValue() { Time = "100000" };
197+
198+
VariantValue variantValue4 = new VariantValue();
199+
StringVariantValue stringVariantValue5 = new StringVariantValue() { Val = "#ppt_y" };
200+
201+
variantValue4.Append(stringVariantValue5);
202+
203+
timeAnimateValue4.Append(variantValue4);
204+
205+
timeAnimateValueList2.Append(timeAnimateValue3);
206+
timeAnimateValueList2.Append(timeAnimateValue4);
207+
208+
animate2.Append(commonBehavior4);
209+
animate2.Append(timeAnimateValueList2);
210+
211+
childTimeNodeList5.Append(setBehavior1);
212+
childTimeNodeList5.Append(animateEffect1);
213+
childTimeNodeList5.Append(animate1);
214+
childTimeNodeList5.Append(animate2);
215+
216+
commonTimeNode5.Append(startConditionList3);
217+
commonTimeNode5.Append(childTimeNodeList5);
218+
219+
parallelTimeNode4.Append(commonTimeNode5);
220+
221+
childTimeNodeList4.Append(parallelTimeNode4);
222+
223+
commonTimeNode4.Append(startConditionList2);
224+
commonTimeNode4.Append(childTimeNodeList4);
225+
226+
parallelTimeNode3.Append(commonTimeNode4);
227+
228+
childTimeNodeList3.Append(parallelTimeNode3);
229+
230+
commonTimeNode3.Append(startConditionList1);
231+
commonTimeNode3.Append(childTimeNodeList3);
232+
233+
parallelTimeNode2.Append(commonTimeNode3);
234+
235+
childTimeNodeList2.Append(parallelTimeNode2);
236+
237+
commonTimeNode2.Append(childTimeNodeList2);
238+
239+
PreviousConditionList previousConditionList1 = new PreviousConditionList();
240+
241+
Condition condition5 = new Condition() { Event = TriggerEventValues.OnPrevious, Delay = "0" };
242+
243+
TargetElement targetElement5 = new TargetElement();
244+
SlideTarget slideTarget1 = new SlideTarget();
245+
246+
targetElement5.Append(slideTarget1);
247+
248+
condition5.Append(targetElement5);
249+
250+
previousConditionList1.Append(condition5);
251+
252+
NextConditionList nextConditionList1 = new NextConditionList();
253+
254+
Condition condition6 = new Condition() { Event = TriggerEventValues.OnNext, Delay = "0" };
255+
256+
TargetElement targetElement6 = new TargetElement();
257+
SlideTarget slideTarget2 = new SlideTarget();
258+
259+
targetElement6.Append(slideTarget2);
260+
261+
condition6.Append(targetElement6);
262+
263+
nextConditionList1.Append(condition6);
264+
265+
sequenceTimeNode1.Append(commonTimeNode2);
266+
sequenceTimeNode1.Append(previousConditionList1);
267+
sequenceTimeNode1.Append(nextConditionList1);
268+
269+
childTimeNodeList1.Append(sequenceTimeNode1);
270+
271+
commonTimeNode1.Append(childTimeNodeList1);
272+
273+
parallelTimeNode1.Append(commonTimeNode1);
274+
275+
timeNodeList1.Append(parallelTimeNode1);
276+
277+
BuildList buildList1 = new BuildList();
278+
BuildParagraph buildParagraph1 = new BuildParagraph() { ShapeId = shapeId, GroupId = (UInt32Value)0U, AnimateBackground = true };
279+
280+
buildList1.Append(buildParagraph1);
281+
282+
timing1.Append(timeNodeList1);
283+
timing1.Append(buildList1);
284+
return timing1;
285+
}
286+
287+
}
288+
}

0 commit comments

Comments
 (0)