StyleableWindow.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Avalonia.Controls;
  2. using Avalonia.Controls.Primitives;
  3. using Avalonia.Media.Imaging;
  4. using Avalonia.Platform;
  5. using FluentAvalonia.UI.Controls;
  6. using System;
  7. using System.IO;
  8. using System.Reflection;
  9. namespace Ryujinx.Ava.Ui.Windows
  10. {
  11. public class StyleableWindow : Window
  12. {
  13. public ContentDialog ContentDialog { get; private set; }
  14. public IBitmap IconImage { get; set; }
  15. public StyleableWindow()
  16. {
  17. WindowStartupLocation = WindowStartupLocation.CenterOwner;
  18. TransparencyLevelHint = WindowTransparencyLevel.None;
  19. using Stream stream = Assembly.GetAssembly(typeof(Ryujinx.Ui.Common.Configuration.ConfigurationState)).GetManifestResourceStream("Ryujinx.Ui.Common.Resources.Logo_Ryujinx.png");
  20. Icon = new WindowIcon(stream);
  21. stream.Position = 0;
  22. IconImage = new Bitmap(stream);
  23. }
  24. public void LoadDialog()
  25. {
  26. ContentDialog = this.FindControl<ContentDialog>("ContentDialog");
  27. }
  28. protected override void OnOpened(EventArgs e)
  29. {
  30. base.OnOpened(e);
  31. ContentDialog = this.FindControl<ContentDialog>("ContentDialog");
  32. }
  33. protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
  34. {
  35. base.OnApplyTemplate(e);
  36. ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.SystemChrome | ExtendClientAreaChromeHints.OSXThickTitleBar;
  37. }
  38. }
  39. }