Skip to content

Commit

Permalink
Merge pull request #132 from UniverseCitiz3n/main
Browse files Browse the repository at this point in the history
Adding feature to handle HeroImage
  • Loading branch information
Windos committed Dec 23, 2020
2 parents b542c7a + 161ed16 commit 78c27a1
Showing 1 changed file with 50 additions and 42 deletions.
92 changes: 50 additions & 42 deletions BurntToast/Public/New-BurntToastNotification.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function New-BurntToastNotification {
<#
.SYNOPSIS
Creates and displays a Toast Notification.
.SYNOPSIS
Creates and displays a Toast Notification.
.DESCRIPTION
The New-BurntToastNotification function creates and displays a Toast Notification on Microsoft Windows 10.
Expand Down Expand Up @@ -69,8 +69,8 @@

[Alias('Toast')]
[CmdletBinding(DefaultParameterSetName = 'Sound',
SupportsShouldProcess = $true,
HelpUri = 'https://github.com/Windos/BurntToast/blob/main/Help/New-BurntToastNotification.md')]
SupportsShouldProcess = $true,
HelpUri = 'https://github.com/Windos/BurntToast/blob/main/Help/New-BurntToastNotification.md')]
param (
# Specifies the text to show on the Toast Notification. Up to three strings can be displayed, the first of which will be embolden as a title.
[ValidateCount(0, 3)]
Expand All @@ -86,68 +86,71 @@
# Specifies the path to an image that will override the default image displayed with a Toast Notification.
[String] $AppLogo,

# Specifies the path to an image that will be displayed with a Toast Notification in Hero section.
[String] $Hero,

# Selects the sound to acompany the Toast Notification. Any 'Alarm' or 'Call' tones will automatically loop and extent the amount of time that a Toast is displayed on screen.
#
# Cannot be used in conjunction with the 'Silent' switch.
[Parameter(ParameterSetName = 'Sound')]
[Parameter(Mandatory = $true,
ParameterSetName = 'Sound-SnD')]
ParameterSetName = 'Sound-SnD')]
[Parameter(Mandatory = $true,
ParameterSetName = 'Sound-Button')]
ParameterSetName = 'Sound-Button')]
[ValidateSet('Default',
'IM',
'Mail',
'Reminder',
'SMS',
'Alarm',
'Alarm2',
'Alarm3',
'Alarm4',
'Alarm5',
'Alarm6',
'Alarm7',
'Alarm8',
'Alarm9',
'Alarm10',
'Call',
'Call2',
'Call3',
'Call4',
'Call5',
'Call6',
'Call7',
'Call8',
'Call9',
'Call10')]
'IM',
'Mail',
'Reminder',
'SMS',
'Alarm',
'Alarm2',
'Alarm3',
'Alarm4',
'Alarm5',
'Alarm6',
'Alarm7',
'Alarm8',
'Alarm9',
'Alarm10',
'Call',
'Call2',
'Call3',
'Call4',
'Call5',
'Call6',
'Call7',
'Call8',
'Call9',
'Call10')]
[String] $Sound = 'Default',

# Indicates that the Toast Notification will be displayed on screen without an accompanying sound.
#
# Cannot be used in conjunction with the 'Sound' parameter.
[Parameter(Mandatory = $true,
ParameterSetName = 'Silent')]
ParameterSetName = 'Silent')]
[Parameter(Mandatory = $true,
ParameterSetName = 'Silent-SnD')]
ParameterSetName = 'Silent-SnD')]
[Parameter(Mandatory = $true,
ParameterSetName = 'Silent-Button')]
ParameterSetName = 'Silent-Button')]
[Switch] $Silent,

# Adds a default selection box and snooze/dismiss buttons to the bottom of the Toast Notification.
[Parameter(Mandatory = $true,
ParameterSetName = 'SnD')]
ParameterSetName = 'SnD')]
[Parameter(Mandatory = $true,
ParameterSetName = 'Silent-SnD')]
ParameterSetName = 'Silent-SnD')]
[Parameter(Mandatory = $true,
ParameterSetName = 'Sound-SnD')]
ParameterSetName = 'Sound-SnD')]
[Switch] $SnoozeAndDismiss,

# Allows up to five buttons to be added to the bottom of the Toast Notification. These buttons should be created using the New-BTButton function.
[Parameter(Mandatory = $true,
ParameterSetName = 'Button')]
ParameterSetName = 'Button')]
[Parameter(Mandatory = $true,
ParameterSetName = 'Silent-Button')]
ParameterSetName = 'Silent-Button')]
[Parameter(Mandatory = $true,
ParameterSetName = 'Sound-Button')]
ParameterSetName = 'Sound-Button')]
[Microsoft.Toolkit.Uwp.Notifications.IToastButton[]] $Button,

# Specify the Toast Header object created using the New-BTHeader function, for seperation/categorization of toasts from the same AppId.
Expand Down Expand Up @@ -198,6 +201,10 @@
$AppLogoImage = New-BTImage -AppLogoOverride -Crop Circle -WhatIf:$false
}

if ($Hero) {
$HeroImage = New-BTImage -Source $Hero -HeroImage -WhatIf:$false
}

if ($Silent) {
$Audio = New-BTAudio -Silent -WhatIf:$false
} else {
Expand All @@ -214,6 +221,7 @@
$BindingSplat = @{
Children = $ChildObjects
AppLogoOverride = $AppLogoImage
HeroImage = $HeroImage
WhatIf = $false
}

Expand All @@ -225,7 +233,7 @@
$Visual = New-BTVisual -BindingGeneric $Binding -WhatIf:$false

$ContentSplat = @{'Audio' = $Audio
'Visual' = $Visual
'Visual' = $Visual
}

if ($Long) {
Expand All @@ -250,7 +258,7 @@

$ToastSplat = @{
Content = $Content
AppId = $Script:Config.AppId
AppId = $Script:Config.AppId
}

if ($UniqueIdentifier) {
Expand Down Expand Up @@ -278,7 +286,7 @@
$ToastSplat.Add('DismissedAction', $DismissedAction)
}

if($PSCmdlet.ShouldProcess( "submitting: $($Content.GetContent())" )) {
if ($PSCmdlet.ShouldProcess( "submitting: $($Content.GetContent())" )) {
Submit-BTNotification @ToastSplat
}
}

0 comments on commit 78c27a1

Please sign in to comment.