Esempio n. 1
0
 private void CreateNonGifAnimationImage(bool isStaticPic)
 {
     this.DeletePreviousImage();
     if (!string.IsNullOrEmpty(this.Source))
     {
         this.CreateImage(false);
         this._image.Source = ImageSourceCache.GetOrCreateImageSource(this.Source, this.IsCache, isStaticPic);
     }
 }
Esempio n. 2
0
 private void CreateGifAnimation(MemoryStream memoryStream, bool cache)
 {
     try
     {
         this.DeletePreviousImage();
         if (!base.HasContent)
         {
             this.CreateImage(true);
             this._gifAnimation.Tag = this.Source;
             this._gifAnimation.CreateGifAnimation(memoryStream);
             if (cache && this.IsCache)
             {
                 ImageSourceCache.SetMemoryStream(this.Source, memoryStream);
             }
         }
     }
     catch (Exception)
     {
         this.CreateNonGifAnimationImage(true);
     }
 }
Esempio n. 3
0
 private void CreateFromSourceString(string source)
 {
     this.DeletePreviousImage();
     if (string.IsNullOrEmpty(source))
     {
         this.RaiseImageFailedEvent(new Exception("字符串为空"));
     }
     else
     {
         ImageSourceCache.ImageCache imageCache = ImageSourceCache.GetImageCache(this.Source);
         if (imageCache != null)
         {
             if (imageCache.IsStaticPic || this.ForceStaticPic)
             {
                 this.CreateNonGifAnimationImage(false);
                 return;
             }
             if (imageCache.MemoryStream != null)
             {
                 this.CreateGifAnimation(imageCache.MemoryStream, false);
                 return;
             }
         }
         Uri uri = new Uri(source, UriKind.RelativeOrAbsolute);
         if (!this.ForceStaticPic && (source.Trim().ToUpper().EndsWith(".GIF") || this.ForceGifAnim))
         {
             try
             {
                 if (!uri.IsAbsoluteUri)
                 {
                     this.GetGifStreamFromPack(uri);
                 }
                 else
                 {
                     string leftPart = uri.GetLeftPart(UriPartial.Scheme);
                     switch (leftPart)
                     {
                     case "http://":
                     case "ftp://":
                         this.GetGifStreamFromHttp(uri);
                         return;
                     }
                     if (leftPart == "file://")
                     {
                         using (FileStream stream = new FileStream(uri.LocalPath, FileMode.Open, FileAccess.Read))
                         {
                             this.ReadGifStreamSynch(stream);
                             stream.Close();
                             stream.Dispose();
                             return;
                         }
                     }
                     if (leftPart == "pack://")
                     {
                         this.GetGifStreamFromPack(uri);
                     }
                     else
                     {
                         this.CreateNonGifAnimationImage(true);
                     }
                 }
             }
             catch (Exception)
             {
                 this.CreateNonGifAnimationImage(true);
             }
         }
         else
         {
             this.CreateNonGifAnimationImage(false);
         }
     }
 }