|
|
|
@ -1,3 +1,4 @@ |
|
|
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
using Avalonia; |
|
|
|
using Avalonia; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Controls.ApplicationLifetimes; |
|
|
|
using Avalonia.Controls.ApplicationLifetimes; |
|
|
|
@ -6,6 +7,7 @@ using Lib.NotifyIcon; |
|
|
|
using LightweightIocContainer.Interfaces; |
|
|
|
using LightweightIocContainer.Interfaces; |
|
|
|
using Mystify.ViewModels; |
|
|
|
using Mystify.ViewModels; |
|
|
|
using Mystify.Views; |
|
|
|
using Mystify.Views; |
|
|
|
|
|
|
|
using ReactiveUI; |
|
|
|
|
|
|
|
|
|
|
|
namespace Mystify |
|
|
|
namespace Mystify |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -13,6 +15,7 @@ namespace Mystify |
|
|
|
{ |
|
|
|
{ |
|
|
|
private IIocContainer? _kernel; |
|
|
|
private IIocContainer? _kernel; |
|
|
|
private INotifyIcon? _notifyIcon; |
|
|
|
private INotifyIcon? _notifyIcon; |
|
|
|
|
|
|
|
private MainWindow? _mainWindow; |
|
|
|
|
|
|
|
|
|
|
|
public override void Initialize() => AvaloniaXamlLoader.Load(this); |
|
|
|
public override void Initialize() => AvaloniaXamlLoader.Load(this); |
|
|
|
public override void OnFrameworkInitializationCompleted() |
|
|
|
public override void OnFrameworkInitializationCompleted() |
|
|
|
@ -22,19 +25,30 @@ namespace Mystify |
|
|
|
|
|
|
|
|
|
|
|
Bootstrapper bootstrapper = new(); |
|
|
|
Bootstrapper bootstrapper = new(); |
|
|
|
_kernel = bootstrapper.BootstrapKernel(); |
|
|
|
_kernel = bootstrapper.BootstrapKernel(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_mainWindow = new MainWindow |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
DataContext = new MainWindowViewModel() |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopStyleApplicationLifetime) |
|
|
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopStyleApplicationLifetime) |
|
|
|
{ |
|
|
|
{ |
|
|
|
desktopStyleApplicationLifetime.MainWindow = new MainWindow |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
DataContext = new MainWindowViewModel() |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
desktopStyleApplicationLifetime.Exit += OnExit; |
|
|
|
desktopStyleApplicationLifetime.Exit += OnExit; |
|
|
|
|
|
|
|
|
|
|
|
_notifyIcon = _kernel.Resolve<INotifyIcon>(); |
|
|
|
_notifyIcon = _kernel.Resolve<INotifyIcon>(); |
|
|
|
_notifyIcon.ToolTipText = "Test tool tip"; |
|
|
|
_notifyIcon.ToolTipText = "Test tool tip"; |
|
|
|
_notifyIcon.IconPath = "avares://Mystify/Resources/TestIcon.ico"; |
|
|
|
_notifyIcon.IconPath = "avares://Mystify/Resources/TestIcon.ico"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ContextMenu notifyIconContextMenu = new() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Items = new List<MenuItem> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
new() {Header = "Close", Command = ReactiveCommand.Create(() => desktopStyleApplicationLifetime.Shutdown())} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_notifyIcon.ContextMenu = notifyIconContextMenu; |
|
|
|
|
|
|
|
_notifyIcon.DoubleClick += (_, _) => _mainWindow?.Show(); |
|
|
|
_notifyIcon.Visible = true; |
|
|
|
_notifyIcon.Visible = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|