Exemplo n.º 1
0
        /// <summary>
        /// 属性更改处理事件
        /// </summary>
        private static void OnSourcePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            AnimatedGif gif = sender as AnimatedGif;

            if (gif == null)
            {
                return;
            }
            if (!gif.IsLoaded)
            {
                return;
            }
            BindSource(gif);
        }
Exemplo n.º 2
0
        private static void BindSource(AnimatedGif gif)
        {
            gif.StopAnimate();
            if (gif.Bitmap != null)
            {
                gif.Bitmap.Dispose();
            }
            var path = gif.GIFSource;

            if (path.IsInvalid())
            {
                return;
            }
            if (!Path.IsPathRooted(path))
            {
                path = File.GetPhysicalPath(path);
            }
            gif.Bitmap       = new Bitmap(path);
            gif.BitmapSource = GetBitmapSource(gif.Bitmap);
            gif.StartAnimate();
        }