Skip to content

Commit b65c589

Browse files
Added FlyIn Animation
1 parent db48fb8 commit b65c589

37 files changed

+916
-280
lines changed

FileFormat.Slides-Test/Program.cs

+7-5
Original file line numberDiff line numberDiff line change
@@ -523,22 +523,24 @@ static void Main()
523523
presentation.AppendSlide(slide);
524524
presentation.Save();*/
525525

526-
/* Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\draw.pptx");
526+
Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\draw.pptx");
527527
Slide slide = new Slide();
528528

529529
Trapezoid trapezoid = new Trapezoid();
530+
trapezoid.Animation = FileFormat.Slides.Common.Enumerations.AnimationType.FlyIn;
530531
trapezoid.Width = 300.0;
531532
trapezoid.Height = 300.0;
532533
trapezoid.X = 300.0;
533534
trapezoid.Y = 300.0;
534535
slide.DrawTrapezoid(trapezoid);
535536
presentation.AppendSlide(slide);
536-
presentation.Save();*/
537-
/*
538-
Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\draw.pptx");
537+
presentation.Save();
538+
539+
/* Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\draw.pptx");
539540
Slide slide = new Slide();
540-
541+
541542
Pie pie = new Pie();
543+
pie.Animation = FileFormat.Slides.Common.Enumerations.AnimationType.FlyIn;
542544
pie.Width = 300.0;
543545
pie.Height = 300.0;
544546
pie.X = 300.0;

FileFormat.Slides.Common/Enumerations.cs

+21
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,26 @@ public enum ListType
2222
Bulleted,
2323
Numbered
2424
}
25+
public enum AnimationType
26+
{
27+
None, // No animation
28+
Fade, // Fade in or out
29+
Wipe, // Wipe across the screen
30+
Zoom, // Zoom in or out
31+
FlyIn, // Fly into the slide
32+
FlyOut, // Fly out of the slide
33+
Bounce, // Bounce effect
34+
Spin, // Spin in place
35+
GrowShrink, // Grow or shrink in size
36+
Flip, // Flip horizontally or vertically
37+
Slide, // Slide in or out
38+
Morph, // Morph between shapes or objects
39+
Appear, // Appear suddenly
40+
Dissolve, // Dissolve into view
41+
Split, // Split apart
42+
Wheel, // Wheel animation
43+
Float, // Float in or out
44+
Custom // Custom animation defined by the user
45+
}
2546

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

FileFormat.Slides.Facade/ArrowFacade.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public class ArrowFacade
2525
private P.Shape _ArrowShape;
2626
private SlidePart _AssociatedSlidePart;// Store the P.Shape as a private field
2727
private int _ShapeIndex;
28-
29-
28+
private AnimationType _Animation = AnimationType.None;
29+
3030
private String _BackgroundColor;
3131
private ListFacade _TextList = null;
3232

@@ -39,6 +39,7 @@ public class ArrowFacade
3939
public int ShapeIndex { get => _ShapeIndex; set => _ShapeIndex = value; }
4040
public string BackgroundColor { get => _BackgroundColor; set => _BackgroundColor = value; }
4141
public ListFacade TextList { get => _TextList; set => _TextList = value; }
42+
public AnimationType Animation { get => _Animation; set => _Animation = value; }
4243

4344
public ArrowFacade()
4445
{

0 commit comments

Comments
 (0)