https://github.com/trympet/trayiconbindings
A fast, object-oriented wrapper for the Shell_NotifyIcon API
https://github.com/trympet/trayiconbindings
csharp system-tray systray tray-icon tray-menu win32
Last synced: about 1 year ago
JSON representation
A fast, object-oriented wrapper for the Shell_NotifyIcon API
- Host: GitHub
- URL: https://github.com/trympet/trayiconbindings
- Owner: trympet
- Created: 2022-02-06T20:43:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-11-22T22:06:29.000Z (over 2 years ago)
- Last Synced: 2025-02-23T12:47:05.444Z (over 1 year ago)
- Topics: csharp, system-tray, systray, tray-icon, tray-menu, win32
- Language: C#
- Homepage:
- Size: 131 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SimpleTrayIcon
A fast, lightweight, object oriented wrapper for the [Shell_NotifyIcon](https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shell_notifyiconw) API with no framework dependencies.
[](https://www.nuget.org/packages/SimpleTrayIcon/)
## Usage
```csharp
var icon = new System.Drawing.Icon(typeof(Program), "SimpleTrayIcon.Demo.tray-icon.ico"); // Load an icon for the tray
using var menu = new TrayMenu(icon, "Tooltip", true);
var item = new TrayMenuItem { Content = "Item1" };
menu.Items.Add(item);
menu.Items.Add(new TrayMenuSeparator());
menu.Items.Add(new TrayMenuItem { Content = $"some content", IsChecked = true });
item.Click += (s, e) => ((TrayMenuItem)s).IsChecked = !((TrayMenuItem)s).IsChecked; // Attach an event
NativeMethods.RunLoop(); // Runs the message pump. Winforms, WPF, etc., will do this for you.
```
## NativeAOT Linking Options
SimpleTrayIcon is fully AOT compatible.
You can build with static linking to a static library or dynamic library (with DLL).
To enable static linking to the SimpleTrayIcon DLL:
```xml
true
```
To enable static linking to the SimpleTrayIcon static library:
```xml
true
true
```
## OneCore
There is a OneCore SKU of the package `SimpleTrayIcon.onecore` which links to OneCoreUAP and VCRUNTIME140_APP. It is indeed *not* OneCoreUAP compatible, but is compatible with any full-trust UWP apps. This package does not support static linking.