11using System ;
2+ using System . Management . Automation ;
23using Flarial . Launcher . Xaml ;
34using Windows . UI . Core ;
45using Windows . UI . Xaml ;
@@ -12,8 +13,8 @@ namespace Flarial.Launcher.Controls;
1213
1314abstract class PromotionImageButton : XamlElement < Image >
1415{
15- protected abstract string ? ImageUri { get ; }
16- protected abstract string ? NavigateUri { get ; }
16+ protected abstract string ImageUri { get ; }
17+ protected abstract string NavigateUri { get ; }
1718
1819 static readonly CoreCursor _hand = new ( CoreCursorType . Hand , 0 ) ;
1920 static readonly CoreCursor _arrow = new ( CoreCursorType . Arrow , 0 ) ;
@@ -22,21 +23,19 @@ protected PromotionImageButton() : base(new())
2223 {
2324 ( ~ this ) . Width = 320 * 0.95 ;
2425 ( ~ this ) . Height = 50 * 0.95 ;
25- ( ~ this ) . VerticalAlignment = VerticalAlignment . Bottom ;
26+ ( ~ this ) . Visibility = Visibility . Collapsed ;
2627
27- ( ~ this ) . Source = new BitmapImage
28- {
29- DecodePixelType = DecodePixelType . Logical ,
30- UriSource = ImageUri is { } ? new ( ImageUri ) : null
31- } ;
32-
33- ( ~ this ) . ImageOpened += OnImageOpened ;
34- ( ~ this ) . PointerPressed += OnImagePointerPressed ;
35-
36- ( ~ this ) . PointerEntered += OnImagePointerEntered ;
28+ ( ~ this ) . Tag = NavigateUri ;
29+ ( ~ this ) . ImageFailed += OnImageFailed ;
3730 ( ~ this ) . PointerExited += OnImagePointerExited ;
31+ ( ~ this ) . PointerEntered += OnImagePointerEntered ;
32+ ( ~ this ) . PointerPressed += OnImagePointerPressed ;
3833
39- ( ~ this ) . Tag = NavigateUri ;
34+ if ( ImageUri is { } )
35+ {
36+ ( ~ this ) . Visibility = Visibility . Visible ;
37+ ( ~ this ) . Source = new BitmapImage { UriSource = new ( ImageUri ) } ;
38+ }
4039 }
4140
4241 unsafe static void OnImagePointerPressed ( object sender , RoutedEventArgs args )
@@ -45,10 +44,8 @@ unsafe static void OnImagePointerPressed(object sender, RoutedEventArgs args)
4544 ShellExecute ( Null , null , lpFile , null , null , SW_NORMAL ) ;
4645 }
4746
48- static void OnImageOpened ( object sender , RoutedEventArgs args ) => ( ( Image ) sender ) . Visibility = Visibility . Visible ;
49-
47+ static void OnImageFailed ( object sender , RoutedEventArgs args ) => ( ( Image ) sender ) . Visibility = Visibility . Collapsed ;
5048 static void OnImagePointerEntered ( object sender , RoutedEventArgs args ) => CoreWindow . GetForCurrentThread ( ) . PointerCursor = _hand ;
51-
5249 static void OnImagePointerExited ( object sender , RoutedEventArgs args ) => CoreWindow . GetForCurrentThread ( ) . PointerCursor = _arrow ;
5350}
5451
@@ -64,15 +61,15 @@ sealed class LiteByteHostingImageButton : PromotionImageButton
6461 protected override string NavigateUri => "https://litebyte.co/minecraft?utm_source=flarial-client&utm_medium=app&utm_campaign=bedrock-launch" ;
6562}
6663
64+ sealed class InfinityNetworkImageButton : PromotionImageButton
65+ {
66+ protected override string ImageUri => "https://assets.infinitymcpe.com/banner.png" ;
67+ protected override string NavigateUri => "https://discord.gg/infinitymcpe" ;
68+ }
69+
6770[ Obsolete ( "" , true ) ]
6871sealed class CollapseNetworkImageButton : PromotionImageButton
6972{
7073 protected override string ImageUri => "https://collapsemc.com/assets/other/ad-banner.png" ;
7174 protected override string NavigateUri => "minecraft://?addExternalServer=Collapse|clps.gg:19132" ;
72- }
73-
74- sealed class InfinityNetworkImageButton : PromotionImageButton
75- {
76- protected override string ImageUri => "https://assets.infinitymcpe.com/banner.png" ;
77- protected override string NavigateUri => "https://discord.gg/infinitymcpe" ;
7875}
0 commit comments