|
|
|
@ -23,10 +23,20 @@ namespace Avalonia.Win32 |
|
|
|
private IconImpl? _icon; |
|
|
|
private string? _tooltipText; |
|
|
|
private readonly Win32NativeToManagedMenuExporter _exporter; |
|
|
|
|
|
|
|
private static Dictionary<int, TrayIconImpl> s_trayIcons = new Dictionary<int, TrayIconImpl>(); |
|
|
|
private bool _disposedValue; |
|
|
|
|
|
|
|
public TrayIconImpl() |
|
|
|
{ |
|
|
|
_exporter = new Win32NativeToManagedMenuExporter(); |
|
|
|
|
|
|
|
_uniqueId = ++_nextUniqueId; |
|
|
|
|
|
|
|
s_trayIcons.Add(_uniqueId, this); |
|
|
|
} |
|
|
|
|
|
|
|
public Action? OnClicked { get; set; } |
|
|
|
|
|
|
|
public INativeMenuExporter MenuExporter => _exporter; |
|
|
|
|
|
|
|
internal static void ProcWnd(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam) |
|
|
|
@ -37,15 +47,6 @@ namespace Avalonia.Win32 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public TrayIconImpl() |
|
|
|
{ |
|
|
|
_exporter = new Win32NativeToManagedMenuExporter(); |
|
|
|
|
|
|
|
_uniqueId = ++_nextUniqueId; |
|
|
|
|
|
|
|
s_trayIcons.Add(_uniqueId, this); |
|
|
|
} |
|
|
|
|
|
|
|
public void SetIcon(IWindowIconImpl? icon) |
|
|
|
{ |
|
|
|
_icon = icon as IconImpl; |
|
|
|
@ -63,7 +64,6 @@ namespace Avalonia.Win32 |
|
|
|
UpdateIcon(!_iconAdded); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void UpdateIcon(bool remove = false) |
|
|
|
{ |
|
|
|
var iconData = new NOTIFYICONDATA() |
|
|
|
@ -105,9 +105,7 @@ namespace Avalonia.Win32 |
|
|
|
switch (lParam.ToInt32()) |
|
|
|
{ |
|
|
|
case (int)WindowsMessage.WM_LBUTTONUP: |
|
|
|
break; |
|
|
|
|
|
|
|
case (int)WindowsMessage.WM_LBUTTONDBLCLK: |
|
|
|
OnClicked?.Invoke(); |
|
|
|
break; |
|
|
|
|
|
|
|
case (int)WindowsMessage.WM_RBUTTONUP: |
|
|
|
@ -264,11 +262,11 @@ namespace Avalonia.Win32 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
~TrayIconImpl() |
|
|
|
{ |
|
|
|
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
|
|
|
Dispose(disposing: false); |
|
|
|
} |
|
|
|
~TrayIconImpl() |
|
|
|
{ |
|
|
|
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
|
|
|
Dispose(disposing: false); |
|
|
|
} |
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
{ |
|
|
|
|