@@ -61,6 +61,7 @@ private sealed record AnimationFactory<T>(
6161 T ? From ,
6262 TimeSpan Delay ,
6363 TimeSpan Duration ,
64+ RepeatOption Repeat ,
6465 EasingType EasingType ,
6566 EasingMode EasingMode )
6667 : ICompositionAnimationFactory , IXamlAnimationFactory
@@ -70,6 +71,7 @@ private sealed record AnimationFactory<T>(
7071 public CompositionAnimation GetAnimation ( CompositionObject targetHint , out CompositionObject ? target )
7172 {
7273 CompositionEasingFunction ? easingFunction = targetHint . Compositor . TryCreateEasingFunction ( EasingType , EasingMode ) ;
74+ ( AnimationIterationBehavior iterationBehavior , int iterationCount ) = Repeat . ToBehaviorAndCount ( ) ;
7375
7476 target = null ;
7577
@@ -80,7 +82,9 @@ public CompositionAnimation GetAnimation(CompositionObject targetHint, out Compo
8082 GetToAs < bool > ( ) ,
8183 GetFromAs < bool > ( ) ,
8284 Delay ,
83- Duration ) ;
85+ Duration ,
86+ iterationBehavior : iterationBehavior ,
87+ iterationCount : iterationCount ) ;
8488 }
8589
8690 if ( typeof ( T ) == typeof ( float ) )
@@ -91,7 +95,9 @@ public CompositionAnimation GetAnimation(CompositionObject targetHint, out Compo
9195 GetFromAs < float > ( ) ,
9296 Delay ,
9397 Duration ,
94- easingFunction ) ;
98+ easingFunction ,
99+ iterationBehavior : iterationBehavior ,
100+ iterationCount : iterationCount ) ;
95101 }
96102
97103 if ( typeof ( T ) == typeof ( double ) )
@@ -102,7 +108,9 @@ public CompositionAnimation GetAnimation(CompositionObject targetHint, out Compo
102108 ( float ? ) GetFromAs < double > ( ) ,
103109 Delay ,
104110 Duration ,
105- easingFunction ) ;
111+ easingFunction ,
112+ iterationBehavior : iterationBehavior ,
113+ iterationCount : iterationCount ) ;
106114 }
107115
108116 if ( typeof ( T ) == typeof ( Vector2 ) )
@@ -113,7 +121,9 @@ public CompositionAnimation GetAnimation(CompositionObject targetHint, out Compo
113121 GetFromAs < Vector2 > ( ) ,
114122 Delay ,
115123 Duration ,
116- easingFunction ) ;
124+ easingFunction ,
125+ iterationBehavior : iterationBehavior ,
126+ iterationCount : iterationCount ) ;
117127 }
118128
119129 if ( typeof ( T ) == typeof ( Vector3 ) )
@@ -124,7 +134,9 @@ public CompositionAnimation GetAnimation(CompositionObject targetHint, out Compo
124134 GetFromAs < Vector3 > ( ) ,
125135 Delay ,
126136 Duration ,
127- easingFunction ) ;
137+ easingFunction ,
138+ iterationBehavior : iterationBehavior ,
139+ iterationCount : iterationCount ) ;
128140 }
129141
130142 if ( typeof ( T ) == typeof ( Vector4 ) )
@@ -135,7 +147,9 @@ public CompositionAnimation GetAnimation(CompositionObject targetHint, out Compo
135147 GetFromAs < Vector4 > ( ) ,
136148 Delay ,
137149 Duration ,
138- easingFunction ) ;
150+ easingFunction ,
151+ iterationBehavior : iterationBehavior ,
152+ iterationCount : iterationCount ) ;
139153 }
140154
141155 if ( typeof ( T ) == typeof ( Color ) )
@@ -146,7 +160,9 @@ public CompositionAnimation GetAnimation(CompositionObject targetHint, out Compo
146160 GetFromAs < Color > ( ) ,
147161 Delay ,
148162 Duration ,
149- easingFunction ) ;
163+ easingFunction ,
164+ iterationBehavior : iterationBehavior ,
165+ iterationCount : iterationCount ) ;
150166 }
151167
152168 if ( typeof ( T ) == typeof ( Quaternion ) )
@@ -157,7 +173,9 @@ public CompositionAnimation GetAnimation(CompositionObject targetHint, out Compo
157173 GetFromAs < Quaternion > ( ) ,
158174 Delay ,
159175 Duration ,
160- easingFunction ) ;
176+ easingFunction ,
177+ iterationBehavior : iterationBehavior ,
178+ iterationCount : iterationCount ) ;
161179 }
162180
163181 throw new InvalidOperationException ( "Invalid animation type" ) ;
@@ -177,6 +195,7 @@ public Timeline GetAnimation(DependencyObject targetHint)
177195 Delay ,
178196 Duration ,
179197 easingFunction ,
198+ Repeat . ToRepeatBehavior ( ) ,
180199 enableDependecyAnimations : true ) ;
181200 }
182201
@@ -189,6 +208,7 @@ public Timeline GetAnimation(DependencyObject targetHint)
189208 Delay ,
190209 Duration ,
191210 easingFunction ,
211+ Repeat . ToRepeatBehavior ( ) ,
192212 enableDependecyAnimations : true ) ;
193213 }
194214
@@ -201,6 +221,7 @@ public Timeline GetAnimation(DependencyObject targetHint)
201221 Delay ,
202222 Duration ,
203223 easingFunction ,
224+ Repeat . ToRepeatBehavior ( ) ,
204225 enableDependecyAnimations : true ) ;
205226 }
206227
@@ -212,7 +233,8 @@ public Timeline GetAnimation(DependencyObject targetHint)
212233 GetFromAs < Color > ( ) ,
213234 Delay ,
214235 Duration ,
215- easingFunction ) ;
236+ easingFunction ,
237+ Repeat . ToRepeatBehavior ( ) ) ;
216238 }
217239
218240 throw new InvalidOperationException ( "Invalid animation type" ) ;
@@ -287,6 +309,7 @@ private sealed record CompositionClipScalarAnimation(
287309 float ? From ,
288310 TimeSpan Delay ,
289311 TimeSpan Duration ,
312+ RepeatOption Repeat ,
290313 EasingType EasingType ,
291314 EasingMode EasingMode )
292315 : ICompositionAnimationFactory
@@ -297,7 +320,16 @@ public CompositionAnimation GetAnimation(CompositionObject targetHint, out Compo
297320 Visual visual = ( Visual ) targetHint ;
298321 InsetClip clip = visual . Clip as InsetClip ?? ( InsetClip ) ( visual . Clip = visual . Compositor . CreateInsetClip ( ) ) ;
299322 CompositionEasingFunction ? easingFunction = clip . Compositor . TryCreateEasingFunction ( EasingType , EasingMode ) ;
300- ScalarKeyFrameAnimation animation = clip . Compositor . CreateScalarKeyFrameAnimation ( Property , To , From , Delay , Duration , easingFunction ) ;
323+ ( AnimationIterationBehavior iterationBehavior , int iterationCount ) = Repeat . ToBehaviorAndCount ( ) ;
324+ ScalarKeyFrameAnimation animation = clip . Compositor . CreateScalarKeyFrameAnimation (
325+ Property ,
326+ To ,
327+ From ,
328+ Delay ,
329+ Duration ,
330+ easingFunction ,
331+ iterationBehavior : iterationBehavior ,
332+ iterationCount : iterationCount ) ;
301333
302334 target = clip ;
303335
@@ -314,6 +346,7 @@ private sealed record XamlTransformDoubleAnimationFactory(
314346 double ? From ,
315347 TimeSpan Delay ,
316348 TimeSpan Duration ,
349+ RepeatOption Repeat ,
317350 EasingType EasingType ,
318351 EasingMode EasingMode )
319352 : IXamlAnimationFactory
@@ -328,7 +361,14 @@ public Timeline GetAnimation(DependencyObject targetHint)
328361 element . RenderTransform = transform = new CompositeTransform ( ) ;
329362 }
330363
331- return transform . CreateDoubleAnimation ( Property , To , From , Duration , Delay , EasingType . ToEasingFunction ( EasingMode ) ) ;
364+ return transform . CreateDoubleAnimation (
365+ Property ,
366+ To ,
367+ From ,
368+ Duration ,
369+ Delay ,
370+ EasingType . ToEasingFunction ( EasingMode ) ,
371+ Repeat . ToRepeatBehavior ( ) ) ;
332372 }
333373 }
334374
0 commit comments