From 018ec395f6a9a82a27829561775b9e2748923303 Mon Sep 17 00:00:00 2001 From: Josh King Date: Sun, 27 Jul 2025 12:14:05 +1200 Subject: [PATCH 1/4] (#264) Add Urgent switch support to BurntToast cmdlets for important notifications Add -Urgent switch to Submit-BTNotification and New-BurntToastNotification to designate toasts as "Important Notifications" that break through Focus Assist. Fixes #264 --- Help/New-BTContent.md | 2 +- Help/New-BurntToastNotification.md | 10 ++++++++ Help/Submit-BTNotification.md | 3 ++- Tests/New-BurntToastNotification.Tests.ps1 | 6 +++++ Tests/Submit-BTNotification.Tests.ps1 | 6 +++++ src/Public/New-BTContent.ps1 | 1 + src/Public/New-BurntToastNotification.ps1 | 12 +++++++++- src/Public/Submit-BTNotification.ps1 | 28 +++++++++++++++------- 8 files changed, 57 insertions(+), 11 deletions(-) diff --git a/Help/New-BTContent.md b/Help/New-BTContent.md index 4187193..3b88ffb 100644 --- a/Help/New-BTContent.md +++ b/Help/New-BTContent.md @@ -18,7 +18,7 @@ The `New-BTContent` function creates a new `ToastContent` object, the root confi | `Duration` | Microsoft.Toolkit.Uwp.Notifications.ToastDuration| Enum. How long the toast notification is displayed (Short/Long). | No | | `Header` | Microsoft.Toolkit.Uwp.Notifications.ToastHeader | ToastHeader object, created via `New-BTHeader`, categorizing the toast in Action Center. | No | | `Launch` | String | Data passed to the activation context when a toast is clicked. | No | -| `Scenario` | Microsoft.Toolkit.Uwp.Notifications.ToastScenario| Enum. Tells Windows to treat the toast as an alarm, reminder, or more (`ToastScenario`). | No | +| `Scenario` | Microsoft.Toolkit.Uwp.Notifications.ToastScenario| Enum. Tells Windows to treat the toast as an alarm, reminder, or more (`ToastScenario`). Will be ignored if toast is submitted with `-Urgent` switch on the Submit-BTNotification function, as the Urgent scenario takes precedence but cannot be set via this parameter. | No | | `Visual` | Microsoft.Toolkit.Uwp.Notifications.ToastVisual | **Required.** ToastVisual object, created by `New-BTVisual`, representing the core content of the toast. | Yes | | `ToastPeople` | Microsoft.Toolkit.Uwp.Notifications.ToastPeople | ToastPeople object, representing recipient/persons (optional, used for group chat/etc). | No | | `CustomTimestamp`| DateTime | Optional timestamp for when the toast is considered created (affects Action Center sort order). | No | diff --git a/Help/New-BurntToastNotification.md b/Help/New-BurntToastNotification.md index 2af659a..1103b13 100644 --- a/Help/New-BurntToastNotification.md +++ b/Help/New-BurntToastNotification.md @@ -8,6 +8,7 @@ Creates and displays a rich Toast Notification for Windows. The `New-BurntToastNotification` function creates and displays a Toast Notification supporting text, images, sounds, progress bars, actions, snooze/dismiss, and more on Microsoft Windows 10+. Parameter sets ensure mutual exclusivity (e.g., you cannot use Silent and Sound together). +The `-Urgent` switch will designate the toast as an "Important Notification" that can break through Focus Assist. ## PARAMETERS @@ -32,6 +33,7 @@ Parameter sets ensure mutual exclusivity (e.g., you cannot use Silent and Sound | `ActivatedAction` | ScriptBlock | Script block to invoke when the toast is activated (clicked). | No | | `DismissedAction` | ScriptBlock | Script block to invoke when the toast is dismissed by the user. | No | | `EventDataVariable`| String | The name of the global variable that will contain event data for use in event handler script blocks. | No | +| `Urgent` | Switch | Designates the toast as an "Important Notification" (scenario 'urgent'), allowing breakthrough of Focus Assist. | No | ## INPUTS @@ -85,6 +87,14 @@ New-BurntToastNotification -Text 'Integration Complete' -Attribution 'Powered by Displays a notification with attribution at the bottom, e.g., "Powered by BurntToast". +### Example: Important Notification with Urgent + +```powershell +New-BurntToastNotification -Text 'Critical System Alert' -Urgent +``` + +Marks the notification as "Important", causing it to break through Focus Assist. + ## LINKS - [New-BTButton](New-BTButton.md) diff --git a/Help/Submit-BTNotification.md b/Help/Submit-BTNotification.md index 173f68e..aa7cd88 100644 --- a/Help/Submit-BTNotification.md +++ b/Help/Submit-BTNotification.md @@ -7,7 +7,7 @@ Submits a completed toast notification for display. ## DESCRIPTION The `Submit-BTNotification` function submits a completed toast notification to the operating system's notification manager for display. -This function supports advanced scenarios such as event callbacks for user actions or toast dismissal, sequence numbering to ensure correct update order, unique identification for toast replacement, expiration control, and direct Action Center delivery. +This function supports advanced scenarios such as event callbacks for user actions or toast dismissal, sequence numbering to ensure correct update order, unique identification for toast replacement, expiration control, direct Action Center delivery, and designating a notification as "Important" (using the `-Urgent` switch) so that it can break through Focus Assist. When a script block is supplied for any of the event actions (`ActivatedAction`, `DismissedAction`, or `FailedAction`), the function ensures that only one registration for a logically identical handler is allowed per notification event type. This is accomplished by normalizing and hashing the script block; the resulting hash uniquely identifies the action for event registration purposes. Attempting to register the same handler multiple times for a given event will not create a duplicate subscription, but instead will produce an informative warning. @@ -27,6 +27,7 @@ Specifying `-EventDataVariable` implicitly enables the behavior of `-ReturnEvent | `DataBinding` | Hashtable | Hashtable mapping strings to binding keys in a toast notification. Enables advanced updating scenarios. | No | | `ExpirationTime` | DateTime | When the notification is no longer relevant and should be removed from the Action Center. | No | | `SuppressPopup` | Switch | If set, the notification is delivered directly to the Action Center (bypassing immediate display). | No | +| `Urgent` | Switch | If set, designates the toast as an "Important Notification" (scenario 'urgent') which can break through Focus Assist, ensuring the notification is delivered even when user focus mode is enabled. | No | | `ActivatedAction` | ScriptBlock | A script block executed if the user activates/clicks the toast notification. | No | | `DismissedAction` | ScriptBlock | A script block executed if the user dismisses the toast notification. | No | | `FailedAction` | ScriptBlock | A script block executed if the notification fails to display properly. | No | diff --git a/Tests/New-BurntToastNotification.Tests.ps1 b/Tests/New-BurntToastNotification.Tests.ps1 index 0c943a6..c66971a 100644 --- a/Tests/New-BurntToastNotification.Tests.ps1 +++ b/Tests/New-BurntToastNotification.Tests.ps1 @@ -182,3 +182,9 @@ Context 'include attribution string' { $Log | Should -Be $Expected } } + +Context 'Urgent scenarios' { + It 'does not throw when using -Urgent' { + { New-BurntToastNotification -Text 'Critical Alert' -Urgent -WhatIf } | Should -Not -Throw + } +} diff --git a/Tests/Submit-BTNotification.Tests.ps1 b/Tests/Submit-BTNotification.Tests.ps1 index 03fcfe8..3763405 100644 --- a/Tests/Submit-BTNotification.Tests.ps1 +++ b/Tests/Submit-BTNotification.Tests.ps1 @@ -47,4 +47,10 @@ Describe 'Submit-BTNotification' { $output | Should -Not -Contain "Duplicate or conflicting OnActivated ScriptBlock event detected" } } +Context 'Urgent scenario' { + It 'runs without error with -Urgent' { + $mockContent = [Activator]::CreateInstance([Microsoft.Toolkit.Uwp.Notifications.ToastContent]) + { Submit-BTNotification -Content $mockContent -Urgent -WhatIf } | Should -Not -Throw + } +} } \ No newline at end of file diff --git a/src/Public/New-BTContent.ps1 b/src/Public/New-BTContent.ps1 index e27770e..5642f85 100644 --- a/src/Public/New-BTContent.ps1 +++ b/src/Public/New-BTContent.ps1 @@ -26,6 +26,7 @@ .PARAMETER Scenario Enum. Tells Windows to treat the toast as an alarm, reminder, or more (ToastScenario). + Will be ignored if toast is submitted with `-Urgent` switch on the Submit-BTNotification function, as the Urgent scenario takes precedence but cannot be set via this parameter. .PARAMETER Visual Required. ToastVisual object, created by New-BTVisual, representing the core content of the toast. diff --git a/src/Public/New-BurntToastNotification.ps1 b/src/Public/New-BurntToastNotification.ps1 index 2800027..0a1b628 100644 --- a/src/Public/New-BurntToastNotification.ps1 +++ b/src/Public/New-BurntToastNotification.ps1 @@ -6,6 +6,7 @@ .DESCRIPTION The New-BurntToastNotification function creates and displays a Toast Notification supporting text, images, sounds, progress bars, actions, snooze/dismiss, attribution, and more on Microsoft Windows 10+. Parameter sets ensure mutual exclusivity (e.g., you cannot use Silent and Sound together). + The `-Urgent` switch will designate the toast as an "Important Notification" that can break through Focus Assist. .PARAMETER Text Up to 3 strings to show within the Toast Notification. The first is the title. @@ -64,6 +65,9 @@ .PARAMETER EventDataVariable The name of the global variable that will contain event data for use in event handler script blocks. + .PARAMETER Urgent + If set, designates the toast as an "Important Notification" (scenario 'urgent'), allowing it to break through Focus Assist. + .INPUTS None. You cannot pipe input to this function. @@ -186,7 +190,9 @@ [scriptblock] $DismissedAction, - [string] $EventDataVariable + [string] $EventDataVariable, + + [switch] $Urgent ) $ChildObjects = @() @@ -300,6 +306,10 @@ $ToastSplat.Add('EventDataVariable', $EventDataVariable) } + if ($Urgent) { + $ToastSplat.Add('Urgent', $true) + } + if ($PSCmdlet.ShouldProcess( "submitting: $($Content.GetContent())" )) { Submit-BTNotification @ToastSplat } diff --git a/src/Public/Submit-BTNotification.ps1 b/src/Public/Submit-BTNotification.ps1 index 387a30a..a8a05f1 100644 --- a/src/Public/Submit-BTNotification.ps1 +++ b/src/Public/Submit-BTNotification.ps1 @@ -48,6 +48,9 @@ .PARAMETER EventDataVariable If specified, assigns the $Event variable from notification callbacks to this global variable name (e.g., -EventDataVariable MyVar gives $global:MyVar in handlers). Implies ReturnEventData. + .PARAMETER Urgent + If set, designates the toast as an "Important Notification" (scenario 'urgent') which can break through Focus Assist, ensuring the notification is delivered even when user focus mode is enabled. + .INPUTS None. You cannot pipe input to this function. @@ -71,6 +74,7 @@ [hashtable] $DataBinding, [datetime] $ExpirationTime, [switch] $SuppressPopup, + [switch] $Urgent, [scriptblock] $ActivatedAction, [scriptblock] $DismissedAction, [scriptblock] $FailedAction, @@ -84,15 +88,23 @@ $ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::new() + $ToastXmlContent = $Content.GetContent() + if (-not $DataBinding) { - $CleanContent = $Content.GetContent() -Replace '{', '' - $CleanContent = $CleanContent.Replace('}', '') - $CleanContent = $CleanContent.Replace('="{', '="') - $CleanContent = $CleanContent.Replace('}" ', '" ') - - $ToastXml.LoadXml($CleanContent) - } else { - $ToastXml.LoadXml($Content.GetContent()) + $ToastXmlContent = $ToastXmlContent -replace '{', '' + $ToastXmlContent = $ToastXmlContent.Replace('}', '') + $ToastXmlContent = $ToastXmlContent.Replace('="{', '="') + $ToastXmlContent = $ToastXmlContent.Replace('}" ', '" ') + } + + $ToastXml.LoadXml($ToastXmlContent) + + if ($Urgent) { + try { + $ToastXml.GetElementsByTagName('toast')[0].SetAttribute('scenario', 'urgent') + } catch { + # We don't actually want to capture these errors, but rather suppress them. + } } $Toast = [Windows.UI.Notifications.ToastNotification]::new($ToastXml) From df032fcfbd482f249be15a8149d358327239016b Mon Sep 17 00:00:00 2001 From: Josh King Date: Sun, 27 Jul 2025 13:38:53 +1200 Subject: [PATCH 2/4] (#265) Add support for setting Button colors --- Help/New-BTButton.md | 23 ++++++++++++++++++++++ Help/Submit-BTNotification.md | 2 ++ Tests/New-BTButton.Tests.ps1 | 9 +++++++++ Tests/Submit-BTNotification.Tests.ps1 | 10 +++++----- src/Public/New-BTButton.ps1 | 28 +++++++++++++++++++++++---- src/Public/Submit-BTNotification.ps1 | 20 +++++++++++++++---- 6 files changed, 79 insertions(+), 13 deletions(-) diff --git a/Help/New-BTButton.md b/Help/New-BTButton.md index efed069..1ab7fac 100644 --- a/Help/New-BTButton.md +++ b/Help/New-BTButton.md @@ -20,6 +20,7 @@ Up to five buttons can be added to a single Toast notification. Buttons may have | `ActivationType`| Microsoft.Toolkit.Uwp.Notifications.ToastActivationType| Defines the activation type that triggers when the button is pressed. Defaults to Protocol. | No | | `ImageUri` | String | Path or URI of an image icon to display next to the button label. | No | | `Id` | String | Specifies an ID associated with another toast control (textbox or selection box). For standard buttons, this aligns the button next to a control; for snooze buttons, associates with a selection box. | No | +| `Color` | String (Green/Red) | If specified as `Green` or `Red`, the button will be visually styled as "Success" (green) or "Critical" (red) where supported. Use for representing positive/primary or destructive actions. | No | ## INPUTS @@ -74,6 +75,28 @@ New-BTButton -Content 'View Picture' -Arguments $pic -ImageUri $pic Button with a picture to the left, launches the image file. +## NOTES + +To visually distinguish action buttons, you can set the `Color` parameter to `Green` or `Red`. This will render these buttons with a "Success" (green) or "Critical" (red) style in systems that support advanced toast button styling (Windows 11+). Useful for marking approve/submit (green) or destructive (red) actions. + +## EXAMPLES + +### Example 6 + +```powershell +New-BTButton -Content 'Approve' -Arguments 'approve' -Color Green +``` + +Creates a "Success" style (green) button intended for positive actions. + +### Example 7 + +```powershell +New-BTButton -Content 'Delete' -Arguments 'delete' -Color Red +``` + +Creates a "Critical" style (red) button for destructive actions. + ## LINKS - [New-BTAction](New-BTAction.md) diff --git a/Help/Submit-BTNotification.md b/Help/Submit-BTNotification.md index aa7cd88..f4ca718 100644 --- a/Help/Submit-BTNotification.md +++ b/Help/Submit-BTNotification.md @@ -9,6 +9,8 @@ Submits a completed toast notification for display. The `Submit-BTNotification` function submits a completed toast notification to the operating system's notification manager for display. This function supports advanced scenarios such as event callbacks for user actions or toast dismissal, sequence numbering to ensure correct update order, unique identification for toast replacement, expiration control, direct Action Center delivery, and designating a notification as "Important" (using the `-Urgent` switch) so that it can break through Focus Assist. +If a button in the toast is created using `New-BTButton` with the `-Color` parameter (`Green` or `Red`), Submit-BTNotification will ensure those buttons are visually styled as "Success" (green) or "Critical" (red) in capable environments. This allows you to clearly indicate primary/positive or destructive actions on the notification. + When a script block is supplied for any of the event actions (`ActivatedAction`, `DismissedAction`, or `FailedAction`), the function ensures that only one registration for a logically identical handler is allowed per notification event type. This is accomplished by normalizing and hashing the script block; the resulting hash uniquely identifies the action for event registration purposes. Attempting to register the same handler multiple times for a given event will not create a duplicate subscription, but instead will produce an informative warning. If the `-ReturnEventData` switch is used and any event action scriptblocks are supplied (`ActivatedAction`, `DismissedAction`, `FailedAction`), diff --git a/Tests/New-BTButton.Tests.ps1 b/Tests/New-BTButton.Tests.ps1 index 142f5f9..710745b 100644 --- a/Tests/New-BTButton.Tests.ps1 +++ b/Tests/New-BTButton.Tests.ps1 @@ -88,3 +88,12 @@ Describe 'New-BTButton' { } } } + +Context 'custom button with color' { + It 'creates a button with green color without throwing' { + { New-BTButton -Content 'Approve' -Arguments 'approve' -Color Green -WhatIf } | Should -Not -Throw + } + It 'creates a button with red color without throwing' { + { New-BTButton -Content 'Delete' -Arguments 'delete' -Color Red -WhatIf } | Should -Not -Throw + } +} diff --git a/Tests/Submit-BTNotification.Tests.ps1 b/Tests/Submit-BTNotification.Tests.ps1 index 3763405..5680211 100644 --- a/Tests/Submit-BTNotification.Tests.ps1 +++ b/Tests/Submit-BTNotification.Tests.ps1 @@ -47,10 +47,10 @@ Describe 'Submit-BTNotification' { $output | Should -Not -Contain "Duplicate or conflicting OnActivated ScriptBlock event detected" } } -Context 'Urgent scenario' { - It 'runs without error with -Urgent' { - $mockContent = [Activator]::CreateInstance([Microsoft.Toolkit.Uwp.Notifications.ToastContent]) - { Submit-BTNotification -Content $mockContent -Urgent -WhatIf } | Should -Not -Throw + Context 'Urgent scenario' { + It 'runs without error with -Urgent' { + $mockContent = [Activator]::CreateInstance([Microsoft.Toolkit.Uwp.Notifications.ToastContent]) + { Submit-BTNotification -Content $mockContent -Urgent -WhatIf } | Should -Not -Throw + } } -} } \ No newline at end of file diff --git a/src/Public/New-BTButton.ps1 b/src/Public/New-BTButton.ps1 index 53b0b68..bfca87a 100644 --- a/src/Public/New-BTButton.ps1 +++ b/src/Public/New-BTButton.ps1 @@ -1,11 +1,13 @@ function New-BTButton { <# .SYNOPSIS - Creates a new clickable button for a Toast Notification. + Creates a new clickable button for a Toast Notification, with optional color styling. .DESCRIPTION The New-BTButton function creates a new button for a Toast Notification. Up to five buttons can be added to a single Toast notification. - Buttons may have display text, an icon, an optional activation type, argument string, or serve as system managed Dismiss/Snooze buttons. + Buttons may have display text, an icon, an optional activation type, argument string, serve as system managed Dismiss/Snooze buttons, and may optionally be rendered with colored button styles by specifying -Color. + + If -Color is set to 'Green' or 'Red', the button will be displayed with a "Success" (green) or "Critical" (red) style in supported environments. .PARAMETER Snooze Switch. Creates a system-handled snooze button. When paired with a selection box on the toast, the snooze time is customizable. @@ -28,6 +30,9 @@ .PARAMETER Id String. Specifies an ID associated with another toast control (textbox or selection box). For standard buttons, this aligns the button next to a control, for snooze buttons it associates with a selection box. + .PARAMETER Color + String. Optional. If specified as 'Green' or 'Red', the button will be visually styled as "Success" (green) or "Critical" (red) where supported. Use for indicating primary/positive or destructive actions. + .INPUTS None. You cannot pipe input to this function. @@ -57,6 +62,14 @@ New-BTButton -Content 'View Picture' -Arguments $pic -ImageUri $pic Button with a picture to the left, launches the image file. + .EXAMPLE + New-BTButton -Content 'Approve' -Arguments 'approve' -Color 'Green' + Creates a button with a green "Success" style intended for positive actions like approval. + + .EXAMPLE + New-BTButton -Content 'Delete' -Arguments 'delete' -Color 'Red' + Creates a button with a red "Critical" style indicating a destructive action. + .LINK https://github.com/Windos/BurntToast/blob/main/Help/New-BTButton.md #> @@ -97,7 +110,10 @@ [Parameter(ParameterSetName = 'Button')] [Parameter(ParameterSetName = 'Snooze')] [alias('TextBoxId', 'SelectionBoxId')] - [string] $Id + [string] $Id, + + [ValidateSet('Green', 'Red')] + [string] $Color ) switch ($PsCmdlet.ParameterSetName) { @@ -125,7 +141,7 @@ if ($Id) { $Button.SelectionBoxId = $Id } - + if ($ImageUri) { $Button.ImageUri = $ImageUri } @@ -139,6 +155,10 @@ } } + if ($Color) { + $Button = $Button.SetHintActionId($Color) + } + switch ($Button.GetType().Name) { ToastButton { if($PSCmdlet.ShouldProcess("returning: [$($Button.GetType().Name)]:Content=$($Button.Content):Arguments=$($Button.Arguments):ActivationType=$($Button.ActivationType):ImageUri=$($Button.ImageUri):TextBoxId=$($Button.TextBoxId)")) { $Button }} ToastButtonSnooze { if($PSCmdlet.ShouldProcess("returning: [$($Button.GetType().Name)]:CustomContent=$($Button.CustomContent):ImageUri=$($Button.ImageUri):SelectionBoxId=$($Button.SelectionBoxId)")) { $Button } } diff --git a/src/Public/Submit-BTNotification.ps1 b/src/Public/Submit-BTNotification.ps1 index a8a05f1..f321fcd 100644 --- a/src/Public/Submit-BTNotification.ps1 +++ b/src/Public/Submit-BTNotification.ps1 @@ -6,6 +6,9 @@ .DESCRIPTION The Submit-BTNotification function submits a completed toast notification to the operating system's notification manager for display. This function supports advanced scenarios such as event callbacks for user actions or toast dismissal, sequence numbering to ensure correct update order, unique identification for toast replacement, expiration control, and direct Action Center delivery. + Supports colored action buttons: when a button generated via New-BTButton includes the -Color parameter + ('Green' or 'Red'), the notification will style those buttons as "Success" (green) or "Critical" (red) + to visually distinguish positive or destructive actions where supported. When an action ScriptBlock is supplied (Activated, Dismissed, or Failed), a normalized SHA256 hash of its content is used to generate a unique SourceIdentifier for event registration. This prevents duplicate handler registration for the same ScriptBlock, warning if a duplicate registration is attempted. @@ -100,10 +103,19 @@ $ToastXml.LoadXml($ToastXmlContent) if ($Urgent) { - try { - $ToastXml.GetElementsByTagName('toast')[0].SetAttribute('scenario', 'urgent') - } catch { - # We don't actually want to capture these errors, but rather suppress them. + try {$ToastXml.GetElementsByTagName('toast')[0].SetAttribute('scenario', 'urgent')} catch {} + } + + if ($ToastXml.GetXml() -match 'hint-actionId="(Red|Green)"') { + try {$ToastXml.GetElementsByTagName('toast').SetAttribute('useButtonStyle', 'true')} catch {} + + foreach ($ActionElement in $ToastXml.GetElementsByTagName('actions')[0].ChildNodes) { + if ($ActionElement.GetAttribute('hint-actionId') -eq 'Red') { + $ActionElement.SetAttribute('hint-buttonStyle', 'Critical') + } + if ($ActionElement.GetAttribute('hint-actionId') -eq 'Green') { + $ActionElement.SetAttribute('hint-buttonStyle', 'Success') + } } } From 904c89668a51c0262753ed94f725d2eef0e0bf15 Mon Sep 17 00:00:00 2001 From: Josh King Date: Sun, 10 Aug 2025 16:13:46 +1200 Subject: [PATCH 3/4] (#266) Center align text when incomingCall scenario used --- Help/New-BTContent.md | 2 +- src/Public/New-BTContent.ps1 | 1 + src/Public/Submit-BTNotification.ps1 | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Help/New-BTContent.md b/Help/New-BTContent.md index 3b88ffb..a3e0bf0 100644 --- a/Help/New-BTContent.md +++ b/Help/New-BTContent.md @@ -18,7 +18,7 @@ The `New-BTContent` function creates a new `ToastContent` object, the root confi | `Duration` | Microsoft.Toolkit.Uwp.Notifications.ToastDuration| Enum. How long the toast notification is displayed (Short/Long). | No | | `Header` | Microsoft.Toolkit.Uwp.Notifications.ToastHeader | ToastHeader object, created via `New-BTHeader`, categorizing the toast in Action Center. | No | | `Launch` | String | Data passed to the activation context when a toast is clicked. | No | -| `Scenario` | Microsoft.Toolkit.Uwp.Notifications.ToastScenario| Enum. Tells Windows to treat the toast as an alarm, reminder, or more (`ToastScenario`). Will be ignored if toast is submitted with `-Urgent` switch on the Submit-BTNotification function, as the Urgent scenario takes precedence but cannot be set via this parameter. | No | +| `Scenario` | Microsoft.Toolkit.Uwp.Notifications.ToastScenario| Enum. Tells Windows to treat the toast as an alarm, reminder, or more (`ToastScenario`). If the `IncomingCall` scenario is used, any main body text (no longer than a single line) will be center aligned. Will be ignored if toast is submitted with `-Urgent` switch on the `Submit-BTNotification` function, as the Urgent scenario takes precedence but cannot be set via this parameter. | No | | `Visual` | Microsoft.Toolkit.Uwp.Notifications.ToastVisual | **Required.** ToastVisual object, created by `New-BTVisual`, representing the core content of the toast. | Yes | | `ToastPeople` | Microsoft.Toolkit.Uwp.Notifications.ToastPeople | ToastPeople object, representing recipient/persons (optional, used for group chat/etc). | No | | `CustomTimestamp`| DateTime | Optional timestamp for when the toast is considered created (affects Action Center sort order). | No | diff --git a/src/Public/New-BTContent.ps1 b/src/Public/New-BTContent.ps1 index 5642f85..5302c74 100644 --- a/src/Public/New-BTContent.ps1 +++ b/src/Public/New-BTContent.ps1 @@ -26,6 +26,7 @@ .PARAMETER Scenario Enum. Tells Windows to treat the toast as an alarm, reminder, or more (ToastScenario). + If the IncomingCall scenario is selected then any main body text on the toast notification, that is no longer than a single line in length, will be center aligned. Will be ignored if toast is submitted with `-Urgent` switch on the Submit-BTNotification function, as the Urgent scenario takes precedence but cannot be set via this parameter. .PARAMETER Visual diff --git a/src/Public/Submit-BTNotification.ps1 b/src/Public/Submit-BTNotification.ps1 index f321fcd..b47d616 100644 --- a/src/Public/Submit-BTNotification.ps1 +++ b/src/Public/Submit-BTNotification.ps1 @@ -106,6 +106,14 @@ try {$ToastXml.GetElementsByTagName('toast')[0].SetAttribute('scenario', 'urgent')} catch {} } + if ($ToastXml.GetElementsByTagName('toast')[0].GetAttribute('scenario') -eq 'incomingCall') { + foreach ($BindingElement in $ToastXml.GetElementsByTagName('binding')[0].ChildNodes) { + if ($BindingElement.TagName -eq 'text') { + $BindingElement.SetAttribute('hint-callScenarioCenterAlign', 'true') + } + } + } + if ($ToastXml.GetXml() -match 'hint-actionId="(Red|Green)"') { try {$ToastXml.GetElementsByTagName('toast').SetAttribute('useButtonStyle', 'true')} catch {} From 7c391953c175833dce56260f5dbf70efc9673a03 Mon Sep 17 00:00:00 2001 From: Josh King Date: Sun, 10 Aug 2025 16:22:27 +1200 Subject: [PATCH 4/4] (maint) Prep for v1.1.0 --- CHANGES.md | 10 ++++++++++ README.md | 10 ++++++++++ src/BurntToast.psd1 | 11 +++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 14ca2ce..2bae6c0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,15 @@ # Full Change Log +- [v1.1.0](https://github.com/Windos/BurntToast/releases/download/v1.1.0/BurntToast.zip) + + - Features and Improvements + + - Add support for Important Notifications using the Urgent switch. + + - Add support for setting button colors. + + - Center align notification body text when using the IncomingCall scenario. + - [v1.0.1](https://github.com/Windos/BurntToast/releases/download/v1.0.1/BurntToast.zip) - Bug Fixes diff --git a/README.md b/README.md index 9050638..870bea5 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,16 @@ See the [Chocolatey community package](https://chocolatey.org/packages/burnttoas ## Releases +### [v1.1.0](https://github.com/Windos/BurntToast/releases/download/v1.1.0/BurntToast.zip) + +#### Features and Improvements + +- Add support for Important Notifications using the Urgent switch. + +- Add support for setting button colors. + +- Center align notification body text when using the IncomingCall scenario. + ### [v1.0.1](https://github.com/Windos/BurntToast/releases/download/v1.0.1/BurntToast.zip) #### Bug Fixes diff --git a/src/BurntToast.psd1 b/src/BurntToast.psd1 index 4a4bca0..28623d2 100644 --- a/src/BurntToast.psd1 +++ b/src/BurntToast.psd1 @@ -1,6 +1,6 @@ @{ RootModule = 'BurntToast.psm1' - ModuleVersion = '1.0.1' + ModuleVersion = '1.1.0' # Can only use CompatiblePSEditions if PowerShellVersion is set to 5.1, not sure about limiting this to that version yet. # CompatiblePSEditions = @('Desktop') GUID = '751a2aeb-a68f-422e-a2ea-376bdd81612a' @@ -38,7 +38,14 @@ LicenseUri = 'https://github.com/Windos/BurntToast/blob/main/LICENSE' ProjectUri = 'https://github.com/Windos/BurntToast' IconUri = 'https://rawcdn.githack.com/Windos/BurntToast/3dd8dd7457552056da4bbd27880f8283e1116395/Media/BurntToast-Logo.png' - ReleaseNotes = '# 1.0.1 + ReleaseNotes = '# 1.1.0 + +* Features and Improvements + * Add support for Important Notifications using the Urgent switch. + * Add support for setting button colors. + * Center align notification body text when using the IncomingCall scenario. + +# 1.0.1 * Bug Fixes * OnActivated events are "sticky"