Skip to content

Commit

Permalink
chore: add more try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
tangge233 committed Jan 22, 2025
1 parent 14cc464 commit e91d1a2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 34 deletions.
46 changes: 25 additions & 21 deletions Plain Craft Launcher 2/Pages/PageVersion/PageVersionShader.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,35 @@ Public Class PageVersionShader
If ModeDebug Then Log("[Shader] 共发现 " & FileList.Count & " 个光影包文件", LogLevel.Debug)
PanList.Children.Clear()
For Each i In FileList
Dim worldItem As MyListItem = New MyListItem With {
Try
Dim worldItem As MyListItem = New MyListItem With {
.Title = GetFileNameWithoutExtentionFromPath(i),
.Info = $"引入时间:{ File.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")}",
.Tag = i
}
Dim BtnOpen As MyIconButton = New MyIconButton With {
.Logo = Logo.IconButtonOpen,
.ToolTip = "打开",
.Tag = i
}
AddHandler BtnOpen.Click, AddressOf BtnOpen_Click
Dim BtnDelete As MyIconButton = New MyIconButton With {
.Logo = Logo.IconButtonDelete,
.ToolTip = "删除",
.Tag = i
}
AddHandler BtnDelete.Click, AddressOf BtnDelete_Click
Dim BtnCopy As MyIconButton = New MyIconButton With {
.Logo = Logo.IconButtonCopy,
.ToolTip = "复制",
.Tag = i
}
AddHandler BtnCopy.Click, AddressOf BtnCopy_Click
worldItem.Buttons = {BtnOpen, BtnDelete, BtnCopy}
PanList.Children.Add(worldItem)
Dim BtnOpen As MyIconButton = New MyIconButton With {
.Logo = Logo.IconButtonOpen,
.ToolTip = "打开",
.Tag = i
}
AddHandler BtnOpen.Click, AddressOf BtnOpen_Click
Dim BtnDelete As MyIconButton = New MyIconButton With {
.Logo = Logo.IconButtonDelete,
.ToolTip = "删除",
.Tag = i
}
AddHandler BtnDelete.Click, AddressOf BtnDelete_Click
Dim BtnCopy As MyIconButton = New MyIconButton With {
.Logo = Logo.IconButtonCopy,
.ToolTip = "复制",
.Tag = i
}
AddHandler BtnCopy.Click, AddressOf BtnCopy_Click
worldItem.Buttons = {BtnOpen, BtnDelete, BtnCopy}
PanList.Children.Add(worldItem)
Catch ex As Exception
Log(ex, $"[Shader] 读取 {i} 数据错误", LogLevel.Hint)
End Try
Next
RefreshUI()
End Sub
Expand Down
30 changes: 17 additions & 13 deletions Plain Craft Launcher 2/Pages/PageVersion/PageVersionWorld.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,44 @@ Public Class PageVersionWorld
If ModeDebug Then Log("[World] 共发现 " & FileList.Count & " 个存档文件夹", LogLevel.Debug)
PanList.Children.Clear()
For Each i In FileList
Dim SaveLogo = i + "\icon.png"
If Not File.Exists(SaveLogo) Then SaveLogo = PathImage & "Icons/NoIcon.png"
Dim worldItem As MyListItem = New MyListItem With {
Try
Dim SaveLogo = i + "\icon.png"
If Not File.Exists(SaveLogo) Then SaveLogo = PathImage & "Icons/NoIcon.png"
Dim worldItem As MyListItem = New MyListItem With {
.Logo = SaveLogo,
.Title = GetFolderNameFromPath(i),
.Info = $"创建时间:{ Directory.GetCreationTime(i).ToString("yyyy'/'MM'/'dd")},最后修改时间:{Directory.GetLastWriteTime(i).ToString("yyyy'/'MM'/'dd")}",
.Tag = i
}
Dim BtnOpen As MyIconButton = New MyIconButton With {
Dim BtnOpen As MyIconButton = New MyIconButton With {
.Logo = Logo.IconButtonOpen,
.ToolTip = "打开",
.Tag = i
}
AddHandler BtnOpen.Click, AddressOf BtnOpen_Click
Dim BtnDelete As MyIconButton = New MyIconButton With {
AddHandler BtnOpen.Click, AddressOf BtnOpen_Click
Dim BtnDelete As MyIconButton = New MyIconButton With {
.Logo = Logo.IconButtonDelete,
.ToolTip = "删除",
.Tag = i
}
AddHandler BtnDelete.Click, AddressOf BtnDelete_Click
Dim BtnCopy As MyIconButton = New MyIconButton With {
AddHandler BtnDelete.Click, AddressOf BtnDelete_Click
Dim BtnCopy As MyIconButton = New MyIconButton With {
.Logo = Logo.IconButtonCopy,
.ToolTip = "复制",
.Tag = i
}
AddHandler BtnCopy.Click, AddressOf BtnCopy_Click
Dim BtnInfo As MyIconButton = New MyIconButton With {
AddHandler BtnCopy.Click, AddressOf BtnCopy_Click
Dim BtnInfo As MyIconButton = New MyIconButton With {
.Logo = Logo.IconButtonInfo,
.ToolTip = "详情",
.Tag = i
}
AddHandler BtnInfo.Click, AddressOf BtnInfo_Click
worldItem.Buttons = {BtnOpen, BtnDelete, BtnCopy, BtnInfo}
PanList.Children.Add(worldItem)
AddHandler BtnInfo.Click, AddressOf BtnInfo_Click
worldItem.Buttons = {BtnOpen, BtnDelete, BtnCopy, BtnInfo}
PanList.Children.Add(worldItem)
Catch ex As Exception
Log(ex, $"[World] 读取 {i} 数据错误", LogLevel.Hint)
End Try
Next
RefreshUI()
End Sub
Expand Down

0 comments on commit e91d1a2

Please sign in to comment.