AboutWindow.axaml.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Avalonia.Controls;
  2. using Avalonia.Input;
  3. using Avalonia.Interactivity;
  4. using Avalonia.Layout;
  5. using Avalonia.Styling;
  6. using FluentAvalonia.UI.Controls;
  7. using Ryujinx.Ava.Common.Locale;
  8. using Ryujinx.Ava.UI.Helpers;
  9. using Ryujinx.Ava.UI.ViewModels;
  10. using Ryujinx.Common;
  11. using Ryujinx.UI.Common.Helper;
  12. using System.Threading.Tasks;
  13. using Button = Avalonia.Controls.Button;
  14. namespace Ryujinx.Ava.UI.Windows
  15. {
  16. public partial class AboutWindow : UserControl
  17. {
  18. public AboutWindow()
  19. {
  20. DataContext = new AboutWindowViewModel();
  21. InitializeComponent();
  22. GitHubRepoButton.Tag =
  23. $"https://github.com/{ReleaseInformation.ReleaseChannelOwner}/{ReleaseInformation.ReleaseChannelRepo}";
  24. }
  25. public static async Task Show()
  26. {
  27. ContentDialog contentDialog = new()
  28. {
  29. PrimaryButtonText = string.Empty,
  30. SecondaryButtonText = string.Empty,
  31. CloseButtonText = LocaleManager.Instance[LocaleKeys.UserProfilesClose],
  32. Content = new AboutWindow(),
  33. };
  34. Style closeButton = new(x => x.Name("CloseButton"));
  35. closeButton.Setters.Add(new Setter(WidthProperty, 80d));
  36. Style closeButtonParent = new(x => x.Name("CommandSpace"));
  37. closeButtonParent.Setters.Add(new Setter(HorizontalAlignmentProperty, HorizontalAlignment.Right));
  38. contentDialog.Styles.Add(closeButton);
  39. contentDialog.Styles.Add(closeButtonParent);
  40. await ContentDialogHelper.ShowAsync(contentDialog);
  41. }
  42. private void Button_OnClick(object sender, RoutedEventArgs e)
  43. {
  44. if (sender is Button { Tag: string url })
  45. OpenHelper.OpenUrl(url);
  46. }
  47. private void AmiiboLabel_OnPointerPressed(object sender, PointerPressedEventArgs e)
  48. {
  49. if (sender is TextBlock)
  50. {
  51. OpenHelper.OpenUrl("https://amiiboapi.com");
  52. }
  53. }
  54. }
  55. }