diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index 00644a1e..2afad9b8 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/Bin/net45/SunnyUI.dll b/Bin/net45/SunnyUI.dll index e1da1d78..4877970e 100644 Binary files a/Bin/net45/SunnyUI.dll and b/Bin/net45/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll index aa243cee..daea5f9d 100644 Binary files a/Bin/net5.0-windows/SunnyUI.dll and b/Bin/net5.0-windows/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/ref/SunnyUI.dll b/Bin/net5.0-windows/ref/SunnyUI.dll index bc602869..2bf4befd 100644 Binary files a/Bin/net5.0-windows/ref/SunnyUI.dll and b/Bin/net5.0-windows/ref/SunnyUI.dll differ diff --git a/Bin/netcoreapp3.1/SunnyUI.dll b/Bin/netcoreapp3.1/SunnyUI.dll index b97a04c5..9e7b4250 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI/Controls/UIImageListBox.Designer.cs b/SunnyUI/Controls/UIImageListBox.Designer.cs index be4e1d1e..7fefa956 100644 --- a/SunnyUI/Controls/UIImageListBox.Designer.cs +++ b/SunnyUI/Controls/UIImageListBox.Designer.cs @@ -17,6 +17,13 @@ { components.Dispose(); } + + foreach (var item in Items) + { + if (item is ImageListItem imageItem) + imageItem.Dispose(); + } + base.Dispose(disposing); } diff --git a/SunnyUI/Controls/UIImageListBox.cs b/SunnyUI/Controls/UIImageListBox.cs index e6eada6a..c5ca8b46 100644 --- a/SunnyUI/Controls/UIImageListBox.cs +++ b/SunnyUI/Controls/UIImageListBox.cs @@ -727,14 +727,14 @@ namespace Sunny.UI public string Description { get; set; } - public Bitmap Image { get; private set; } + public Image Image { get; private set; } public ImageListItem(string imagePath, string description = "") { if (File.Exists(imagePath)) { ImagePath = imagePath; - Image = new Bitmap(imagePath); + Image = ImageEx.FromFile(imagePath); } Description = description; diff --git a/SunnyUI/Static/UImage.cs b/SunnyUI/Static/UImage.cs index 93087225..94f6b1d0 100644 --- a/SunnyUI/Static/UImage.cs +++ b/SunnyUI/Static/UImage.cs @@ -84,6 +84,26 @@ namespace Sunny.UI return sb.ToString(); } + public static Image FromFile(string path) + { + if (File.Exists(path)) + { + try + { + byte[] bytes = File.ReadAllBytes(path); + return System.Drawing.Image.FromStream(new MemoryStream(bytes)); + } + catch (Exception) + { + return null; + } + } + else + { + return null; + } + } + public static Color RandomColor() { Random random = new Random();