Add project files.
This commit is contained in:
46
ClipForge/App.xaml.cs
Normal file
46
ClipForge/App.xaml.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml;
|
||||
using WinRT.Interop;
|
||||
|
||||
namespace ClipForge
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
public MainWindow? MainWindow { get; private set; }
|
||||
public static DispatcherQueue? MainQueue { get; private set; }
|
||||
public TrayIconService? TrayIcon { get; private set; }
|
||||
|
||||
public App()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
|
||||
{
|
||||
MainQueue = DispatcherQueue.GetForCurrentThread();
|
||||
MainWindow = new MainWindow();
|
||||
MainWindow.Activate();
|
||||
|
||||
var hwnd = WindowNative.GetWindowHandle(MainWindow);
|
||||
TrayIcon = new TrayIconService();
|
||||
TrayIcon.Initialize(
|
||||
hwnd,
|
||||
showWindow: () =>
|
||||
{
|
||||
MainQueue?.TryEnqueue(() =>
|
||||
{
|
||||
MainWindow?.AppWindow.Show();
|
||||
MainWindow?.Activate();
|
||||
});
|
||||
},
|
||||
exitApp: () =>
|
||||
{
|
||||
MainQueue?.TryEnqueue(() =>
|
||||
{
|
||||
TrayIcon?.Dispose();
|
||||
Microsoft.UI.Xaml.Application.Current.Exit();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user