private static async void InitAnimationAsync(Image image, Uri sourceUri, RepeatBehavior repeatBehavior, int seqNum) { if (!CheckDesignMode(image, sourceUri, null)) { return; } try { var animator = await Animator.CreateAsync(image, sourceUri, repeatBehavior); // Check that the source hasn't changed while we were loading the animation if (GetSeqNum(image) != seqNum) { animator.Dispose(); return; } await SetAnimatorCoreAsync(image, animator); OnLoaded(image); } catch (InvalidSignatureException) { image.Source = new BitmapImage(sourceUri); OnLoaded(image); } catch (Exception ex) { OnError(image, ex, AnimationErrorKind.Loading); } }
private static async void InitAnimationAsync(Image image, Stream stream, RepeatBehavior repeatBehavior) { if (!CheckDesignMode(image, null, stream)) { return; } try { var animator = await Animator.CreateAsync(stream, repeatBehavior); SetAnimatorCore(image, animator); } catch (Exception ex) { OnError(image, ex, AnimationErrorKind.Loading); } }
private static async void InitAnimationAsync(Image image, Stream stream, RepeatBehavior repeatBehavior, int seqNum) { if (!CheckDesignMode(image, null, stream)) { return; } try { var animator = await Animator.CreateAsync(image, stream, repeatBehavior); await SetAnimatorCoreAsync(image, animator); // Check that the source hasn't changed while we were loading the animation if (GetSeqNum(image) != seqNum) { animator.Dispose(); return; } OnLoaded(image); } catch (InvalidSignatureException) { var bmp = new BitmapImage(); #if WPF bmp.BeginInit(); bmp.StreamSource = stream; bmp.EndInit(); #elif WINRT bmp.SetSource(stream.AsRandomAccessStream()); #endif image.Source = bmp; OnLoaded(image); } catch (Exception ex) { OnError(image, ex, AnimationErrorKind.Loading); } }
private static async void InitAnimationAsync(Image image, Uri sourceUri, CancellationToken cancellationToken, RepeatBehavior repeatBehavior, int seqNum) { if (!AnimationBehavior.CheckDesignMode(image, sourceUri, null)) { return; } try { // ISSUE: reference to a compiler-generated field Animator.DownloadProgressChanged += AnimationBehavior.DownloadProgressChanged; Animator async = await Animator.CreateAsync(image, sourceUri, cancellationToken, repeatBehavior); // ISSUE: reference to a compiler-generated field Animator.DownloadProgressChanged -= AnimationBehavior.DownloadProgressChanged; if (async == null || AnimationBehavior.GetSeqNum((DependencyObject)image) != seqNum) { if (async == null) { return; } // ISSUE: explicit non-virtual call async.Dispose(); } else { AnimationBehavior.SetAnimatorCore(image, async); AnimationBehavior.OnLoaded(image); } } catch (Exception ex) { // ISSUE: reference to a compiler-generated field Animator.DownloadProgressChanged -= AnimationBehavior.DownloadProgressChanged; AnimationBehavior.OnError(image, ex, AnimationErrorKind.Loading); } }
internal static Task <Animator> CreateAsync(Image image, Stream sourceStream, RepeatBehavior repeatBehavior = default(RepeatBehavior)) { return(Animator.CreateAsync(sourceStream, null, repeatBehavior, image)); }