ShowWindowTest.axaml.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using Avalonia.Controls;
  3. using Avalonia.Interactivity;
  4. using Avalonia.Markup.Xaml;
  5. using Avalonia.Rendering;
  6. namespace IntegrationTestApp
  7. {
  8. public class ShowWindowTest : Window
  9. {
  10. public ShowWindowTest()
  11. {
  12. InitializeComponent();
  13. }
  14. private void InitializeComponent()
  15. {
  16. AvaloniaXamlLoader.Load(this);
  17. }
  18. protected override void OnOpened(EventArgs e)
  19. {
  20. base.OnOpened(e);
  21. this.GetControl<TextBox>("ClientSize").Text = $"{Width}, {Height}";
  22. this.GetControl<TextBox>("FrameSize").Text = $"{FrameSize}";
  23. this.GetControl<TextBox>("Position").Text = $"{Position}";
  24. this.GetControl<TextBox>("ScreenRect").Text = $"{Screens.ScreenFromVisual(this)?.WorkingArea}";
  25. this.GetControl<TextBox>("Scaling").Text = $"{((IRenderRoot)this).RenderScaling}";
  26. if (Owner is not null)
  27. {
  28. var ownerRect = this.GetControl<TextBox>("OwnerRect");
  29. var owner = (Window)Owner;
  30. ownerRect.Text = $"{owner.Position}, {owner.FrameSize}";
  31. }
  32. }
  33. private void CloseWindow_Click(object sender, RoutedEventArgs e) => Close();
  34. }
  35. }