PageVersionExport.xaml.vb 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. Public Class PageVersionExport
  2. Private Sub PageVersionExport_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
  3. Reload()
  4. End Sub
  5. Public ItemVersion As MyListItem
  6. Public Sub Reload()
  7. AniControlEnabled += 1
  8. TbExportName.HintText = PageVersionLeft.Version.Name
  9. TbExportDesc.HintText = PageVersionLeft.Version.Info
  10. PanDisplayItem.Children.Clear()
  11. ItemVersion = PageSelectRight.McVersionListItem(PageVersionLeft.Version.Load())
  12. ItemVersion.IsHitTestVisible = False
  13. If Not String.IsNullOrEmpty(CustomLogo) Then
  14. ItemVersion.Logo = CustomLogo
  15. End If
  16. PanDisplayItem.Children.Add(ItemVersion)
  17. ItemVersion.Title = If(String.IsNullOrWhiteSpace(TbExportName.Text), PageVersionLeft.Version.Name, TbExportName.Text)
  18. AniControlEnabled -= 1
  19. End Sub
  20. Private Type As ModpackType = ModpackType.Modrinth
  21. Private SelectedSaves As New List(Of Integer)
  22. Private ReadOnly Property Saves As List(Of String)
  23. Get
  24. If Directory.Exists(PageVersionLeft.Version.Path & "saves\") Then
  25. Return Directory.EnumerateDirectories(PageVersionLeft.Version.Path & "saves\").ToList
  26. End If
  27. Return New List(Of String)
  28. End Get
  29. End Property
  30. #Region "整合包信息 & 预览栏"
  31. Private Sub TbExportName_TextChanged(sender As MyTextBox, e As TextChangedEventArgs) Handles TbExportName.TextChanged
  32. ItemVersion.Title = If(String.IsNullOrWhiteSpace(sender.Text), PageVersionLeft.Version.Name, sender.Text)
  33. End Sub
  34. Private Sub TbExportDesc_TextChanged(sender As MyTextBox, e As TextChangedEventArgs) Handles TbExportDesc.TextChanged
  35. ItemVersion.Info = If(String.IsNullOrWhiteSpace(sender.Text), PageVersionLeft.Version.Info, sender.Text)
  36. End Sub
  37. Private CustomLogoVal As String
  38. ''' <summary>
  39. ''' 自定义 Logo 的路径。
  40. ''' </summary>
  41. Public Property CustomLogo() As String
  42. Get
  43. Return CustomLogoVal
  44. End Get
  45. Set(value As String)
  46. If AniControlEnabled <> 0 Then Exit Property
  47. CustomLogoVal = value
  48. ItemVersion.Logo = value
  49. Reload()
  50. End Set
  51. End Property
  52. Private Sub ComboDisplayLogo_SelectionChanged(sender As MyComboBox, e As SelectionChangedEventArgs) Handles ComboDisplayLogo.SelectionChanged
  53. If Not AniControlEnabled = 0 Then Exit Sub
  54. '选择 自定义 时修改图片
  55. If ComboDisplayLogo.SelectedItem Is ItemDisplayLogoCustom Then
  56. Dim FileName As String = SelectFile("常用图片文件(*.png;*.jpg;*.gif)|*.png;*.jpg;*.gif", "选择图片")
  57. If String.IsNullOrWhiteSpace(FileName) Then Exit Sub
  58. CustomLogo = FileName
  59. Else
  60. CustomLogo = sender.SelectedItem.Tag
  61. End If
  62. End Sub
  63. #End Region
  64. #Region "导出"
  65. Private Function IncludePCL() As Boolean
  66. Return True
  67. End Function
  68. 'Private Sub ComboExportType_Change(sender As ComboBox, e As SelectionChangedEventArgs) Handles ComboExportType.SelectionChanged
  69. ' If AniControlEnabled <> 0 Then Exit Sub
  70. ' Type = sender.SelectedIndex
  71. ' Select Case Type
  72. ' Case ModpackType.Modrinth
  73. ' If IncludePCL() Then 'TODO:修改这里的条件
  74. ' If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Visible
  75. ' If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Collapsed
  76. ' Else
  77. ' If GridCompressed IsNot Nothing Then GridCompressed.Visibility = Visibility.Collapsed
  78. ' If GridModrinth IsNot Nothing Then GridModrinth.Visibility = Visibility.Visible
  79. ' End If
  80. ' End Select
  81. ' CardExport.TriggerForceResize()
  82. 'End Sub
  83. Private Sub BtnExportExport_Click() Handles BtnExportExport.Click
  84. If IncludePCL() AndAlso Val(VersionBranchCode) <> 50 Then
  85. If MyMsgBox("你当前的 PCL 不是正式版,有二次分发(制作压缩包)的限制。" & vbCrLf &
  86. "请使用正式版再次尝试该操作!" & vbCrLf &
  87. "其他类型的整合包(例如 Modrinth 整合包)没有该限制。", Button1:="下载正式版", Button2:="取消") = 1 Then
  88. OpenWebsite("https://afdian.net/p/0164034c016c11ebafcb52540025c377")
  89. End If
  90. Exit Sub
  91. End If
  92. Dim savePath As String = SelectAs(
  93. "选择导出位置", $"整合包 - {If(String.IsNullOrWhiteSpace(TbExportName.Text), PageVersionLeft.Version.Name, TbExportName.Text)}" & If(Type = ModpackType.Modrinth, ".mrpack", ".zip"),
  94. If(Type = ModpackType.Modrinth, "Modrinth 整合包(*.mrpack)|*.mrpack", "整合包文件(*.zip)|*.zip"))
  95. If String.IsNullOrEmpty(savePath) Then Exit Sub
  96. ModpackExport(New ExportOptions(PageVersionLeft.Version, savePath, Type, {}, 'TODO:改成要保留的文件列表
  97. Name:=TbExportName.Text, VerID:=TbExportVersion.Text))
  98. End Sub
  99. #End Region
  100. End Class