• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A library for toast notifications from desktop app

Desktop Toast

A library for toast notifications from desktop app. This library will, if necessary, install a shortcut in Windows startup and show a toast asynchronously.

Requirements

  • .NET Framework 4.5.2
  • Windows 8.0 or newer

Contents

  • DesktopToast - The library.

  • DesktopToast.Wpf - Sample WPF app to use this library.

  • DesktopToast.WinForms - Sample WinForms app to use this library.

  • DesktopToast.Proxy - Sample console app which acts as proxy to this library. This app will accept a request in JSON format from standard input, transfer the request to this library and return the result to standard output.

Note

  • Windows in project references is for using Windows Runtime (WinRT) API. It refers to Windows.winmd whose location has been changed over time. If it is not solved, find its location in your system and modify its path in .csproj file.

Usage

Instantiate ToastRequest class, set its properties and then call ToastManager.ShowAsync method.

public async Task<bool> ShowToastAsync()
{
    var request = new ToastRequest
    {
        ToastTitle = "DesktopToast WPF Sample",
        ToastBody = "This is a toast test.",
        ToastLogoFilePath = string.Format("file:///{0}", Path.GetFullPath("toast128.png")),
        ShortcutFileName = "DesktopToast.Wpf.lnk",
        ShortcutTargetFilePath = Assembly.GetExecutingAssembly().Location,
        AppId = "DesktopToast.Wpf",
    };

    var result = await ToastManager.ShowAsync(request);

    return (result == ToastResult.Activated);
}

ToastRequest class is a container of information necessary for installing a shortcut and showing a toast. It has the following properties:

Property Description Note
ToastTitle Toast title Optional
ToastBody Toast body Required for toast
ToastBodyList Toast body list (If specified, toast body will be substituted by this list.) Optional
ToastLogoFilePath Logo image file path of toast Optional
ToastAudio Audio type of toast Optional
ToastXml XML representation of Toast (If specified, this XML will be used for a toast as it is.) Optional
ShortcutFileName Shortcut file name to be installed in Windows startup Required for shortcut
ShortcutTargetFilePath Target file path of shortcut Required for shortcut
ShortcutArguments Arguments of shortcut Optional
ShortcutComment Comment of shortcut Optional
ShortcutWorkingFolder Working folder of shortcut Optional
ShortcutWindowState Window state of shortcut Optional
ShortcutIconFilePath Icon file path of shortcut Optional
AppId AppUserModelID of application Required
ActivatorId AppUserModelToastActivatorCLSID of application (for Action Center of Windows 10) Optional
WaitingDuration Waiting duration before showing a toast after the shortcut file is installed Optional

Action Center of Windows 10

To interact with Action Center of Windows 10, an application needs to register COM class type which implements INotificationActivationCallback. In addition, the registration of COM server in the registry is required for an application to be started by COM when it is not running.

See WPF sample for implementation. Note that the CLSID of COM class type (AppUserModelToastActivatorCLSID) must be unique for each application.

Also check the following sample.

Interactive toast of Windows 10

To show an interactive toast of Windows 10, prepare a XML representation of toast and set it to ToastXml property. Check the following article.

You can compose it from scratch or utilize NotificationsExtensions.Win10 library. See WPF sample.

License

  • MIT License

More Repositories

1

Monitorian

A Windows desktop tool to adjust the brightness of multiple monitors with ease
C#
3,278
star
2

Wifinian

A Windows desktop tool to enable user to actively control Wi-Fi connections
C#
241
star
3

ManagedNativeWifi

A managed implementation of Native Wifi API
C#
139
star
4

HelloSwitcher

A Windows desktop tool to help switching cameras for Windows Hello
C#
37
star
5

RawInput.Touchpad

Sample to capture inputs from Precision Touchpad by Raw Input API
C#
35
star
6

SnowyImageCopy

A Windows desktop app to copy images from FlashAir by a wireless connection
C#
32
star
7

WpfMonitorAware

A library for Per-Monitor DPI aware and color profile aware Window
C#
32
star
8

HashPad

A simple tool to compute and compare hash value including from Explorer's context menu
C#
26
star
9

CortanaSwitcher

Enable/Disable Cortana in Windows 10 Anniversay Update
C#
14
star
10

ExifTimeShift

A simple tool to shift date/time of JPG files by directly changing Exif date fields while leaving other data intact
C#
14
star
11

WindowCornerTest

Rounded corners of window on Windows 11 applicable to WPF.
C#
9
star
12

DiskGazer

A high-definition disk measuring tool which can measure the transfer rates of a physical disk in a small unit and at any location in the disk
C#
8
star
13

WpfControlCollection

A collection of WPF controls such as ProgressBar.
C#
6
star
14

TrimCopy

A Visual Studio extension to copy code block trimming leading white spaces while keeping indentation structure
C#
4
star
15

DeviceDetect

Sample Windows service to detect device events
C#
3
star
16

BatteryProbe

A Windows desktop app to probe battery information
C#
3
star
17

WpfBuiltinDpiTest

Test WPF Built-in scaling for Per-Monitor DPI.
C#
3
star
18

WinFormsControlCollection

A collection of WinForms controls such as ProgressBar.
C#
2
star
19

PowerMapView

C#
2
star
20

OsVersionDetect

Sample methods to detect Windows OS versions
C#
2
star
21

StripeMaker

A design tool to create the tile visuals for striped background
C#
2
star
22

PowerMonitor

A library to check electric power data of Japanese electric power companies
Visual Basic .NET
2
star
23

FontAlignment

A set of tools for adjusting the vertical center of text taking font metric into account
C#
1
star
24

SdrTest

Test SDR.
C#
1
star
25

SynapseBane

Stop Razor Synapse 3 from automatically creating c:\temp\ folder by changing NLog config files.
C#
1
star
26

WindowsRuntimeSettings

A library for Windows Runtime app to save/load settings of various types with encryption if necessary
C#
1
star
27

LargeFileProxy

An attempt to make a proxy for a large text file delimited by line breaks.
C#
1
star
28

StringReaderCatalog

A catalog of methods to read string by C#, especially focusing on handling of Unicode BOM
C#
1
star
29

WpfColorManagement

A sample attached property of color profile for color management
C#
1
star
30

IlluminoChecker

Visualize ambient light sensor output and corresponding screen brightness adjusted by adaptive brightness.
C#
1
star