From 1b8d3f27069c9fa12a896cba06bdc251b71a0b4c Mon Sep 17 00:00:00 2001 From: Simon G Date: Wed, 7 Apr 2021 13:26:11 +0200 Subject: [PATCH] - add notify icon --- Mystify/App.axaml.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Mystify/App.axaml.cs b/Mystify/App.axaml.cs index 03cf0f5..e846b63 100644 --- a/Mystify/App.axaml.cs +++ b/Mystify/App.axaml.cs @@ -2,6 +2,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; +using Lib.NotifyIcon; using LightweightIocContainer.Interfaces; using Mystify.ViewModels; using Mystify.Views; @@ -11,6 +12,7 @@ namespace Mystify public class App : Application { private IIocContainer? _kernel; + private INotifyIcon? _notifyIcon; public override void Initialize() => AvaloniaXamlLoader.Load(this); public override void OnFrameworkInitializationCompleted() @@ -29,11 +31,20 @@ namespace Mystify }; desktopStyleApplicationLifetime.Exit += OnExit; + + _notifyIcon = _kernel.Resolve(); + _notifyIcon.ToolTipText = "Test tool tip"; + _notifyIcon.IconPath = "avares://Mystify/Resources/TestIcon.ico"; + _notifyIcon.Visible = true; } base.OnFrameworkInitializationCompleted(); } - private void OnExit(object? sender, ControlledApplicationLifetimeExitEventArgs args) => _kernel?.Dispose(); + private void OnExit(object? sender, ControlledApplicationLifetimeExitEventArgs args) + { + _notifyIcon?.Remove(); + _kernel?.Dispose(); + } } } \ No newline at end of file