Skip to content

Commit

Permalink
在从 LoaderState 转为 UI 元素的 Converter 中直接新建对象而不使用 GetObjectFromXML
Browse files Browse the repository at this point in the history
  • Loading branch information
Open-KFC committed Mar 6, 2025
1 parent 1594321 commit 0aabfe7
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions Plain Craft Launcher 2/Modules/Base/ModBase.vb
Original file line number Diff line number Diff line change
Expand Up @@ -3040,13 +3040,46 @@ Public Class DlStateConveter
If value Is Nothing OrElse TypeOf value IsNot LoadState Then Return Nothing
Select Case value
Case LoadState.Waiting
Return GetObjectFromXML("<Path xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Stretch=""Uniform"" Tag=""Waiting"" Data=""F1 M5,0 a5,5 360 1 0 0,0.0001 m15,0 a5,5 360 1 0 0,0.0001 m15,0 a5,5 360 1 0 0,0.0001 Z"" Width=""18"" HorizontalAlignment=""Center"" Fill=""{DynamicResource ColorBrush3}"" Margin=""0,7,0,0"" VerticalAlignment=""Top"" Height=""6""/>")
Dim Ret As New Shapes.Path With {
.Stretch = Stretch.Uniform,
.Tag = "Waiting",
.Data = Geometry.Parse("F1 M5,0 a5,5 360 1 0 0,0.0001 m15,0 a5,5 360 1 0 0,0.0001 m15,0 a5,5 360 1 0 0,0.0001 Z"),
.Width = 18, .Height = 6,
.HorizontalAlignment = HorizontalAlignment.Center, .VerticalAlignment = VerticalAlignment.Top,
.Margin = New Thickness(0, 7, 0, 0)
}
Ret.SetResourceReference(Shape.FillProperty, "ColorBrush3")
Return Ret
Case LoadState.Loading
Return GetObjectFromXML("<TextBlock xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Text=""{Binding PercentStr, Mode=OneWay}"" Tag=""Loading"" HorizontalAlignment=""Center"" Foreground=""{DynamicResource ColorBrush3}"" />")
Dim Ret As New TextBlock With {
.Tag = "Loading",
.HorizontalAlignment = HorizontalAlignment.Center
}
Ret.SetResourceReference(TextBlock.ForegroundProperty, "ColorBrush3")
Ret.SetBinding(TextBlock.TextProperty, New Binding("PercentStr") With {.Mode = BindingMode.OneWay})
Return Ret
Case LoadState.Finished
Return GetObjectFromXML("<Path xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Stretch=""Uniform"" Tag=""Finished"" Data=""F1 M 23.7501,33.25L 34.8334,44.3333L 52.2499,22.1668L 56.9999,26.9168L 34.8334,53.8333L 19.0001,38L 23.7501,33.25 Z"" Height=""16"" Width=""15"" HorizontalAlignment=""Center"" Fill=""{DynamicResource ColorBrush3}"" Margin=""0,3,0,0"" VerticalAlignment=""Top""/>")
Dim Ret As New Shapes.Path With {
.Stretch = Stretch.Uniform,
.Tag = "Finished",
.Data = Geometry.Parse("F1 M 23.7501,33.25L 34.8334,44.3333L 52.2499,22.1668L 56.9999,26.9168L 34.8334,53.8333L 19.0001,38L 23.7501,33.25 Z"),
.Width = 16, .Height = 15,
.HorizontalAlignment = HorizontalAlignment.Center, .VerticalAlignment = VerticalAlignment.Top,
.Margin = New Thickness(0, 3, 0, 0)
}
Ret.SetResourceReference(Shape.FillProperty, "ColorBrush3")
Return Ret
Case Else 'Failed, Aborted
Return GetObjectFromXML("<Path xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Stretch=""Uniform"" Tag=""Failed"" Data=""F1 M2.5,0 L0,2.5 7.5,10 0,17.5 2.5,20 10,12.5 17.5,20 20,17.5 12.5,10 20,2.5 17.5,0 10,7.5 2.5,0Z"" Height=""15"" Width=""15"" HorizontalAlignment=""Center"" Fill=""{DynamicResource ColorBrush3}"" Margin=""0,1,0,0"" VerticalAlignment=""Top""/>")
Dim Ret As New Shapes.Path With {
.Stretch = Stretch.Uniform,
.Tag = "Failed",
.Data = Geometry.Parse("F1 M2.5,0 L0,2.5 7.5,10 0,17.5 2.5,20 10,12.5 17.5,20 20,17.5 12.5,10 20,2.5 17.5,0 10,7.5 2.5,0Z"),
.Width = 15, .Height = 15,
.HorizontalAlignment = HorizontalAlignment.Center, .VerticalAlignment = VerticalAlignment.Top,
.Margin = New Thickness(0, 1, 0, 0)
}
Ret.SetResourceReference(Shape.FillProperty, "ColorBrush3")
Return Ret
End Select
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Expand Down

0 comments on commit 0aabfe7

Please sign in to comment.