/// <summary> /// This method will be called when the animation behaviour has loaded /// </summary> /// <param name="sender">The object that has initialized the method</param> /// <param name="e">The routed event arguments</param> private void AnimationBehavior_OnLoaded(object sender, RoutedEventArgs e) { PgbLoading.Visibility = Visibility.Collapsed; ImgView.Visibility = Visibility.Visible; if (_animator != null) { _animator.CurrentFrameChanged -= CurrentFrameChanged; _animator.AnimationCompleted -= AnimationCompleted; } _animator = AnimationBehavior.GetAnimator(ImgView); if (_animator == null) { return; } _animator.CurrentFrameChanged += CurrentFrameChanged; _animator.AnimationCompleted += AnimationCompleted; SldFrame.Value = 0; SldFrame.Maximum = _animator.FrameCount - 1; LblDimensions.Content = ImgView.Source.Width + " x " + ImgView.Source.Height; LblSize.Content = (new FileInfo(_currentPath).Length / 1024f / 1024f).ToString("F2") + " MB"; LblFrames.Content = "Frames: " + ImageUtils.GetFrameCount(_currentPath); }
private void AnimationBehavior_OnLoaded(object sender, RoutedEventArgs e) { try { animator = AnimationBehavior.GetAnimator(gifImg); animator.Play(); } catch //prevents playback(crash otherwise), error gets logged in ErrorEvent() { } }
private void AnimationBehavior_OnLoaded(object sender, RoutedEventArgs e) { if (_animator != null) { _animator.CurrentFrameChanged -= CurrentFrameChanged; _animator.AnimationCompleted -= AnimationCompleted; } _animator = AnimationBehavior.GetAnimator(img); if (_animator != null) { _animator.CurrentFrameChanged += CurrentFrameChanged; _animator.AnimationCompleted += AnimationCompleted; sldPosition.Value = 0; sldPosition.Maximum = _animator.FrameCount - 1; SetPlayPauseEnabled(_animator.IsPaused || _animator.IsComplete); } }
private void ImageChanged() { if (_animator != null) { _animator.CurrentFrameChanged -= CurrentFrameChanged; _animator.AnimationCompleted -= AnimationCompleted; } _animator = AnimationBehavior.GetAnimator(img); if (_animator != null) { _animator.CurrentFrameChanged += CurrentFrameChanged; _animator.AnimationCompleted += AnimationCompleted; sldPosition.Value = 0; sldPosition.Maximum = _animator.FrameCount - 1; SetPlayPauseEnabled(_animator.IsPaused || _animator.IsComplete); } }
private void AnimationBehavior_OnLoaded(object sender, RoutedEventArgs e) { timerImageChange.Stop(); GC.Collect(); _animator = AnimationBehavior.GetAnimator(myImage); if (_animator != null) { int Frames = _animator.FrameCount; int gifInterval = (int)Math.Ceiling((decimal)(Frames / 24)); if (gifInterval == 0) { gifInterval = 1; } if (gifInterval < 3) { gifInterval = gifInterval * 3; } timerImageChange.Interval = new TimeSpan(0, 0, gifInterval); } timerImageChange.Start(); }
private System.Windows.Controls.Image AddImageAttachment(string url, int?width, int?height) { System.Windows.Controls.Image image = new System.Windows.Controls.Image(); image.HorizontalAlignment = HorizontalAlignment.Left; image.VerticalAlignment = VerticalAlignment.Top; if (width.HasValue) { image.MaxWidth = width.Value; } if (height.HasValue) { image.MaxHeight = height.Value; } image.Stretch = Stretch.Uniform; if (System.IO.Path.GetExtension(url) == ".gif") { AnimationBehavior.SetSourceUri(image, new Uri(url)); image.MouseEnter += (o, e) => { AnimationBehavior.GetAnimator(image).Play(); }; image.MouseLeave += (o, e) => { AnimationBehavior.GetAnimator(image).Pause(); }; } else { image.Source = Images.GetImage(url); } image.ContextMenu = GetAttachmentContextMenu(url); image.Visibility = Visibility.Collapsed; mainContent.Children.Add(image); MouseDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) { if (image.Visibility == Visibility.Collapsed) { image.Visibility = Visibility.Visible; } else { image.Visibility = Visibility.Collapsed; try { Animator anim = AnimationBehavior.GetAnimator(image); if (anim != null) { anim.Rewind(); } } catch { } } } }; return(image); }