-
-
Notifications
You must be signed in to change notification settings - Fork 120
/
New-BTHeader.ps1
70 lines (52 loc) · 2.77 KB
/
New-BTHeader.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function New-BTHeader {
<#
.SYNOPSIS
Creates a new toast notification header.
.DESCRIPTION
The New-BTHeader function creates a new toast notification header for a Toast Notification.
These headers are diaplyed at the top of a toast and are also used to categorize toasts in the Action Center.
.INPUTS
None
You cannot pipe input to this function.
.OUTPUTS
Microsoft.Toolkit.Uwp.Notifications.ToastHeader
.EXAMPLE
New-BTHeader -Title 'First Category'
This command creates a Toast Header object, which will be displayed with the text "First Category."
.EXAMPLE
New-BTHeader -Id '001' -Title 'Stack Overflow Questions' -Arguments 'http://stackoverflow.com/'
This command creates a Toast Header object, which will be displayed with the text "First Category."
Clicking the header will take the user to the Stack Overflow website.
.LINK
https://github.com/Windos/BurntToast/blob/main/Help/New-BTHeader.md
#>
[CmdletBinding(SupportsShouldProcess = $true,
HelpUri = 'https://github.com/Windos/BurntToast/blob/main/Help/New-BTHeader.md')]
param (
# Unique string that identifies a header. If a new Id is provided, the system will treat the header as a new header even if it has the same display text as a previous header.
#
# It is possible to update a header's display text by re-using the Id but changing the title.
[Parameter()]
[string] $Id = 'ID' + (New-Guid).ToString().Replace('-','').ToUpper(),
# The header string that is displayed to the user.
[Parameter(Mandatory)]
[string] $Title,
# Specifies an app defined string.
#
# For the purposes of BurntToast notifications this is generally the path to a file or URI and paired with the Protocol ActivationType.
[Parameter()]
[string] $Arguments,
# Defines tne ActivationType that is trigger when the button is pressed.
#
# Defaults to Protocol which will open the file or URI specified in with the Arguments parameter in the relevant system default application.
[Parameter()]
[Microsoft.Toolkit.Uwp.Notifications.ToastActivationType] $ActivationType = [Microsoft.Toolkit.Uwp.Notifications.ToastActivationType]::Protocol
)
$Header = [Microsoft.Toolkit.Uwp.Notifications.ToastHeader]::new($Id, ($Title -replace '\x01'), $Arguments)
if ($ActivationType) {
$Header.ActivationType = $ActivationType
}
if($PSCmdlet.ShouldProcess("returning: [$($Header.GetType().Name)]:Id=$($Header.Id):Title=$($Header.Title):Arguments=$($Header.Arguments):ActivationType=$($Header.ActivationType)")) {
$Header
}
}