Ejemplo n.º 1
0
        private void LoadCompletedDelegate(object arg)
        {
            AsyncCompletedEventArgs e = (AsyncCompletedEventArgs)arg;

            System.Drawing.Image  errorImage     = this.ErrorImage;
            ImageInstallationType errorOrInitial = ImageInstallationType.ErrorOrInitial;

            if (!e.Cancelled && (e.Error == null))
            {
                try
                {
                    errorImage     = System.Drawing.Image.FromStream(this.tempDownloadStream);
                    errorOrInitial = ImageInstallationType.FromUrl;
                }
                catch (Exception exception)
                {
                    e = new AsyncCompletedEventArgs(exception, false, null);
                }
            }
            if (!e.Cancelled)
            {
                this.InstallNewImage(errorImage, errorOrInitial);
            }
            this.tempDownloadStream = null;
            this.pictureBoxState[2] = false;
            this.pictureBoxState[1] = false;
            this.OnLoadCompleted(e);
        }
Ejemplo n.º 2
0
 private void InstallNewImage(System.Drawing.Image value, ImageInstallationType installationType)
 {
     this.StopAnimate();
     this.image = value;
     LayoutTransaction.DoLayoutIf(this.AutoSize, this, this, PropertyNames.Image);
     this.Animate();
     if (installationType != ImageInstallationType.ErrorOrInitial)
     {
         this.AdjustSize();
     }
     this.imageInstallationType = installationType;
     base.Invalidate();
     CommonProperties.xClearPreferredSizeCache(this);
 }
Ejemplo n.º 3
0
        public void Load()
        {
            System.Drawing.Image errorImage;
            if ((this.imageLocation == null) || (this.imageLocation.Length == 0))
            {
                throw new InvalidOperationException(System.Windows.Forms.SR.GetString("PictureBoxNoImageLocation"));
            }
            this.pictureBoxState[0x20] = false;
            ImageInstallationType fromUrl = ImageInstallationType.FromUrl;

            try
            {
                Uri uri = this.CalculateUri(this.imageLocation);
                if (uri.IsFile)
                {
                    using (StreamReader reader = new StreamReader(uri.LocalPath))
                    {
                        errorImage = System.Drawing.Image.FromStream(reader.BaseStream);
                        goto Label_00C0;
                    }
                }
                using (WebClient client = new WebClient())
                {
                    using (Stream stream = client.OpenRead(uri.ToString()))
                    {
                        errorImage = System.Drawing.Image.FromStream(stream);
                    }
                }
            }
            catch
            {
                if (!base.DesignMode)
                {
                    throw;
                }
                errorImage = this.ErrorImage;
                fromUrl    = ImageInstallationType.ErrorOrInitial;
            }
Label_00C0:
            this.InstallNewImage(errorImage, fromUrl);
        }
Ejemplo n.º 4
0
 private void InstallNewImage(Image value,
                              ImageInstallationType installationType)
 {
     StopAnimate();
     this.image = value;
     
     LayoutTransaction.DoLayoutIf(AutoSize, this, this, PropertyNames.Image); 
     
     Animate();
     if (installationType != ImageInstallationType.ErrorOrInitial)
     {
         AdjustSize();
     }
     this.imageInstallationType = installationType;
     
     Invalidate();
     CommonProperties.xClearPreferredSizeCache(this);
 }