A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

43 lines
1.1 KiB

using System;
using System.Runtime.InteropServices;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Threading;
namespace IntegrationTestApp;
public partial class TopmostWindowTest : Window
{
private readonly DispatcherTimer? _timer;
public TopmostWindowTest(string name)
{
Name = name;
InitializeComponent();
PositionChanged += (s, e) => CurrentPosition.Text = $"{Position}";
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
_timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(250) };
_timer.Tick += TimerOnTick;
_timer.Start();
}
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
_timer?.Stop();
}
private void TimerOnTick(object? sender, EventArgs e)
{
CurrentOrder.Text = MacOSIntegration.GetOrderedIndex(this).ToString();
}
private void Button_OnClick(object? sender, RoutedEventArgs e)
{
Position += new PixelPoint(100, 100);
}
}