Skip to content

Lightweight Windows Notification Icon without any dependencies

Notifications You must be signed in to change notification settings

BlyZeDev/DotTray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DotTray

Show lightweight Windows Notification Icons simple and easy without any dependencies.

NuGet

Current features - for feature requests just open an issue here

  • Fully non-blocking API with async support
  • Easily create multiple icons at once and handle them individually without any complicated code required
  • Changing icon at runtime
  • Changing tooltip at runtime
  • Changing menu items at runtime
  • CancellationToken support to easily tie cancellation to other operations
  • Show detailed balloon notifications with customization options
  • NativeAOT compatible

Quickstart

var menuItems = new MenuItemCollection(
[
    new MenuItem
    {
        Text = "Item Number 1",
        Click = (sender, args) => Console.WriteLine("Item Number 1 Clicked")
    },
    new MenuItem
    {
        Text = "Item Number 2",
        IsDisabled = true
    },
    new MenuItem
    {
        Text = "Item Number 3",
        IsChecked = true,
        Click = (sender, args) => Console.WriteLine($"Item Number 3 was {(sender.IsChecked ?? false ? "checked" : "unchecked")}")
    },
    new MenuItem
    {
        Text = "Item Number 4",
        SubMenu = new MenuItemCollection(
        [
            new MenuItem
            {
                Text = "SubItem Number 1"
            },
            new MenuItem
            {
                Text = "SubItem Number 2",
                Click = (sender, args) => Console.WriteLine("SubItem Number 2 Clicked")
            }
        ])
    }
]);

using (var notifyIcon = NotifyIcon.Run(@"path\to\my\icon.ico", menuItems, CancellationToken.None))
{
    Console.ReadKey();
}

This example will look something like this. The exact look depends on your Windows Version

grafik

Show a Balloon Message

notifyIcon.ShowBalloon(new BalloonNotification
{
    Icon = BalloonNotificationIcon.Error,
    Title = "An error occurred",
    Message = "This is a fictional error message. You can show some useful information here :)",
    NoSound = false
});

This balloon message will look something like this. The exact look depends on your Windows Version

balloonmsg

About

Lightweight Windows Notification Icon without any dependencies

Resources

Stars

Watchers

Forks

Languages