csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
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.
52 lines
1.5 KiB
52 lines
1.5 KiB
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Markup.Xaml;
|
|
using Avalonia.Threading;
|
|
using ReactiveUI;
|
|
using System;
|
|
using System.Reactive.Linq;
|
|
using System.Threading;
|
|
|
|
namespace ControlCatalog
|
|
{
|
|
public class MainWindow : Window
|
|
{
|
|
private Thread _initialThread;
|
|
|
|
public MainWindow()
|
|
{
|
|
this.InitializeComponent();
|
|
this.AttachDevTools();
|
|
Renderer.DrawFps = true;
|
|
Renderer.DrawDirtyRects = Renderer.DrawFps = true;
|
|
|
|
_initialThread = Thread.CurrentThread;
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
// TODO: iOS does not support dynamically loading assemblies
|
|
// so we must refer to this resource DLL statically. For
|
|
// now I am doing that here. But we need a better solution!!
|
|
var theme = new Avalonia.Themes.Default.DefaultTheme();
|
|
theme.TryGetResource("Button", out _);
|
|
AvaloniaXamlLoader.Load(this);
|
|
|
|
var timer = new DispatcherTimer
|
|
{
|
|
Interval = TimeSpan.FromSeconds(1),
|
|
};
|
|
|
|
Observable.FromEventPattern(timer, nameof(timer.Tick)).Throttle(TimeSpan.FromMilliseconds(500)).ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ =>
|
|
{
|
|
if (Thread.CurrentThread != _initialThread)
|
|
{
|
|
throw new SystemException();
|
|
}
|
|
});
|
|
|
|
timer.Start();
|
|
|
|
}
|
|
}
|
|
}
|
|
|