@@ -38,7 +38,7 @@ public class MotionPath : ContentControl
38
38
private readonly Storyboard _storyboard = new Storyboard ( ) ;
39
39
40
40
#endregion
41
-
41
+
42
42
public new double Width
43
43
{
44
44
get { return base . Width ; }
@@ -138,23 +138,27 @@ public MotionPath()
138
138
139
139
static MotionPath ( )
140
140
{
141
+ AutoRewindProperty = DependencyProperty . Register ( "AutoRewind" , typeof ( bool ) , typeof ( MotionPath ) , new PropertyMetadata ( false ) ) ;
142
+
141
143
CurrentPointProperty = DependencyProperty . Register ( "CurrentPoint" , typeof ( Point ) , typeof ( MotionPath ) , new PropertyMetadata ( new Point ( double . NaN , double . NaN ) ) ) ;
142
144
143
- AutoRewindProperty = DependencyProperty . Register ( "AutoRewind " , typeof ( bool ) , typeof ( MotionPath ) , new PropertyMetadata ( false ) ) ;
145
+ CurrentTimeProperty = DependencyProperty . Register ( "CurrentTime " , typeof ( TimeSpan ) , typeof ( MotionPath ) , new PropertyMetadata ( default ( TimeSpan ) ) ) ;
144
146
145
147
DurationProperty = DependencyProperty . Register ( "Duration" , typeof ( TimeSpan ) , typeof ( MotionPath ) , new PropertyMetadata ( TimeSpan . FromSeconds ( 1 ) ) ) ;
146
148
147
- StateProperty = DependencyProperty . Register ( "State" , typeof ( AnimationState ) , typeof ( MotionPath ) , new PropertyMetadata ( AnimationState . Ready ,
148
- delegate ( DependencyObject o , DependencyPropertyChangedEventArgs e )
149
- {
150
- var sender = ( MotionPath ) o ;
151
- var val = ( AnimationState ) e . NewValue ;
149
+ EasingFunctionProperty = DependencyProperty . Register ( "EasingFunction" , typeof ( EasingFunctionBase ) , typeof ( MotionPath ) , new PropertyMetadata ( default ( EasingFunctionBase ) ) ) ;
152
150
153
- sender . StateChanged ? . Invoke ( sender , val ) ;
154
- if ( val == AnimationState . Complete )
155
- sender . Completed ? . Invoke ( sender ) ;
156
- } ) ) ;
151
+ LineRelativeEndProperty = DependencyProperty . Register ( "LineRelativeEnd" , typeof ( Point ) , typeof ( MotionPath ) ,
152
+ new PropertyMetadata ( new Point ( double . NaN , double . NaN ) , RefreshCalculations ) ) ;
157
153
154
+ LineAbsoluteStartProperty = DependencyProperty . Register ( "LineAbsoluteStart" , typeof ( Point ) , typeof ( MotionPath ) ,
155
+ new PropertyMetadata ( new Point ( double . NaN , double . NaN ) , RefreshCalculations ) ) ;
156
+
157
+ LineAbsoluteEndProperty = DependencyProperty . Register ( "LineAbsoluteEnd" , typeof ( Point ) , typeof ( MotionPath ) ,
158
+ new PropertyMetadata ( new Point ( double . NaN , double . NaN ) , RefreshCalculations ) ) ;
159
+
160
+ OrientToPathProperty = DependencyProperty . Register ( "OrientToPath" , typeof ( bool ) , typeof ( MotionPath ) , new PropertyMetadata ( default ( bool ) ) ) ;
161
+
158
162
ProgressProperty = DependencyProperty . Register ( "Progress" , typeof ( double ) , typeof ( MotionPath ) , new PropertyMetadata ( 0.0 ,
159
163
delegate ( DependencyObject o , DependencyPropertyChangedEventArgs e )
160
164
{
@@ -169,22 +173,18 @@ static MotionPath()
169
173
sender . UpdatePathData ( data ) ;
170
174
} ) ) ;
171
175
172
- LineAbsoluteStartProperty = DependencyProperty . Register ( "LineAbsoluteStart" , typeof ( Point ) , typeof ( MotionPath ) ,
173
- new PropertyMetadata ( new Point ( double . NaN , double . NaN ) , RefreshCalculations ) ) ;
174
-
175
- LineAbsoluteEndProperty = DependencyProperty . Register ( "LineAbsoluteEnd" , typeof ( Point ) , typeof ( MotionPath ) ,
176
- new PropertyMetadata ( new Point ( double . NaN , double . NaN ) , RefreshCalculations ) ) ;
177
-
178
- LineRelativeEndProperty = DependencyProperty . Register ( "LineRelativeEnd" , typeof ( Point ) , typeof ( MotionPath ) ,
179
- new PropertyMetadata ( new Point ( double . NaN , double . NaN ) , RefreshCalculations ) ) ;
180
-
181
- PathVisibilityProperty = DependencyProperty . Register ( "PathVisibility" , typeof ( Visibility ) , typeof ( MotionPath ) , new PropertyMetadata ( default ( Visibility ) ) ) ;
182
-
183
- CurrentTimeProperty = DependencyProperty . Register ( "CurrentTime" , typeof ( TimeSpan ) , typeof ( MotionPath ) , new PropertyMetadata ( default ( TimeSpan ) ) ) ;
184
-
185
- OrientToPathProperty = DependencyProperty . Register ( "OrientToPath" , typeof ( bool ) , typeof ( MotionPath ) , new PropertyMetadata ( default ( bool ) ) ) ;
186
-
187
- EasingFunctionProperty = DependencyProperty . Register ( "EasingFunction" , typeof ( EasingFunctionBase ) , typeof ( MotionPath ) , new PropertyMetadata ( default ( EasingFunctionBase ) ) ) ;
176
+ PathVisibilityProperty = DependencyProperty . Register ( "PathVisibility" , typeof ( Visibility ) , typeof ( MotionPath ) , new PropertyMetadata ( default ( Visibility ) ) ) ;
177
+
178
+ StateProperty = DependencyProperty . Register ( "State" , typeof ( AnimationState ) , typeof ( MotionPath ) , new PropertyMetadata ( AnimationState . Ready ,
179
+ delegate ( DependencyObject o , DependencyPropertyChangedEventArgs e )
180
+ {
181
+ var sender = ( MotionPath ) o ;
182
+ var val = ( AnimationState ) e . NewValue ;
183
+
184
+ sender . StateChanged ? . Invoke ( sender , val ) ;
185
+ if ( val == AnimationState . Complete )
186
+ sender . Completed ? . Invoke ( sender ) ;
187
+ } ) ) ;
188
188
}
189
189
190
190
private static void RefreshCalculations ( DependencyObject o , DependencyPropertyChangedEventArgs e )
@@ -203,17 +203,21 @@ private static void RefreshCalculations(DependencyObject o, DependencyPropertyCh
203
203
public delegate void StateChangedEventHandler ( object sender , AnimationState state ) ;
204
204
public delegate void EventHandler ( object sender ) ;
205
205
/// <summary>
206
- /// Raised when state is ready and we are starting a new animation
206
+ /// Occurs when state is ready and we are starting a new animation
207
207
/// </summary>
208
208
public event CancelEventHandler Starting ;
209
209
/// <summary>
210
- /// Raising when a new animation starts
210
+ /// Occurs when a new animation starts
211
211
/// </summary>
212
212
public event EventHandler Started ;
213
213
/// <summary>
214
- /// Raising when an animation completes
214
+ /// Occurs when an animation completes
215
215
/// </summary>
216
216
public event EventHandler Completed ;
217
+
218
+ /// <summary>
219
+ /// Occurs when animation state changes.
220
+ /// </summary>
217
221
public event StateChangedEventHandler StateChanged ;
218
222
#endregion
219
223
@@ -262,12 +266,19 @@ private static void RefreshCalculations(DependencyObject o, DependencyPropertyCh
262
266
263
267
#region public methods
264
268
269
+ /// <summary>
270
+ /// Starts the animation
271
+ /// </summary>
265
272
public void Start ( )
266
273
{
267
274
TryStart ( ) ;
268
275
Started ? . Invoke ( this ) ;
269
276
}
270
277
278
+ /// <summary>
279
+ /// Starts the animation asynchronously
280
+ /// </summary>
281
+ /// <returns></returns>
271
282
public async Task StartAsync ( )
272
283
{
273
284
await Task . Run ( delegate
@@ -340,7 +351,7 @@ private void StartProgressAnimation()
340
351
} ) ;
341
352
}
342
353
343
- if ( Path == null || true )
354
+ if ( Path == null )
344
355
{
345
356
CalculateLineMovement ( ) ;
346
357
_initialContentPoint = GetChildAbsolutePoint ( ) ;
@@ -356,6 +367,9 @@ private void StartProgressAnimation()
356
367
_storyboard . Begin ( ) ;
357
368
}
358
369
370
+ /// <summary>
371
+ /// Resets current animation and child position
372
+ /// </summary>
359
373
public void Reset ( )
360
374
{
361
375
if ( State != AnimationState . Ready )
@@ -370,6 +384,9 @@ public void Reset()
370
384
CalculateLineMovement ( ) ;
371
385
}
372
386
387
+ /// <summary>
388
+ /// Rewinds the animation when playing
389
+ /// </summary>
373
390
public void RewindNow ( )
374
391
{
375
392
if ( AutoRewind )
@@ -383,7 +400,9 @@ public void RewindNow()
383
400
}
384
401
}
385
402
386
-
403
+ /// <summary>
404
+ /// Pauses the animation
405
+ /// </summary>
387
406
public void Pause ( )
388
407
{
389
408
if ( State == AnimationState . Running || State == AnimationState . Rewinding )
0 commit comments