From 3b8ea5379d9997c4b9901972728fa34f73d3e6ea Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 10 Aug 2014 01:59:26 +0300 Subject: [PATCH] fixed #161: Picture box error issue fixed #233: FTP name parsing consistency --- HelpersLib/Controls/MyPictureBox.cs | 17 +++++++++--- HelpersLib/HelpersLib.csproj | 3 +++ HelpersLib/Properties/Resources.Designer.cs | 10 +++++++ HelpersLib/Properties/Resources.resx | 9 ++++--- HelpersLib/Resources/cross.png | Bin 0 -> 2168 bytes ShareX/VideoEncodersForm.cs | 27 ++++++++++++++++++- UploadersLib/FileUploaders/FTP.cs | 5 ++-- UploadersLib/FileUploaders/FTP/FTPAccount.cs | 8 ++++-- UploadersLib/FileUploaders/SFTP.cs | 5 ++-- 9 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 HelpersLib/Resources/cross.png diff --git a/HelpersLib/Controls/MyPictureBox.cs b/HelpersLib/Controls/MyPictureBox.cs index a8a979e5d..bc19900dc 100644 --- a/HelpersLib/Controls/MyPictureBox.cs +++ b/HelpersLib/Controls/MyPictureBox.cs @@ -144,6 +144,7 @@ public MyPictureBox() InitializeComponent(); Text = string.Empty; pbMain.InitialImage = Resources.Loading; + pbMain.ErrorImage = Resources.cross; pbMain.LoadProgressChanged += pbMain_LoadProgressChanged; pbMain.LoadCompleted += pbMain_LoadCompleted; pbMain.Resize += pbMain_Resize; @@ -237,13 +238,23 @@ private void LoadImageAsync(string path) public void Reset() { - if (!isImageLoading) + if (!isImageLoading && Image != null) { - if (Image != null) + Image temp = null; + + try { - Image.Dispose(); + temp = Image; Image = null; } + finally + { + // If error happened in previous image load then PictureBox set image as error image and if we dispose it then error happens. + if (temp != null && temp != pbMain.ErrorImage) + { + temp.Dispose(); + } + } } if (FullscreenOnClick && Cursor != Cursors.Default) diff --git a/HelpersLib/HelpersLib.csproj b/HelpersLib/HelpersLib.csproj index 89e4d7ad4..be3136106 100644 --- a/HelpersLib/HelpersLib.csproj +++ b/HelpersLib/HelpersLib.csproj @@ -430,6 +430,9 @@ + + +