private static void OnAnimatedBitmapChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            AnimatedImage control = (AnimatedImage)obj;

            System.IO.Stream stream = Env.Current.Project.GetData(ProjectEntityType.Image, control.ImageName);
            control.animatedBitmap = BitmapDecoder.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
            control.Source         = control.animatedBitmap.Frames[0];

            RoutedPropertyChangedEventArgs <string> e = new RoutedPropertyChangedEventArgs <string>(
                (string)args.OldValue, (string)args.NewValue, AnimatedBitmapChangedEvent);

            control.OnAnimatedBitmapChanged(e);
        }
        private static void OnAnimatedControlChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            AnimatedImage control = (AnimatedImage)obj;

            if (control.ImageName == null)
            {
                return;
            }

            if ((bool)args.NewValue == true)
            {
                control.StartAnimate();
            }
            if ((bool)args.NewValue == false)
            {
                control.StopAnimate();
            }
        }
 protected override void BeginQuery()
 {
     try
     {
         //System.Windows.Media.Imaging.BitmapImage bi = new System.Windows.Media.Imaging.BitmapImage();
         //System.IO.Stream stream = Env.Current.Project.GetData(ProjectEntityType.Image,mediaFileName);
         //BitmapDecoder bd=BitmapDecoder.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
         if (ExpectedTarget == typeof(Object))
         {
             AnimatedImage image = new AnimatedImage();
             image.ImageName       = MediaFileName;
             image.AnimatedControl = true;
             base.OnQueryFinished(image);
             System.ComponentModel.TypeDescriptor.AddAttributes(image, new Attribute[] { new System.Windows.Markup.RuntimeNamePropertyAttribute(MediaFileName) });
         }
     }
     catch (Exception)
     {
         base.OnQueryFinished(mediaFileName);
     }
 }