From e782d0ed2de1797eff95e2982904600bc4ce0455 Mon Sep 17 00:00:00 2001 From: tangge233 Date: Wed, 2 Oct 2024 17:22:20 +0800 Subject: [PATCH] fix: apply suggestions --- Plain Craft Launcher 2/Controls/MyImage.vb | 15 +++++---------- Plain Craft Launcher 2/Modules/Base/MyBitmap.vb | 7 ------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Plain Craft Launcher 2/Controls/MyImage.vb b/Plain Craft Launcher 2/Controls/MyImage.vb index f0c3d80..5e09175 100644 --- a/Plain Craft Launcher 2/Controls/MyImage.vb +++ b/Plain Craft Launcher 2/Controls/MyImage.vb @@ -3,8 +3,6 @@ '事件 - Public Uuid As Integer = GetUuid() - Private _SourceData As String = "" ''' @@ -15,20 +13,17 @@ Return _SourceData End Get Set(value As String) - SetImage(value) + If String.IsNullOrEmpty(value) Then Exit Property + _SourceData = value + MyBase.Source = New MyBitmap(_SourceData) End Set End Property Public Shared Shadows ReadOnly SourceProperty As DependencyProperty = DependencyProperty.Register("Source", GetType(String), GetType(MyImage), New PropertyMetadata(New PropertyChangedCallback( Sub(sender As DependencyObject, e As DependencyPropertyChangedEventArgs) If Not IsNothing(sender) Then - CType(sender, MyImage).SetImage(e.NewValue) + If String.IsNullOrEmpty(e.NewValue.ToString()) Then Exit Sub + CType(sender, MyImage).Source = e.NewValue.ToString() End If End Sub))) - Private Sub SetImage(source As String) - If Me Is Nothing Then Exit Sub - If String.IsNullOrEmpty(source) Then Exit Sub - _SourceData = source - MyBase.Source = New MyBitmap(_SourceData) - End Sub End Class diff --git a/Plain Craft Launcher 2/Modules/Base/MyBitmap.vb b/Plain Craft Launcher 2/Modules/Base/MyBitmap.vb index 33a3150..0f63b31 100644 --- a/Plain Craft Launcher 2/Modules/Base/MyBitmap.vb +++ b/Plain Craft Launcher 2/Modules/Base/MyBitmap.vb @@ -68,13 +68,6 @@ Public Class MyBitmap Dim tempFile = PathTemp & "Cache\MyImage\" & GetHash(FilePathOrResourceName) NetDownload(FilePathOrResourceName, tempFile, True) FilePathOrResourceName = tempFile - ElseIf FilePathOrResourceName.StartsWithF("data:image/png;base64,") Then 'base64 图片 - Dim base64Data = FilePathOrResourceName.Split(",")(1) - Dim imageData = Convert.FromBase64String(base64Data) - Using ms = New MemoryStream(imageData) - Pic = New System.Drawing.Bitmap(ms) - End Using - Return End If '使用这种自己接管 FileStream 的方法加载才能解除文件占用 Using InputStream As New FileStream(FilePathOrResourceName, FileMode.Open)