Public/New-BTContextMenuItem.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function New-BTContextMenuItem {
    <#
        .SYNOPSIS
        Creates a Context Menu Item object.
 
        .DESCRIPTION
        The New-BTContextMenuItem function creates a Context Menu Item object.
 
        .INPUTS
        None
 
        .OUTPUTS
        ToastContextMenuItem
 
        .EXAMPLE
        New-BTContextMenuItem -Content 'Google' -Arguments 'https://google.com' -ActivationType Protocol
 
        This command creates a new Context Menu Item object with the specified properties.
 
        .NOTES
        Credit for most of the help text for this function go to the authors of the UWPCommunityToolkit library that this module relies upon.
 
        Please see the originating repo here: https://github.com/Microsoft/UWPCommunityToolkit
 
        .LINK
        https://github.com/Windos/BurntToast/blob/master/Help/New-BTContextMenuItem.md
    #>


    [CmdletBinding()]
    [OutputType([Microsoft.Toolkit.Uwp.Notifications.ToastContextMenuItem])]

    param (
        # The text to display on the menu item.
        [Parameter(Mandatory)]
        [string] $Content,

        # App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the menu item.
        [Parameter(Mandatory)]
        [string] $Arguments,

        # Controls what type of activation this menu item will use when clicked. Defaults to Foreground.
        [Parameter()]
        [Microsoft.Toolkit.Uwp.Notifications.ToastActivationType] $ActivationType
    )

    $MenuItem = [Microsoft.Toolkit.Uwp.Notifications.ToastContextMenuItem]::new($Content, $Arguments)

    if ($ActivationType) {
        $MenuItem.ActivationType = $ActivationType
    }

    $MenuItem
}