private void ux_textboxThumbnailVirtualPath_TextChanged(object sender, EventArgs e) { #region WebRequest Method... //try //{ // System.Net.WebRequest req = System.Net.WebRequest.Create(ux_textboxThumbnailVirtualPath.Text.Trim()); // System.Net.WebResponse response = req.GetResponse(); // System.IO.Stream stream = response.GetResponseStream(); // //int imageBytesLength = (int)response.ContentLength + ((int)(response.ContentLength)%2); // //byte[] imageBytes = new byte[imageBytesLength]; // //stream.Read(imageBytes, 0, (int)response.ContentLength); // if (stream != null && stream.Length > 0) // { // stream.Position = 0L; // Image thumbnailImage = Image.FromStream(stream, false, true); // if (thumbnailImage != null) // { // ux_pictureboxThumbnail.Image = thumbnailImage; // } // else // { // ux_pictureboxThumbnail.Image = null; // } // } // else // { // ux_pictureboxThumbnail.Image = null; // } // stream.Dispose(); // response.Close(); //} //catch (Exception err) //{ // ux_pictureboxThumbnail.Image = null; //} #endregion #region WebService Method... try { // Attempt to get the thumbnail from the remote server's WebService... byte[] imageBytes = _sharedUtils.GetImage(ux_textboxThumbnailVirtualPath.Text.Trim()); if (imageBytes != null && imageBytes.Length > 0) { System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBytes); Image thumbnailImage = Image.FromStream(ms, false, true); if (thumbnailImage != null) { ux_pictureboxThumbnail.Image = thumbnailImage; } else { ux_pictureboxThumbnail.Image = null; } } else { ux_pictureboxThumbnail.Image = null; } } catch (Exception err) { //MessageBox.Show("Remote server's WebServce 'DownloadImage()' returned a corrupt image file that cannot be displayed"); GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Remote server's WebServce 'DownloadImage()' returned a corrupt image file that cannot be displayed", "Load Image Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxDefaultButton.Button1); ggMessageBox.Name = "ImageForm_ux_textboxThumbnailVirtualPathMessage1"; if (_sharedUtils != null) { _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name); } ggMessageBox.ShowDialog(); ux_pictureboxThumbnail.Image = null; } #endregion }