Ruben 1 년 전
부모
커밋
1edb3135f9

+ 1 - 7
src/XamlAnimatedGif/AnimationCompletedEventArgs.cs

@@ -4,10 +4,4 @@ namespace XamlAnimatedGif;
 
 
 public delegate void AnimationCompletedEventHandler(DependencyObject d, AnimationCompletedEventArgs e);
 public delegate void AnimationCompletedEventHandler(DependencyObject d, AnimationCompletedEventArgs e);
 
 
-public class AnimationCompletedEventArgs : RoutedEventArgs
-{
-    public AnimationCompletedEventArgs(object source)
-        : base(AnimationBehavior.AnimationCompletedEvent, source)
-    {
-    }
-}
+public class AnimationCompletedEventArgs(object source) : RoutedEventArgs(AnimationBehavior.AnimationCompletedEvent, source);

+ 3 - 10
src/XamlAnimatedGif/AnimationErrorEventArgs.cs

@@ -4,18 +4,11 @@ namespace XamlAnimatedGif;
 
 
 public delegate void AnimationErrorEventHandler(DependencyObject d, AnimationErrorEventArgs e);
 public delegate void AnimationErrorEventHandler(DependencyObject d, AnimationErrorEventArgs e);
 
 
-public class AnimationErrorEventArgs : RoutedEventArgs
+public class AnimationErrorEventArgs(object source, Exception exception, AnimationErrorKind kind) : RoutedEventArgs(AnimationBehavior.ErrorEvent, source)
 {
 {
-    public AnimationErrorEventArgs(object source, Exception exception, AnimationErrorKind kind)
-        : base(AnimationBehavior.ErrorEvent, source)
-    {
-        Exception = exception;
-        Kind = kind;
-    }
+    public Exception Exception { get; } = exception;
 
 
-    public Exception Exception { get; }
-
-    public AnimationErrorKind Kind { get; }
+    public AnimationErrorKind Kind { get; } = kind;
 }
 }
 
 
 public enum AnimationErrorKind
 public enum AnimationErrorKind

+ 1 - 7
src/XamlAnimatedGif/AnimationStartedEventArgs.cs

@@ -4,10 +4,4 @@ namespace XamlAnimatedGif;
 
 
 public delegate void AnimationStartedEventHandler(DependencyObject d, AnimationStartedEventArgs e);
 public delegate void AnimationStartedEventHandler(DependencyObject d, AnimationStartedEventArgs e);
 
 
-public class AnimationStartedEventArgs : RoutedEventArgs
-{
-    public AnimationStartedEventArgs(object source)
-        : base(AnimationBehavior.AnimationStartedEvent, source)
-    {
-    }
-}
+public class AnimationStartedEventArgs(object source) : RoutedEventArgs(AnimationBehavior.AnimationStartedEvent, source);

+ 1 - 1
src/XamlAnimatedGif/Animator.cs

@@ -271,7 +271,7 @@ public abstract class Animator : DependencyObject, IDisposable
     private static Dictionary<int, GifPalette> CreatePalettes(GifDataStream metadata)
     private static Dictionary<int, GifPalette> CreatePalettes(GifDataStream metadata)
     {
     {
         var palettes = new Dictionary<int, GifPalette>();
         var palettes = new Dictionary<int, GifPalette>();
-        Color[] globalColorTable = null;
+        Color[]? globalColorTable = null;
         if (metadata.Header.LogicalScreenDescriptor.HasGlobalColorTable)
         if (metadata.Header.LogicalScreenDescriptor.HasGlobalColorTable)
         {
         {
             globalColorTable =
             globalColorTable =

+ 15 - 20
src/XamlAnimatedGif/TimingManager.cs

@@ -45,25 +45,25 @@ internal class TimingManager
             }
             }
         }
         }
 
 
-        if (_current >= _timeSpans.Count)
+        if (_current < _timeSpans.Count)
         {
         {
-            _count++;
-            if (repeatBehavior.HasCount)
-            {
-                if (_count < repeatBehavior.Count)
-                {
-                    _current = 0;
-                    return true;
-                }
+            return true;
+        }
 
 
-                IsComplete = true;
-                return false;
+        _count++;
+        if (repeatBehavior.HasCount)
+        {
+            if (_count < repeatBehavior.Count)
+            {
+                _current = 0;
+                return true;
             }
             }
 
 
-            _current = 0;
-            return true;
+            IsComplete = true;
+            return false;
         }
         }
 
 
+        _current = 0;
         return true;
         return true;
     }
     }
 
 
@@ -94,7 +94,7 @@ internal class TimingManager
     }
     }
 
 
     private readonly Task _completedTask = Task.FromResult(0);
     private readonly Task _completedTask = Task.FromResult(0);
-    private TaskCompletionSource<int> _pauseCompletionSource;
+    private TaskCompletionSource<int>? _pauseCompletionSource;
 
 
     public void Pause()
     public void Pause()
     {
     {
@@ -117,11 +117,6 @@ internal class TimingManager
     private Task IsPausedAsync(CancellationToken cancellationToken)
     private Task IsPausedAsync(CancellationToken cancellationToken)
     {
     {
         var tcs = _pauseCompletionSource;
         var tcs = _pauseCompletionSource;
-        if (tcs != null)
-        {
-            return tcs.Task.WithCancellationToken(cancellationToken);
-        }
-
-        return _completedTask;
+        return tcs?.Task.WithCancellationToken(cancellationToken) ?? _completedTask;
     }
     }
 }
 }