-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1696 from RussKie/fix_1548_PictureBox.LoadAsync_...
fix: `PictureBox.LoadAsync` throws `PlatformNotSupportedException`
- Loading branch information
Showing
21 changed files
with
472 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/MainForm.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/PictureBoxes.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/PictureBoxes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace WinformsControlsTest | ||
{ | ||
public partial class PictureBoxes : Form | ||
{ | ||
private const string Heading = "PictureBox tests"; | ||
private bool _isLoading; | ||
|
||
public PictureBoxes() | ||
{ | ||
InitializeComponent(); | ||
Text = Heading; | ||
} | ||
|
||
private void btnloadImage_Click(object sender, EventArgs e) | ||
{ | ||
if (string.IsNullOrWhiteSpace(imageUri.Text)) | ||
{ | ||
pictureBox1.Image = null; | ||
if (_isLoading) | ||
{ | ||
pictureBox1.CancelAsync(); | ||
} | ||
|
||
return; | ||
} | ||
|
||
try | ||
{ | ||
_isLoading = true; | ||
pictureBox1.WaitOnLoad = false; | ||
pictureBox1.LoadAsync(imageUri.Text); | ||
} | ||
catch (Exception ex) | ||
{ | ||
MessageBox.Show(ex.Message); | ||
} | ||
} | ||
|
||
private void pictureBox1_LoadCompleted(object sender, AsyncCompletedEventArgs e) | ||
{ | ||
_isLoading = false; | ||
Text = Heading; | ||
|
||
if (e.Cancelled) | ||
{ | ||
MessageBox.Show("Image loading cancelled"); | ||
} | ||
|
||
if (e.Error != null) | ||
{ | ||
MessageBox.Show(e.Error.Message, $"{e.Error.GetType().FullName} occurred"); | ||
} | ||
} | ||
|
||
private void pictureBox1_LoadProgressChanged(object sender, ProgressChangedEventArgs e) | ||
{ | ||
Text = $"{Heading}: loading image progress: {e.ProgressPercentage}%"; | ||
} | ||
} | ||
} |
Oops, something went wrong.