/// <summary> /// Method to handle property changed event of AnimationSourcePath property. /// </summary> /// <param name="obj">Source image.</param> /// <param name="ev">Event arguments.</param> protected static void AnimationSourcePathPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs ev) { GifImage ob = obj as GifImage; ob.BeginAnimation(GifImage.FrameIndexProperty, null); ob.anim = null; ob.gf = null; ob.Source = null; if (!String.IsNullOrEmpty(ob.AnimationSourcePath) && Uri.IsWellFormedUriString(ob.AnimationSourcePath, UriKind.RelativeOrAbsolute)) { if (((string)ob.AnimationSourcePath).ToLower().EndsWith(".gif")) { Uri uri = new Uri(ob.AnimationSourcePath); GifImage.SetupAnimationSource(ob, uri); ob.BeginAnimation(GifImage.FrameIndexProperty, ob.anim); } else { ob.Source = (new ImageSourceConverter()).ConvertFromString(ob.AnimationSourcePath) as ImageSource; ob.InvalidateVisual(); } ob.animationIsWorking = true; } }
/// <summary> /// Initializes a new instance of the GifImage class based on the uri. /// </summary> /// <param name="uri">Uri of the image source.</param> public GifImage(Uri uri) { GifImage.SetupAnimationSource(this, uri); }