citelao.SystrayIcon
0.1.0.1
dotnet add package citelao.SystrayIcon --version 0.1.0.1
NuGet\Install-Package citelao.SystrayIcon -Version 0.1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="citelao.SystrayIcon" Version="0.1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="citelao.SystrayIcon" Version="0.1.0.1" />
<PackageReference Include="citelao.SystrayIcon" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add citelao.SystrayIcon --version 0.1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: citelao.SystrayIcon, 0.1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package citelao.SystrayIcon@0.1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=citelao.SystrayIcon&version=0.1.0.1
#tool nuget:?package=citelao.SystrayIcon&version=0.1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
citelao.Systray
This is an unopinionated library for creating systray icons in dotnet, without needing to use WinForms or WPF.
It's designed to be as simple as possible while still being correct.
Features
- Very simple: a very lightweight wrapper over the
Shell_NotifyIcon
APIs: it does not add WinForms or WPF to your code. - Flexible: automatically processes & routes events for you, or you can use your own WndProc.
- Correct: re-registers on explorer.exe crashes & uses clear
PhysicalPoint
types to indicate physical vs scaled pixel locations.
Getting started
> dotnet add package citelao.Systray
Example
GUID iconGuid = /* a consistent GUID for this type of icon */;
IntPtr myHwnd = /* a new or existing HWND; the TrayIcon will subclass its wndproc. */;
var trayIcon = new TrayIcon(
guid: iconGuid,
ownerHwnd: new(myHwnd))
{
Icon = new(PInvoke.LoadIcon(default, PInvoke.IDI_APPLICATION)),
Tooltip = "Hello, Windows!",
ContextMenu = (hwnd, pt) =>
{
// Show a context menu at the specified point.
},
Select = (hwnd, pt) =>
{
// Handle selection
},
};
For a full example, see https://github.com/citelao/systray-doom/.
Feedback
The project repo is here: https://github.com/citelao/systray-doom/.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0-windows7.0
- crayon (>= 2.0.69)
GitHub repositories
This package is not used by any popular GitHub repositories.