Sfoglia il codice sorgente

:bug: 修复图标设置的问题

youzi-2333 2 anni fa
parent
commit
aacaf792ef

+ 2 - 2
Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml

@@ -33,10 +33,10 @@
                         <TextBlock Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Text="整合包名称" Margin="0,0,25,0" />
                         <TextBlock Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Text="整合包名称" Margin="0,0,25,0" />
                         <local:MyTextBox Grid.Row="0" x:Name="TbExportName" Grid.ColumnSpan="2" Tag="VersionArgumentTitle" Grid.Column="1" MaxLength="100" />
                         <local:MyTextBox Grid.Row="0" x:Name="TbExportName" Grid.ColumnSpan="2" Tag="VersionArgumentTitle" Grid.Column="1" MaxLength="100" />
                         <TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="图标" Margin="0,0,25,0"  />
                         <TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="图标" Margin="0,0,25,0"  />
-                        <local:MyComboBox x:Name="ItemDisplayLogoCustom" Grid.Row="2" Grid.ColumnSpan="2" Grid.Column="1">
+                        <local:MyComboBox x:Name="ComboDisplayLogo" Grid.Row="2" Grid.ColumnSpan="2" Grid.Column="1">
                             <local:MyComboBoxItem Content="自动" IsSelected="True" Tag="" />
                             <local:MyComboBoxItem Content="自动" IsSelected="True" Tag="" />
                             <!-- 此处需要添加一个自定义图标 -->
                             <!-- 此处需要添加一个自定义图标 -->
-                            <local:MyComboBoxItem Content="自定义..." />
+                            <local:MyComboBoxItem x:Name="ItemDisplayLogoCustom" Content="自定义..." />
                             <local:MyComboBoxItem Content="圆石" Tag="pack://application:,,,/images/Blocks/CobbleStone.png" />
                             <local:MyComboBoxItem Content="圆石" Tag="pack://application:,,,/images/Blocks/CobbleStone.png" />
                             <local:MyComboBoxItem Content="命令方块" Tag="pack://application:,,,/images/Blocks/CommandBlock.png" />
                             <local:MyComboBoxItem Content="命令方块" Tag="pack://application:,,,/images/Blocks/CommandBlock.png" />
                             <local:MyComboBoxItem Content="金块" Tag="pack://application:,,,/images/Blocks/GoldBlock.png" />
                             <local:MyComboBoxItem Content="金块" Tag="pack://application:,,,/images/Blocks/GoldBlock.png" />

+ 40 - 2
Plain Craft Launcher 2/Pages/PageVersion/PageVersionExport.xaml.vb

@@ -1,4 +1,6 @@
-Public Class PageVersionExport
+Imports System.Runtime.CompilerServices
+
+Public Class PageVersionExport
     Private Sub PageVersionExport_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
     Private Sub PageVersionExport_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
         TbExportName.HintText = PageVersionLeft.Version.Name
         TbExportName.HintText = PageVersionLeft.Version.Name
         Reload()
         Reload()
@@ -6,10 +8,18 @@
 
 
     Public ItemVersion As MyListItem
     Public ItemVersion As MyListItem
     Public Sub Reload()
     Public Sub Reload()
+        AniControlEnabled += 1
+
         PanDisplayItem.Children.Clear()
         PanDisplayItem.Children.Clear()
-        ItemVersion = PageSelectRight.McVersionListItem(PageVersionLeft.Version)
+        ItemVersion = PageSelectRight.McVersionListItem(PageVersionLeft.Version.Load())
         ItemVersion.IsHitTestVisible = False
         ItemVersion.IsHitTestVisible = False
+        If Not String.IsNullOrEmpty(CustomLogo) Then
+            ItemVersion.Logo = CustomLogo
+        End If
         PanDisplayItem.Children.Add(ItemVersion)
         PanDisplayItem.Children.Add(ItemVersion)
+        ItemVersion.Title = If(String.IsNullOrWhiteSpace(TbExportName.Text), PageVersionLeft.Version.Name, TbExportName.Text)
+
+        AniControlEnabled -= 1
     End Sub
     End Sub
 
 
     Private Type As ModpackType = ModpackType.Modrinth
     Private Type As ModpackType = ModpackType.Modrinth
@@ -27,6 +37,34 @@
     Private Sub TbExportName_TextChanged(sender As MyTextBox, e As TextChangedEventArgs) Handles TbExportName.TextChanged
     Private Sub TbExportName_TextChanged(sender As MyTextBox, e As TextChangedEventArgs) Handles TbExportName.TextChanged
         ItemVersion.Title = If(String.IsNullOrWhiteSpace(sender.Text), PageVersionLeft.Version.Name, sender.Text)
         ItemVersion.Title = If(String.IsNullOrWhiteSpace(sender.Text), PageVersionLeft.Version.Name, sender.Text)
     End Sub
     End Sub
+
+    Private CustomLogoVal As String
+    ''' <summary>
+    ''' 自定义 Logo 的路径。
+    ''' </summary>
+    Public Property CustomLogo() As String
+        Get
+            Return CustomLogoVal
+        End Get
+        Set(value As String)
+            If AniControlEnabled <> 0 Then Exit Property
+            CustomLogoVal = value
+            ItemVersion.Logo = value
+            Reload()
+        End Set
+    End Property
+
+    Private Sub ComboDisplayLogo_SelectionChanged(sender As MyComboBox, e As SelectionChangedEventArgs) Handles ComboDisplayLogo.SelectionChanged
+        If Not AniControlEnabled = 0 Then Exit Sub
+        '选择 自定义 时修改图片
+        If ComboDisplayLogo.SelectedItem Is ItemDisplayLogoCustom Then
+            Dim FileName As String = SelectFile("常用图片文件(*.png;*.jpg;*.gif)|*.png;*.jpg;*.gif", "选择图片")
+            If String.IsNullOrWhiteSpace(FileName) Then Exit Sub
+            CustomLogo = FileName
+        Else
+            CustomLogo = sender.SelectedItem.Tag
+        End If
+    End Sub
 #End Region
 #End Region
 
 
 #Region "导出"
 #Region "导出"