diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fe58f4e..9e1a73f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,75 +4,83 @@ on: push: branches: - main + - 'v[0-9]+.[0-9]+.[0-9]+' pull_request: branches: - main + - 'v[0-9]+.[0-9]+.[0-9]+' jobs: Win2019-x64-pwsh: name: Server 2019 - PowerShell - x64 runs-on: windows-2019 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Perform a Pester test from the command-line shell: pwsh - run: ./Tasks/build.ps1 -Bootstrap -Test + run: ./tasks/build.ps1 -Test Win2019-x86-pwsh: name: Server 2019 - PowerShell - x86 runs-on: windows-2019 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Perform a Pester test from the command-line shell: pwsh run: | $Pwsh32 = .github/workflows/pwsh32.ps1 - & $Pwsh32 -File ./Tasks/build.ps1 -Bootstrap -Test + & $Pwsh32 -File ./tasks/build.ps1 -Test Win2019-x64-winpwsh: name: Server 2019 - Windows PowerShell - x64 runs-on: windows-2019 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Perform a Pester test from the command-line shell: powershell - run: ./Tasks/build.ps1 -Bootstrap -Test + run: ./tasks/build.ps1 -Test Win2019-x86-winpwsh: name: Server 2019 - Windows PowerShell - x86 runs-on: windows-2019 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Perform a Pester test from the command-line shell: powershell # TODO: This could be problematic with hardcoding - run: C:\Windows\syswow64\WindowsPowerShell\v1.0\powershell.exe -File ./Tasks/build.ps1 -Bootstrap -Test + run: C:\Windows\syswow64\WindowsPowerShell\v1.0\powershell.exe -File ./tasks/build.ps1 -Test build-and-oat-module: name: Build Module and OAT needs: ["Win2019-x64-pwsh", "Win2019-x64-winpwsh", "Win2019-x86-pwsh", "Win2019-x86-winpwsh"] runs-on: windows-2019 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Test Coverage + shell: pwsh + run: | + ./tasks/build.ps1 -Test - name: Compile Module shell: pwsh - run: ./Tasks/build.ps1 -Bootstrap -Compile + run: ./tasks/build.ps1 -Compile - name: OAT shell: pwsh env: # Use the compiled module for testing BURNTTOAST_MODULE_ROOT: './Output/BurntToast/BurntToast.psd1' run: | - ./Tasks/build.ps1 -Test -CodeCoverage + ./tasks/build.ps1 -Test - name: Upload Test Results if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: test-results path: "*.xml" - name: Upload PowerShell Module if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: burnttoast-module path: "./Output/BurntToast/" @@ -83,17 +91,18 @@ jobs: runs-on: ubuntu-latest if: always() steps: + - uses: actions/checkout@v3 - name: Download Artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: test-results path: artifacts - name: Publish Unit Test Results - uses: EnricoMi/publish-unit-test-result-action@v1 + uses: EnricoMi/publish-unit-test-result-action@v2 with: files: artifacts/**/TestResults.xml - - uses: codecov/codecov-action@v2 - if: always() + - name: Publish Code Coverage Results to Codecov + uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} - files: artifacts/CoverageResults.xml + files: artifacts/CoverageResults.xml \ No newline at end of file diff --git a/Azure-Pipelines/release.ps1 b/Azure-Pipelines/release.ps1 deleted file mode 100644 index 50743aa..0000000 --- a/Azure-Pipelines/release.ps1 +++ /dev/null @@ -1,79 +0,0 @@ -[CmdletBinding()] -param( - [switch] - $Bootstrap, - - [switch] - $DefineTag, - - [switch] - $Publish, - - [switch] - $Announce -) - -# Bootstrap step -if ($Bootstrap.IsPresent) { - Write-Information "Validate and install missing prerequisits for building ..." - - # For tweeting - if (-not (Get-Module -Name PSTwitterAPI -ListAvailable)) { - Write-Warning "Module 'PSTwitterAPI' is missing. Installing 'PSTwitterAPI' ..." - Install-Module -Name PSTwitterAPI -Scope CurrentUser -Force - } -} - -# Define Tag step -if ($DefineTag.IsPresent) { - $ReleaseVersion = Get-Content -Path $env:ArtifactDir\PipelinesScripts\release-version.txt - Write-Host "##vso[task.setvariable variable=RELEASETAG]$ReleaseVersion" -} - -# Publish step -if ($Publish.IsPresent) { - # Publish Module to PowerShell Gallery - Try { - $Splat = @{ - Path = (Resolve-Path -Path $env:ArtifactDir\BurntToast) - NuGetApiKey = $env:PSGallery - ErrorAction = 'Stop' - } - Publish-Module @Splat - - Write-Output -InputObject ('BurntToast PowerShell Module published to the PowerShell Gallery') - } Catch { - throw $_ - } -} - -# Announce step -if($Announce.IsPresent) { - if (-not (Get-Module -Name PSTwitterAPI -ListAvailable)) { - throw "Cannot find the 'PSTwitterAPI' module. Please specify '-Bootstrap' to install release dependencies." - } - - Import-Module -Name PSTwitterAPI - - $OAuthSettings = @{ - ApiKey = $env:TwitterConsumerKey - ApiSecret = $env:TwitterConsumerSecret - AccessToken = $env:TwitterAccessToken - AccessTokenSecret = $env:TwitterAccessSecret - } - - Set-TwitterOAuthSettings @OAuthSettings - - $ReleaseVersion = Get-Content -Path $env:ArtifactDir\PipelinesScripts\release-version.txt - - $Tweets = @("I just pushed BurntToast v$ReleaseVersion to the #PowerShell Gallery via @AzureDevOps!$([System.Environment]::NewLine)$([System.Environment]::NewLine)$env:ReleaseMessage$([System.Environment]::NewLine)$([System.Environment]::NewLine)https://www.powershellgallery.com/packages/BurntToast/$ReleaseVersion", - "You can also find this release over on @GitHub.$([System.Environment]::NewLine)$([System.Environment]::NewLine)Please do fire through any issue, feature requests, or submit some additional code!$([System.Environment]::NewLine)$([System.Environment]::NewLine)https://github.com/Windos/BurntToast/releases/tag/v$ReleaseVersion") - - foreach ($Tweet in $Tweets) { - if ($PrevTweet) { - $PrevTweet = Send-TwitterStatuses_Update -in_reply_to_status_id $PrevTweet.id.ToString() -status $Tweet - } else { - $PrevTweet = Send-TwitterStatuses_Update -status $Tweet - } - } -} \ No newline at end of file diff --git a/BurntToast/BurntToast.psd1 b/BurntToast/BurntToast.psd1 deleted file mode 100644 index ee5fe3a..0000000 --- a/BurntToast/BurntToast.psd1 +++ /dev/null @@ -1,86 +0,0 @@ -@{ - RootModule = 'BurntToast.psm1' - ModuleVersion = '0.8.5' - # 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' - Author = 'Joshua (Windos) King' - CompanyName = 'king.geek.nz' - Copyright = '(c) 2015 Joshua (Windos) King. All rights reserved.' - Description = 'Module for creating and displaying Toast Notifications on Microsoft Windows 10.' - PowerShellVersion = '5.0' - FunctionsToExport = 'Get-BTHeader', - 'Get-BTHistory', - 'New-BTAction', - 'New-BTAppId', - 'New-BTAudio', - 'New-BTBinding', - 'New-BTButton', - 'New-BTColumn', - 'New-BTContent', - 'New-BTContextMenuItem', - 'New-BTHeader', - 'New-BTImage', - 'New-BTInput', - 'New-BTProgressBar', - 'New-BTSelectionBoxItem', - 'New-BTShoulderTapBinding', - 'New-BTShoulderTapImage', - 'New-BTShoulderTapPeople', - 'New-BTText', - 'New-BTVisual', - 'New-BurntToastShoulderTap', - 'New-BurntToastNotification', - 'Remove-BTNotification', - 'Submit-BTNotification', - 'Update-BTNotification' - CmdletsToExport = @() - AliasesToExport = @('ShoulderTap', - 'Toast') - PrivateData = @{ - PSData = @{ - Tags = @('Notifications', 'Utilities', 'Windows10', 'Toast') - LicenseUri = 'https://github.com/Windos/BurntToast/blob/main/LICENSE' - ProjectUri = 'https://github.com/Windos/BurntToast' - IconUri = 'https://raw.githubusercontent.com/Windos/BurntToast/main/Media/BurntToast-Logo.png' - ReleaseNotes = '# 0.8.5 - -* Actually implement the ability to use a UniqueIdentifier with the Remove-BTNotification function (which was half implemented in 0.8.4) - -# 0.8.4 - -* Enhancement: Header ID on New-BTHeader is now optional. An ID will be auto generated if not specified (#125) - * Thanks [@glennsarti](https://github.com/glennsarti) -* Enhancement: Hero images can now be specified using the New-BurntToastNotification function using the -HeroImage parameter (#80) - * Thanks [@UniverseCitiz3n](https://github.com/UniverseCitiz3n) -* Enhancement: AppIDs can now be specified using the New-BurntToastNotification function using the -AppId parameter. - * Thanks [@cedarbaum](https://github.com/cedarbaum) -* Enhancement: You can now specify a UniqueIdentifier when using the Remove-BTNotification function rather than component Tag and Group strings. -* Fix: Weird edge cases when taking text from Twitch/IRC and using them in a toast is now sorted. - * Thanks [@potatoqualitee](https://github.com/potatoqualitee) and [@vexx32](https://github.com/vexx32) - -# 0.8.3 - -* Fix: Error when running Update-BTNotification on PowerShell 6.0+ (#120) -* Fix: Error when using actionable toast parameters on any version (#122) -* Fix: Multiple warnings about events not being supported when specifying multiple event types. - -# 0.8.2 - -* Add: AdaptiveGroups are now usable via New-BTColumn - -# 0.8.1 - -* Fix: Toast alias removed in 0.8.0 has been restored -* Deprecation: Signalling removal of Shoulder Tap cmdlets in future version, v0.9.0 -* Deprecation: Signalling removal of Path parameter from New-BTAudio in future version, v0.9.0. https://github.com/MicrosoftDocs/windows-uwp/issues/1593 - -# 0.8.0 - -* Fix: Images from UNC path failing (#111) -* Add: Ability to force a refresh of cached images via IgnoreCache switch on New-BTImage -* Add: ACTIONABLE NOTIFICATIONS! Exposed via ActivatedAction and DismissedAction parameters on Submit-BTNotification and New-BurntToastNotification -' - } - } -} diff --git a/BurntToast/BurntToast.psm1 b/BurntToast/BurntToast.psm1 deleted file mode 100644 index 5a6f7f1..0000000 --- a/BurntToast/BurntToast.psm1 +++ /dev/null @@ -1,59 +0,0 @@ -$WinMajorVersion = (Get-CimInstance -ClassName Win32_OperatingSystem -Property Version).Version.Split('.')[0] - -if ($WinMajorVersion -ge 10) { - $Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue ) - $Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue ) - $Library = @( Get-ChildItem -Path $PSScriptRoot\lib\Microsoft.Toolkit.Uwp.Notifications\*.dll -Recurse -ErrorAction SilentlyContinue ) - - if ($IsWindows) { - $Library += @( Get-ChildItem -Path $PSScriptRoot\lib\Microsoft.Windows.SDK.NET\*.dll -Recurse -ErrorAction SilentlyContinue ) - } - - # Add one class from each expected DLL here: - $LibraryMap = @{ - 'Microsoft.Toolkit.Uwp.Notifications.dll' = 'Microsoft.Toolkit.Uwp.Notifications.ToastContent' - } - - $Script:Config = Get-Content -Path $PSScriptRoot\config.json -ErrorAction SilentlyContinue | ConvertFrom-Json - $Script:DefaultImage = if ($Script:Config.AppLogo -match '^[.\\]') { - "$PSScriptRoot$($Script:Config.AppLogo)" - } else { - $Script:Config.AppLogo - } - - foreach ($Import in @($Public + $Private)) { - try { - . $Import.FullName - } catch { - Write-Error -Message "Failed to import function $($Import.FullName): $_" - } - } - - foreach ($Type in $Library) { - try { - if (-not ($LibraryMap[$Type.Name] -as [type])) { - Add-Type -Path $Type.FullName -ErrorAction Stop - } - } catch { - Write-Error -Message "Failed to load library $($Type.FullName): $_" - } - } - - $Script:ActionsSupported = 'System.Management.Automation.SemanticVersion' -as [type] -and - $PSVersionTable.PSVersion -ge [System.Management.Automation.SemanticVersion] '7.1.0-preview.4' - - $Script:UnsupportedEvents = 'Toast events are only supported on PowerShell 7.1.0 and above. ' + - 'Your notification will still be displayed, but the actions will be ignored.' - - Export-ModuleMember -Alias 'Toast' - Export-ModuleMember -Function $Public.BaseName - - # Register default AppId - New-BTAppId - - if (-not $IsWindows) { - $null = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] - } -} else { - throw 'This version of BurntToast will only work on Windows 10. If you would like to use BurntToast on Windows 8, please use version 0.4' -} diff --git a/BurntToast/Private/Test-BTAudioPath.ps1 b/BurntToast/Private/Test-BTAudioPath.ps1 deleted file mode 100644 index 08ef81e..0000000 --- a/BurntToast/Private/Test-BTAudioPath.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -function Test-BTAudioPath { - param ( - [Parameter(Mandatory)] - [String] $Path - ) - - $Extension = [IO.Path]::GetExtension($Path) - - $ValidExtensions = @( - '.aac' - '.flac' - '.m4a' - '.mp3' - '.wav' - '.wma' - ) - - if ($Extension -in $ValidExtensions) { - if (Test-Path -Path $Path) { - $true - } else { - throw "The file '$Path' doesn't exist in the specified location. Please provide a valid path and try again." - } - } else { - throw "The file extension '$Extension' is not supported. Please provide a valid path and try again." - } -} diff --git a/BurntToast/Public/New-BTAppId.ps1 b/BurntToast/Public/New-BTAppId.ps1 deleted file mode 100644 index 238021e..0000000 --- a/BurntToast/Public/New-BTAppId.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -function New-BTAppId { - <# - .SYNOPSIS - Creates a new AppId Registry Key. - - .DESCRIPTION - The New-BTAppId function create a new AppId registry key in the Current User's Registery Hive. If the desired AppId is already present in the Registry then no changes are made. - - If no AppId is specified then the AppId specified in the config.json file in the BurntToast module's root directory is used. - - .INPUTS - System.String - - You cannot pipe input to this cmdlet. - - .OUTPUTS - None - - .EXAMPLE - New-BTAppId - - This command creates an AppId registry key using the value specified in the BurntToast module's config.json file, which is 'BurntToast' by default. - - .EXAMPLE - New-BTAppId -AppId 'Script Checker' - - This command create an AppId registry key called 'Script Checker.' - - .LINK - https://github.com/Windos/BurntToast/blob/main/Help/New-BTAppId.md - #> - - [CmdletBinding(SupportsShouldProcess = $true, - HelpUri = 'https://github.com/Windos/BurntToast/blob/main/Help/New-BTAppId.md')] - param ( - # Specifies the new AppId. You can use any alphanumeric characters. - # - # Defaults to the AppId specified in the config.json file in the BurntToast module's root directoy if not provided. - [ValidateNotNullOrEmpty()] - [string] $AppId = $Script:Config.AppId - ) - - $RegPath = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings' - - if (!(Test-Path -Path "$RegPath\$AppId")) { - if($PSCmdlet.ShouldProcess("creating: '$RegPath\$AppId' with property 'ShowInActionCenter' set to '1' (DWORD)")) { - $null = New-Item -Path "$RegPath\$AppId" -Force - $null = New-ItemProperty -Path "$RegPath\$AppId" -Name 'ShowInActionCenter' -Value 1 -PropertyType 'DWORD' - } - } else { - Write-Verbose -Message 'Specified AppId is already present in the registry.' - } -} diff --git a/BurntToast/Public/New-BTShoulderTapBinding.ps1 b/BurntToast/Public/New-BTShoulderTapBinding.ps1 deleted file mode 100644 index bfa5ae3..0000000 --- a/BurntToast/Public/New-BTShoulderTapBinding.ps1 +++ /dev/null @@ -1,57 +0,0 @@ -function New-BTShoulderTapBinding { - <# - .SYNOPSIS - Creates a new Shoulder Tap Binding object. - - .DESCRIPTION - The New-BTShoulderTapBinding function creates a new Shoulder Tap Binding Object, with which you can specify the Image to be displayed. - - .INPUTS - LOTS... - - .OUTPUTS - ToastBindingShoulderTap - - .EXAMPLE - $Image = New-BTShoulderTapImage -Source 'https://www.route66sodas.com/wp-content/uploads/2019/01/Alert.gif' - New-BTShoulderTapBinding -Image $Image - - .LINK - https://github.com/Windos/BurntToast/blob/main/Help/New-BTShoulderTapBinding.md - #> - [CmdletBinding(HelpUri = 'https://github.com/Windos/BurntToast/blob/main/Help/New-BTShoulderTapBinding.md')] - [Obsolete('This cmdlet is being deprecated, it will be removed in v0.9.0')] - [OutputType([Microsoft.Toolkit.Uwp.Notifications.ToastBindingShoulderTap])] - param ( - # The image displayed in the Shoulder Tap notification, this object is created using the New-BTShoulderTapImage function. - [Parameter(Mandatory)] - [Microsoft.Toolkit.Uwp.Notifications.ToastShoulderTapImage] $Image, - - # Set to "true" to allow Windows to append a query string to the image URI supplied in the Toast notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language. - [switch] $AddImageQuery, - - # A default base URI that is combined with relative URIs in image source attributes. - [uri] $BaseUri, - - # The target locale of the XML payload, specified as BCP-47 language tags such as "en-US" or "fr-FR". This locale is overridden by any locale specified in binding or text. If this value is a literal string, this attribute defaults to the user's UI language. If this value is a string reference, this attribute defaults to the locale chosen by Windows Runtime in resolving the string. - [string] $Language - ) - - $Binding = [Microsoft.Toolkit.Uwp.Notifications.ToastBindingShoulderTap]::new() - - $Binding.Image = $Image - - if ($AddImageQuery.IsPresent) { - $Binding.AddImageQuery = $true - } - - if ($BaseUri) { - $Binding.BaseUri = $BaseUri - } - - if ($Language) { - $Binding.Language = $Language - } - - $Binding -} diff --git a/BurntToast/Public/New-BTShoulderTapImage.ps1 b/BurntToast/Public/New-BTShoulderTapImage.ps1 deleted file mode 100644 index 9a9eb76..0000000 --- a/BurntToast/Public/New-BTShoulderTapImage.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -function New-BTShoulderTapImage { - <# - .SYNOPSIS - Creates a new ToastShoulderTapImage object. - - .DESCRIPTION - The New-BTShoulderTapImage function creates a new ToastShoulderTapImage object. - - The image can be a static image or anitmated gif, specified using the Source parameter. It can also be a spritesheet. - - This function is mainly used internally, as it is abstracted away when using New-BurntToastShoulderTap. - - .INPUTS - LOTS - - .OUTPUTS - ToastShoulderTapImage - - .EXAMPLE - $Image = New-BTShoulderTapImage -Source 'https://www.route66sodas.com/wp-content/uploads/2019/01/Alert.gif' - - .LINK - https://github.com/Windos/BurntToast/blob/main/Help/New-BTShoulderTapImage.md - #> - - [Obsolete('This cmdlet is being deprecated, it will be removed in v0.9.0')] - [CmdletBinding(DefaultParameterSetName = 'Image', - HelpUri = 'https://github.com/Windos/BurntToast/blob/main/Help/New-BTShoulderTapImage.md')] - [OutputType([Microsoft.Toolkit.Uwp.Notifications.ToastShoulderTapImage])] - - param ( - [Parameter(ParameterSetName = 'Image', - Mandatory)] - [string] $Source, - - [Parameter(ParameterSetName = 'Sprite', - Mandatory)] - [string] $SpriteSheet, - - [Parameter(ParameterSetName = 'Sprite', - Mandatory)] - [uint32] $FrameHeight, - - [Parameter(ParameterSetName = 'Sprite', - Mandatory)] - [uint32] $FPS, - - [Parameter(ParameterSetName = 'Sprite')] - [uint32] $StartingFrame, - - [string] $AlternateText, - - [switch] $AddImageQuery - ) - - $ShoulderTapImage = [Microsoft.Toolkit.Uwp.Notifications.ToastShoulderTapImage]::new() - - if ($PSCmdlet.ParameterSetName -eq 'Sprite') { - $Sprite = [Microsoft.Toolkit.Uwp.Notifications.ToastSpriteSheet]::new() - - $Sprite.Source = Optimize-BTImageSource -Source $SpriteSheet - $Sprite.FrameHeight = $FrameHeight - $Sprite.Fps = $FPS - - if ($StartingFrame) { - $Sprite.StartingFrame = $StartingFrame - } - - $ShoulderTapImage.SpriteSheet = $Sprite - } else { - $ShoulderTapImage.Source = Optimize-BTImageSource -Source $Source - } - - if ($AddImageQuery.IsPresent) { - $ShoulderTapImage.AddImageQuery = $true - } - - if ($AlternateText) { - $ShoulderTapImage.AlternateText = $AlternateText - } - - $ShoulderTapImage -} diff --git a/BurntToast/Public/New-BTShoulderTapPeople.ps1 b/BurntToast/Public/New-BTShoulderTapPeople.ps1 deleted file mode 100644 index 9d46f8b..0000000 --- a/BurntToast/Public/New-BTShoulderTapPeople.ps1 +++ /dev/null @@ -1,55 +0,0 @@ -function New-BTShoulderTapPeople { - <# - .SYNOPSIS - Creates a new ToastPeople object. - - .DESCRIPTION - The New-BTShoulderTapPeople function creates a new ToastPeople object. This object identifies a user from the People app which has been pinned to the Windows Taskbar. - - This function is mainly used internally, as it is abstracted away when using New-BurntToastShoulderTap. - - .INPUTS - STRING - - .OUTPUTS - ToastPeople - - .EXAMPLE - $Person = New-BTShoulderTapPeople -Email 'bob@example.com' - - .LINK - https://github.com/Windos/BurntToast/blob/main/Help/New-BTShoulderTapPeople.md - #> - - [Obsolete('This cmdlet is being deprecated, it will be removed in v0.9.0')] - [CmdletBinding(DefaultParameterSetName = 'Email', - HelpUri = 'https://github.com/Windos/BurntToast/blob/main/Help/New-BTShoulderTapPeople.md')] - [OutputType([Microsoft.Toolkit.Uwp.Notifications.ToastPeople])] - - param ( - # The email address which matches a contact in the Contacts app. - [Parameter(ParameterSetName = 'Email', - Mandatory)] - [string] $Email, - - # The remote identifier which matches a contact in the Contacts app. - [Parameter(ParameterSetName = 'RemoteId', - Mandatory)] - [string] $RemoteId, - - # The phone number which matches a contact in the Contacts app. - [Parameter(ParameterSetName = 'PhoneNumber', - Mandatory)] - [string] $PhoneNumber - ) - - $ToastPeople = [Microsoft.Toolkit.Uwp.Notifications.ToastPeople]::new() - - switch ($PSCmdlet.ParameterSetName) { - Email {$ToastPeople.EmailAddress = $Email} - RemoteId {$ToastPeople.RemoteId = $RemoteId} - PhoneNumber {$ToastPeople.PhoneNumber = $PhoneNumber} - } - - $ToastPeople -} diff --git a/BurntToast/Public/New-BurntToastShoulderTap.ps1 b/BurntToast/Public/New-BurntToastShoulderTap.ps1 deleted file mode 100644 index f472241..0000000 --- a/BurntToast/Public/New-BurntToastShoulderTap.ps1 +++ /dev/null @@ -1,154 +0,0 @@ -function New-BurntToastShoulderTap { - <# - .SYNOPSIS - Creates and displays a Shoulder Tap notification. - - .DESCRIPTION - The New-BurntToastShoulderTap function creates and displays a Shoulder Tap notification on Microsoft Windows 10. - - You can provide a static image or animated GIF, which will be displayed above the specified pinned contact. - - You must first pin a contact to the Taskbar using the Windows 10 People app. Next, you can refer to the contact **by its e-mail address** to display a notification. - - If a matching contact cannot be found, Windows will fall back to a toast notification. This toast notification will also been seen in the Action Center (with or without a working Shoulder Tap.) - - You can optionally call the New-BurntToastShoulderTap function with the ShoulderTap alias. - - .INPUTS - LOTS... - - .OUTPUTS - None - New-BurntToastShoulderTap displays the Shoulder Tap that is created. - - .EXAMPLE - $Image = 'https://i.imgur.com/WKiNp5o.gif' - $Contact = 'stormy@example.com' - $Text = 'First Shoulder Tap', 'This is for the fallback toast.' - - New-BurntToastShoulderTap -Image $Image -Person $Contact -Text $Text - - .NOTES - There's some manual steps required to create and pin a contact which matches the specified email address in the Person parameter. - - There will be a blog post about this on https://toastit.dev, and also further documented within this module in the next release. - - .LINK - https://github.com/Windos/BurntToast/blob/main/Help/New-BurntToastShoulderTap.md - #> - - [Obsolete('This cmdlet is being deprecated, it will be removed in v0.9.0')] - [Alias('ShoulderTap')] - [CmdletBinding(SupportsShouldProcess = $true, - HelpUri = 'https://github.com/Windos/BurntToast/blob/main/Help/New-BurntToastShoulderTap.md')] - param ( - # The URI of the image. Can be a static image or animated GIF. - [Parameter(Mandatory)] - [string] $Image, - - # The email address of the "person" from which the Shoulder Tap is coming from. - # - # A contact with a matching email address must be pinned to the task bar. - [Parameter(Mandatory)] - [string] $Person, - - # 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. - # - # The toast version will be shown on screen if the required contact is not pinned to the task bar, and will also appear in the Action Center. - [ValidateCount(0, 3)] - [string[]] $Text = 'Default Notification', - - # Specifies the path to an image that will override the default image displayed with a Toast Notification. - [string] $AppLogo, - - # 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. - [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. - [Microsoft.Toolkit.Uwp.Notifications.ToastHeader] $Header, - - # Specify one or more Progress Bar object created using the New-BTProgressBar function. - [Microsoft.Toolkit.Uwp.Notifications.AdaptiveProgressBar[]] $ProgressBar, - - # A string that uniquely identifies a toast notification. Submitting a new toast with the same identifier as a previous toast will replace the previous toast. - # - # This is useful when updating the progress of a process, using a progress bar, or otherwise correcting/updating the information on a toast. - [string] $UniqueIdentifier, - - # The time after which the notification is no longer relevant and should be removed from the People notification and Action Center. - [datetime] $ExpirationTime, - - # Bypasses display to the screen and sends the notification directly to the Action Center. - [switch] $SuppressPopup, - - # Sets the time at which Windows should consider the notification to have been created. If not specified the time at which the notification was recieved will be used. - # - # The time stamp affects sorting of notifications in the Action Center. - [datetime] $CustomTimestamp, - - # Specifies the AppId of the 'application' or process that spawned the toast notification. - # - # Defaults to the People App, rather than the configured default. - [string] $AppId = 'Microsoft.People_8wekyb3d8bbwe!x4c7a3b7dy2188y46d4ya362y19ac5a5805e5x' - ) - - $ChildObjects = @() - - foreach ($Txt in $Text) { - $ChildObjects += New-BTText -Text $Txt -WhatIf:$false - } - - if ($ProgressBar) { - foreach ($Bar in $ProgressBar) { - $ChildObjects += $Bar - } - } - - if ($AppLogo) { - $AppLogoImage = New-BTImage -Source $AppLogo -AppLogoOverride -Crop Circle -WhatIf:$false - } else { - $AppLogoImage = New-BTImage -AppLogoOverride -Crop Circle -WhatIf:$false - } - - $Binding = New-BTBinding -Children $ChildObjects -AppLogoOverride $AppLogoImage -WhatIf:$false - - $ShoulderTapBinding = New-BTShoulderTapBinding -Image (New-BTShoulderTapImage -Source $Image) - - $Visual = New-BTVisual -BindingGeneric $Binding -BindingShoulderTap $ShoulderTapBinding -WhatIf:$false - - $ContentSplat = @{ - 'Visual' = $Visual - 'ToastPeople' = (New-BTShoulderTapPeople -Email $Person) - } - - if ($Header) { - $ContentSplat.Add('Header', $Header) - } - - if ($CustomTimestamp) { - $ContentSplat.Add('CustomTimestamp', $CustomTimestamp) - } - - $Content = New-BTContent @ContentSplat -WhatIf:$false - - $ToastSplat = @{ - Content = $Content - AppId = $AppId - } - - if ($UniqueIdentifier) { - $ToastSplat.Add('UniqueIdentifier', $UniqueIdentifier) - } - - if ($ExpirationTime) { - $ToastSplat.Add('ExpirationTime', $ExpirationTime) - } - - if ($SuppressPopup.IsPresent) { - $ToastSplat.Add('SuppressPopup', $true) - } - - if($PSCmdlet.ShouldProcess( "submitting: $($Content.GetContent())" )) { - Submit-BTNotification @ToastSplat - } -} diff --git a/BurntToast/config.json b/BurntToast/config.json deleted file mode 100644 index 0835823..0000000 --- a/BurntToast/config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "AppId": "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe", - "AppLogo": "\\Images\\BurntToast.png" -} diff --git a/BurntToast/lib/Microsoft.Toolkit.Uwp.Notifications/README.md b/BurntToast/lib/Microsoft.Toolkit.Uwp.Notifications/README.md deleted file mode 100644 index 3baf9ff..0000000 --- a/BurntToast/lib/Microsoft.Toolkit.Uwp.Notifications/README.md +++ /dev/null @@ -1 +0,0 @@ -Microsoft.Toolkit.Uwp.Notifications.6.0.0\lib\net461 diff --git a/BurntToast/lib/Microsoft.Windows.SDK.NET/README.md b/BurntToast/lib/Microsoft.Windows.SDK.NET/README.md deleted file mode 100644 index ed274b8..0000000 --- a/BurntToast/lib/Microsoft.Windows.SDK.NET/README.md +++ /dev/null @@ -1 +0,0 @@ -Microsoft.Windows.SDK.NET.Ref.10.0.19041.12\lib \ No newline at end of file diff --git a/BurntToast/lib/Microsoft.Windows.SDK.NET/WinRT.Runtime.dll b/BurntToast/lib/Microsoft.Windows.SDK.NET/WinRT.Runtime.dll deleted file mode 100644 index 842eeb7..0000000 Binary files a/BurntToast/lib/Microsoft.Windows.SDK.NET/WinRT.Runtime.dll and /dev/null differ diff --git a/CHANGES.md b/CHANGES.md index 239773a..a692757 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,17 @@ # Full Change Log +- [1.0.0](https://github.com/Windos/BurntToast/releases/download/v1.0.0/BurntToast.zip) + + - Breaking Change: Removed customizable AppId + + - Breaking Change: Shoulder tap notification support has been removed + + - Breaking Change: Custom audio source support has been removed + + - Libraries: Microsoft.Windows.SDK.NET.Ref library bumped to 10.0.22621.28 + + - Libraries: Microsoft.Toolkit.Uwp.Notifications library bumped to 7.1.3 + - [0.8.5](https://github.com/Windos/BurntToast/releases/download/v0.8.5/BurntToast.zip) - Actually implement the ability to use a UniqueIdentifier with the Remove-BTNotification function (which was half implemented in 0.8.4) diff --git a/Examples/Example01/Example01-Default.ps1 b/Examples/Example01/Example01-Default.ps1 deleted file mode 100644 index a841bbd..0000000 --- a/Examples/Example01/Example01-Default.ps1 +++ /dev/null @@ -1 +0,0 @@ -New-BurntToastNotification \ No newline at end of file diff --git a/Examples/Example01/Example1-Default.png b/Examples/Example01/Example1-Default.png deleted file mode 100644 index 5b23393..0000000 Binary files a/Examples/Example01/Example1-Default.png and /dev/null differ diff --git a/Examples/Example02/Example02-Customized.ps1 b/Examples/Example02/Example02-Customized.ps1 deleted file mode 100644 index a576712..0000000 --- a/Examples/Example02/Example02-Customized.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -New-BurntToastNotification -AppLogo C:\smile.jpg -Text "Don't forget to smile!", - 'Your script ran successfully, celebrate!' \ No newline at end of file diff --git a/Examples/Example02/Example2-Custom.png b/Examples/Example02/Example2-Custom.png deleted file mode 100644 index 0a7f365..0000000 Binary files a/Examples/Example02/Example2-Custom.png and /dev/null differ diff --git a/Examples/Example03/Example03-AlarmClock.ps1 b/Examples/Example03/Example03-AlarmClock.ps1 deleted file mode 100644 index 8a3d271..0000000 --- a/Examples/Example03/Example03-AlarmClock.ps1 +++ /dev/null @@ -1 +0,0 @@ -New-BurntToastNotification -Text 'WAKE UP!' -Sound 'Alarm2' -SnoozeAndDismiss \ No newline at end of file diff --git a/Examples/Example03/Example3-Alarm.png b/Examples/Example03/Example3-Alarm.png deleted file mode 100644 index 1824b47..0000000 Binary files a/Examples/Example03/Example3-Alarm.png and /dev/null differ diff --git a/Examples/Example04/EngineEvents.ps1 b/Examples/Example04/EngineEvents.ps1 deleted file mode 100644 index 7a76ec8..0000000 --- a/Examples/Example04/EngineEvents.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -Register-EngineEvent -SourceIdentifier Powershell.Exiting -Action { - - $header = New-BTHeader -Id 1 -Title "Automation Done" - New-BurntToastNotification -Text "Hey there! That script you wrote is finished." -Silent -Header $header - -} \ No newline at end of file diff --git a/Examples/Example05/New-ToastReminder.ps1 b/Examples/Example05/New-ToastReminder.ps1 deleted file mode 100644 index d4f54b8..0000000 --- a/Examples/Example05/New-ToastReminder.ps1 +++ /dev/null @@ -1,119 +0,0 @@ -Function New-ToastReminder { -<# -.SYNOPSIS -Schedules a toast reminder for some point in the future - -.PARAMETER ReminderTitle -The title of the toast when it appears - -.PARAMETER ReminderText -The main text body for the reminder - -.PARAMETER Seconds -The number of seconds to wait before showing the reminder. -This parameter is additive with the -Minutes and -Hours parameters - -.PARAMETER Minutes -The number of minutes to wait before showing the reminder. -This parameter is additive with the -Seconds and -Hours parameters - -.PARAMETER Hours -The number of hours to wait before showing the reminder. -This parameter is additive with the -Seconds and -Minutes parameters - -.PARAMETER AppLogo -The logo to be displayed on the toast notification - -.PARAMETER PassThru -If this parameter is specified, a reference to the event registration will be written to the pipeline -(e.g. to allow the subscription to be cancelled). By default, this cmdlet produces no output - -.EXAMPLE -New-ToastReminder -Hours 1 -Minutes 30 -ReminderTitle "Heads up" -ReminderText "Time to take a break!" -This example sets a reminder for 1h30min from now with the specified title and text - -.NOTES -As this cmdlet functions via an event registration, the PowerShell session that launched it must -remain open for the reminder to trigger. -#> - [CmdletBinding(SupportsShouldProcess = $true)] - Param( - [Parameter(Mandatory, Position = 0)] - [Alias("Title")] - [ValidateNotNullOrEmpty()] - [string] - $ReminderTitle, - - [Parameter(Mandatory, Position = 1)] - [Alias("Text")] - [ValidateNotNullOrEmpty()] - [string] - $ReminderText, - - [Parameter(Position = 2)] - [int] - $Seconds, - - [Parameter(Position = 3)] - [Int] - $Minutes, - - [Parameter(Position = 4)] - [Int] - $Hours, - - [Parameter(Position = 5)] - [string] - $AppLogo, - - [switch] - $Passthru - ) - - Begin {} - - Process { - - $Timer = [System.Timers.Timer]::new() - If ($Hours + $Minutes + $Seconds -eq 0) - { - $IntervalSpan = New-TimeSpan -Seconds 1 - } - Else - { - $IntervalSpan = [timespan]::Zero - $Intervalspan = $IntervalSpan.Add([timespan]::FromHours($Hours)) - $Intervalspan = $IntervalSpan.Add([timespan]::FromMinutes($Minutes)) - $Intervalspan = $IntervalSpan.Add([timespan]::FromSeconds($Seconds)) - } - $Timer.Interval = $IntervalSpan.TotalMilliseconds - $Timer.AutoReset = $false - $Data = [pscustomobject]@{ - Title = $ReminderTitle - Text = $ReminderText - $AppLogo = $AppLogo - } - $ElapsedAction = { - $Data = $event.MessageData - $Header = New-BTHeader -ID 1 -Title $Data.Title - New-BurntToastNotification -Text $Data.Text -Header $Header -AppLogo $Data.$AppLogo -SnoozeAndDismiss - $Event | Unregister-Event - $Timer.Dispose() - } - - $ElapsedObjectEvent = Register-ObjectEvent -InputObject $Timer -EventName "Elapsed" -MaxTriggerCount 1 -Action $ElapsedAction -MessageData $Data - - $Timer.Start() - - if ($Passthru) - { - Write-Output $ElapsedObjectEvent - } - } - - End {} -} - -if($PSCmdlet.ShouldProcess($ReminderTitle)) { - New-ToastReminder -Minutes 30 -ReminderTitle 'Hey you' -ReminderText 'The coffee is brewed' -} diff --git a/Examples/Example06/Example06_Get-ToastJobNotification.gif b/Examples/Example06/Example06_Get-ToastJobNotification.gif deleted file mode 100644 index b2c6dc0..0000000 Binary files a/Examples/Example06/Example06_Get-ToastJobNotification.gif and /dev/null differ diff --git a/Examples/Example06/Get-ToastJobNotification.ps1 b/Examples/Example06/Get-ToastJobNotification.ps1 deleted file mode 100644 index 289bf46..0000000 --- a/Examples/Example06/Get-ToastJobNotification.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -$BurntJob = Start-Job -ScriptBlock {Start-Sleep 5;Get-date} -Name "BurntJob" - -$BurntEvent = Register-ObjectEvent $BurntJob StateChanged -Action { - New-BurntToastNotification -Text "Job: $($BurntJob.Name) completed" - $BurntEvent | Unregister-Event -} \ No newline at end of file diff --git a/Examples/Example07/Start-PingNotification.ps1 b/Examples/Example07/Start-PingNotification.ps1 deleted file mode 100644 index e43595b..0000000 --- a/Examples/Example07/Start-PingNotification.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -$Destination = "8.8.8.8" -$ScriptBlock = { - $TimesLooped = 0 - while ( $Duration -le $TimesLooped) { - if ( Test-Connection -ComputerName $using:Destination -Count 1 -Quiet ) { - New-BurntToastNotification -Text ($using:Destination + " is online"), ("Last checked :" + (Get-Date).ToString()) -UniqueIdentifier $using:Destination - }#if - else { - New-BurntToastNotification -Text ($using:Destination + " is offline"), ("Last checked :" + (Get-Date).ToString()) -UniqueIdentifier $using:Destination - }#else - Start-Sleep -Seconds 5 - $TimesLooped++ - }#while -}#Scriptblock -Start-Job -Name $Destination -ScriptBlock $ScriptBlock \ No newline at end of file diff --git a/Examples/Example08/ApiToast.png b/Examples/Example08/ApiToast.png deleted file mode 100644 index 165d435..0000000 Binary files a/Examples/Example08/ApiToast.png and /dev/null differ diff --git a/Examples/Example08/Example08_Default.ps1 b/Examples/Example08/Example08_Default.ps1 deleted file mode 100644 index 1e18d3a..0000000 --- a/Examples/Example08/Example08_Default.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -####################################################### -# .Info -# Shows how to configure an (unsecured) http listener -# in the background to wait for and display as a toast -# a message received via an http call -# -####################################################### - -$JobScript = { - try - { - Import-Module BurntToast - - $Listener = [System.Net.HttpListener]::new() - - $Listener.Prefixes.Add("http://localhost:9000/") - $Listener.Start() - - While ($True) - { - $context = $Listener.GetContext() - $Reader = [System.IO.StreamReader]::new($context.Request.InputStream) - $ReadJson = $Reader.ReadToEnd() - if ($ReadJson -eq "Exit") {break} - $ReadObject = $ReadJson | ConvertFrom-Json - New-BurntToastNotification -Text $ReadObject.Text - $context.Response.Close() - } - } - catch - { - Write-Error $_ - } - finally - { - $Listener.Stop() - $Listener.Prefixes.Clear() - $Listener.Close() - } -} - -$ToastJob = Start-Job -Name ToastJob -ScriptBlock $JobScript - -$Body = @{ - Text = "Hello from API call!" -} - -Invoke-RestMethod -Method Post -Body ($Body | ConvertTo-Json) -Uri "http://localhost:9000/" - -# Causes shutdown of the listener -Invoke-RestMethod -Method Post -Body "Exit" -Uri "http://localhost:9000/" - - diff --git a/Examples/Example09/Get-ChocoUpgradeNotification.ps1 b/Examples/Example09/Get-ChocoUpgradeNotification.ps1 deleted file mode 100644 index 127bb89..0000000 --- a/Examples/Example09/Get-ChocoUpgradeNotification.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -Import-Module BurntToast - -# check if chocolatey is installed and the commands are executeable -if (!(Get-Command choco -ErrorAction SilentlyContinue)) { - New-BurntToastNotification -Text "choco not available!" - throw "choco.exe is required to run this script!" -} - -# get a list of chocolatey packages that can be updated -$pkgs = choco outdated --ignore-pinned --ignore-unfound -r -$total = $pkgs.Count - -if ($total -eq 0) { - New-BurntToastNotification -Text "All Chocolatey packages are up-to-date!" -} -else { - $pkgText = "" - foreach ($package in $pkgs) - { - $pkgText += "$($package -split "\|" | Select-Object -First 1), " - } - - # cut the list of entries after 103, else the New-BurntToastNotification will throw an MethodInvocationException - if ($pkgText.Length -gt 103) { - $pkgText = $pkgText.Substring(0, 100) - $pkgText += "..." - } - New-BurntToastNotification -Text "There are $total package updates available:", $pkgText -} \ No newline at end of file diff --git a/Examples/Example10/Creating a Shoulder Tap notification.ps1 b/Examples/Example10/Creating a Shoulder Tap notification.ps1 deleted file mode 100644 index d44e498..0000000 --- a/Examples/Example10/Creating a Shoulder Tap notification.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -$Image = 'https://i.imgur.com/WKiNp5o.gif' -$Contact = 'stormy@example.com' -$Text = 'First Shoulder Tap', 'This is for the fallback toast.' - -New-BurntToastShoulderTap -Image $Image -Person $Contact -Text $Text \ No newline at end of file diff --git a/Examples/Example10/result.gif b/Examples/Example10/result.gif deleted file mode 100644 index 9d4376b..0000000 Binary files a/Examples/Example10/result.gif and /dev/null differ diff --git a/Help/New-BTAction.md b/Help/New-BTAction.md deleted file mode 100644 index d9a57f8..0000000 --- a/Help/New-BTAction.md +++ /dev/null @@ -1,135 +0,0 @@ -# New-BTAction - -## SYNOPSIS - -Creates an action object for a Toast Notification. - -## SYNTAX - -### Custom Actions (Default) - -```powershell -New-BTAction [[-Buttons] ] [[-ContextMenuItems] ] [[-Inputs] ] -``` - -### SnoozeAndDismiss - -```powershell -New-BTAction -SnoozeAndDismiss -``` - -## DESCRIPTION - -The New-BTAction function creates an 'action' object which contains defines the controls displayed at the bottom of a Toast Notification. - -Actions can either be system handeled and automatically localized Snooze and Dismiss buttons or a custom collection of inputs. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>New-BTAction -SnoozeAndDismiss -``` - -This command creates an action element using the system handled snooze and dismiss modal. - -### -------------------------- EXAMPLE 2 -------------------------- - -```powershell -PS C:\>New-BTAction -Buttons (New-BTButton -Content 'Google' -Arguments 'https://google.com') -``` - -This command creates an action element with a single clickable button. - -### -------------------------- EXAMPLE 3 -------------------------- - -```powershell -PS C:\>$Button = New-BTButton -Content 'Google' -Arguments 'https://google.com' -PS C:\>$ContextMenuItem = New-BTContextMenuItem -Content 'Bing' -Arguments 'https://bing.com' -PS C:\>New-BTAction -Buttons $Button -ContextMenuItems $ContextMenuItem -``` - -This example creates an action elemnt with both a clickable button and a right click context menu item. - -## PARAMETERS - -### -Buttons - -Button objects created with the New-BTButton function. Up to five can be included, or less if Context Menu Items are also included. - -```yaml -Type: IToastButton[] -Parameter Sets: Custom Actions -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ContextMenuItems - -Right click context menu item objects created with the New-BTContextMenuItem function. Up to five can be included, or less if Buttons are also included. - -```yaml -Type: ToastContextMenuItem[] -Parameter Sets: Custom Actions -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Inputs - -Input objects created via the New-BTText and New-BTSelectionBoxItem functions. Up to five can be included. - -```yaml -Type: IToastInput[] -Parameter Sets: Custom Actions -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SnoozeAndDismiss - -Creates a system handeled snooze and dismiss action. Cannot be included inconjunction with custom actions. - -```yaml -Type: SwitchParameter -Parameter Sets: SnoozeAndDismiss -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -You cannot pipe input to this function. - -## OUTPUTS - -Microsoft.Toolkit.Uwp.Notifications.IToastActions - -## NOTES - -## RELATED LINKS - -[New-BTAction](https://github.com/Windos/BurntToast/blob/main/Help/New-BTAction.md) diff --git a/Help/New-BTAppId.md b/Help/New-BTAppId.md deleted file mode 100644 index 1c91b65..0000000 --- a/Help/New-BTAppId.md +++ /dev/null @@ -1,71 +0,0 @@ -# New-BTAction - -## SYNOPSIS - -Creates a new AppId Registry Key. - -## SYNTAX - -```powershell -New-BTAppId [[-AppId] ] -``` - -## DESCRIPTION - -The New-BTAppId function create a new AppId registry key in the Current User's Registery Hive. If the desired AppId is already present in the Registry then no changes are made. - -If no AppId is specified then the AppId specified in the config.json file in the BurntToast module's root directory is used. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>New-BTAppId -``` - -This command creates an AppId registry key using the value specified in the BurntToast module's config.json file, which is 'BurntToast' by default. - -### -------------------------- EXAMPLE 2 -------------------------- - -```powershell -PS C:\>New-BTAppId -AppId 'Script Checker' -``` - -This command create an AppId registry key called 'Script Checker.' - -## PARAMETERS - -### -AppId - -Specifies the new AppId. You can use any alphanumeric characters. - -Defaults to the AppId specified in the config.json file in the BurntToast module's root directoy if not provided. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: $Script:Config.AppId -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -You cannot pipe input to this function. - -## OUTPUTS - -None - -## NOTES - -## RELATED LINKS - -[New-BTAction](https://github.com/Windos/BurntToast/blob/main/Help/New-BTAppId.md) diff --git a/Help/New-BTAudio.md b/Help/New-BTAudio.md deleted file mode 100644 index 55cbdde..0000000 --- a/Help/New-BTAudio.md +++ /dev/null @@ -1,149 +0,0 @@ -# New-BTAudio - -## SYNOPSIS - -Creates a new Audio Element for Toast Notifications. - -## SYNTAX - -### StandardSound (Default) - -```powershell -New-BTAudio -Source [-Loop] -``` - -### CustomSound - -```powershell -New-BTAudio -Path [-Loop] -``` - -### Silent - -```powershell -New-BTAudio -Silent -``` - -## DESCRIPTION - -The New-BTAudioElement function creates a new Audio Element for Toast Notifications. - -You can use the parameters of New-BTAudioElement to select an audio file or a standard notification sound (including alarms). -Alternativly you can specify that a Toast Notification should be silent. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>New-BTAudioElement -Source SMS -``` - -Creates an Audio Element which will cause a Toast Notification to play the standard Microsoft 'SMS' sound. - -### -------------------------- EXAMPLE 2 -------------------------- - -```powershell -PS C:\>New-BTAudioElement -Path 'C:\Music\FavSong.mp3' -``` - -Creates an Audio Element which will cause a Toast Notification to play the specified song. - -### -------------------------- EXAMPLE 3 -------------------------- - -```powershell -PS C:\>New-BTAudioElement -Silent -``` - -Creates an Audio Element which will cause a Toast Notification to be silent. - -## PARAMETERS - -### -Loop - -Specifies that the slected sound should play multiple times if its duration is shorter than that of the toast it accompanies. - -```yaml -Type: SwitchParameter -Parameter Sets: CustomSound, StandardSound -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Path - -The full path to an audio file. Supported file types include: - -*.aac -*.flac -*.m4a -*.mp3 -*.wav -*.wma - -```yaml -Type: String -Parameter Sets: CustomSound -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Silent - -Specifies that the toast should be displayed without sound. - -```yaml -Type: SwitchParameter -Parameter Sets: Silent -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Source - -Specifies one of the built in Microsoft notification sounds. - -This paramater takes the full form of the sounds, in the form of a uri. The New-BurntToastNotification function simplifies this, so be aware of the difference. - -```yaml -Type: Uri -Parameter Sets: StandardSound -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -You cannot pipe input to this cmdlet. - -## OUTPUTS - -ToastAudio - -## NOTES - -## RELATED LINKS - -[New-BTAudio](https://github.com/Windos/BurntToast/blob/main/Help/New-BTAudio.md) diff --git a/Help/New-BTBinding.md b/Help/New-BTBinding.md deleted file mode 100644 index b0616a7..0000000 --- a/Help/New-BTBinding.md +++ /dev/null @@ -1,176 +0,0 @@ -# New-BTBinding - -## SYNOPSIS - -Creates a new Generic Toast Binding object. - -## SYNTAX - -```powershell -New-BTBinding [[-Children] ] [-AddImageQuery] - [[-AppLogoOverride] ] [[-Attribution] ] [[-BaseUri] ] - [[-HeroImage] ] [[-Language] ] -``` - -## DESCRIPTION - -The New-BTBinding function creates a new Generic Toast Binding, where you provide text, images, and other visual elements for your Toast notification. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>$text1 = New-BTText -Content 'This is a test' -PS C:\>$text2 = New-BTText -PS C:\>$text3 = New-BTText -Content 'This more testing' -PS C:\>$progress = New-BTProgressBar -Title 'Things are happening' -Status 'Working on it' -Value 0.01 -PS C:\>$image1 = New-BTImage -Source 'C:\BurntToast\Media\BurntToast.png' -PS C:\>$image2 = New-BTImage -Source 'C:\BurntToast\Media\BurntToast.png' -AppLogoOverride -Crop Circle -PS C:\>$image3 = New-BTImage -Source 'C:\BurntToast\Media\BurntToast.png' -HeroImage -PS C:\>$binding1 = New-BTBinding -Children $text1, $text2, $text3, $image1, $progress -AppLogoOverride $image2 -HeroImage $image3 -``` - -This example uses various BurntToast functions to create a number of objects, and then create a Generic Toast Binding using them as inputs. - -## PARAMETERS - -### -AddImageQuery - -Set to "true" to allow Windows to append a query string to the image URI supplied in the Toast notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -AppLogoOverride - -An optional override of the logo displayed on the Toast notification. - -Created using the New-BTImage function with the 'AppLogoOverride' switch. - -```yaml -Type: ToastGenericAppLogo -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Attribution - -New in Anniversary Update: An optional text element that is displayed as attribution text. - -On devices without the Anniversary Update, this text will appear as if it's another Text element at the end of your Children list. - -```yaml -Type: ToastGenericAttributionText -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -BaseUri - -A default base URI that is combined with relative URIs in image source attributes. - -```yaml -Type: Uri -Parameter Sets: (All) -Aliases: - -Required: False -Position: 4 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Children - -The contents of the body of the Toast, which can include Text (New-BTText), Image (New-BTImage), Group (not yet implemented), and Progress Bar (New-BTProgressBar). - -Also, Text elements must come before any other elements. If a Text element is placed after any other element, an exception will be thrown when you try to retrieve the Toast XML content. - -And finally, certain Text properties like HintStyle aren't supported on the root children text elements, and only work inside a Group. If you use Group on devices without the Anniversary Update, the group content will simply be dropped. - -```yaml -Type: IToastBindingGenericChild[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -HeroImage - -New in Anniversary Update: An optional hero image (a visually impactful image displayed on the Toast notification). - -On devices without the Anniversary Update, the hero image will simply be ignored. - -```yaml -Type: ToastGenericHeroImage -Parameter Sets: (All) -Aliases: - -Required: False -Position: 5 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Language - -The target locale of the XML payload, specified as BCP-47 language tags such as "en-US" or "fr-FR". This locale is overridden by any locale specified in binding or text. If this value is a literal string, this attribute defaults to the user's UI language. If this value is a string reference, this attribute defaults to the locale chosen by Windows Runtime in resolving the string. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 6 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -## OUTPUTS - -ToastBindingGeneric - -## 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 Please see the [originating repo](https://github.com/windows-toolkit/WindowsCommunityToolkit). - -## RELATED LINKS - -[New-BTBinding](https://github.com/Windos/BurntToast/blob/main/Help/New-BTBinding.md) diff --git a/Help/New-BTButton.md b/Help/New-BTButton.md deleted file mode 100644 index 858b751..0000000 --- a/Help/New-BTButton.md +++ /dev/null @@ -1,233 +0,0 @@ -# New-BTButton - -## SYNOPSIS - -Creates a new clickable button for a Toast Notification. - -## SYNTAX - -### Button (Default) - -```powershell -New-BTButton -Content -Arguments [-ActivationType {Foreground | Background | Protocol}] [-ImageUri ] [-Id ] -``` - -### Snooze - -```powershell -New-BTButton -Snooze [-Content ] [-Id ] -``` - -### Dismiss - -```powershell -New-BTButton -Dismiss [-Content ] -``` - -## DESCRIPTION - -The New-BTButton function creates a new clickable button for a Toast Notification. Up to five buttons can be added to one Toast. - -Buttons can be fully customized with display text, images and arguments or system handled 'Snooze' and 'Dismiss' buttons. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>New-BTButton -Dismiss -``` - -This command creates a button which mimmicks the act of 'swiping away' the Toast when clicked. - -### -------------------------- EXAMPLE 2 -------------------------- - -```powershell -PS C:\>New-BTButton -Snooze -``` - -This command creates a button which will snooze the Toast for the system default snooze time (often 10 minutes). - -### -------------------------- EXAMPLE 3 -------------------------- - -```powershell -PS C:\>New-BTButton -Snooze -Content 'Sleep' -Id 'TimeSelection' -``` - -This command creates a button which will snooze the Toast for the time selected in the SelectionBox with the ID 'TimeSelection'. The button will show the text 'Sleep' rather than 'Dismiss.' - -### -------------------------- EXAMPLE 4 -------------------------- - -```powershell -PS C:\>New-BTButton -Content 'Blog' -Arguments 'https://king.geek.nz' -``` - -This command creates a button with the display text "Blog", which will launch a browser window to ["https://king.geek.nz"](https://king.geek.nz) when clicked. - -### -------------------------- EXAMPLE 5 -------------------------- - -```powershell -PS C:\>$Picture = 'C:\temp\example.png' -PS C:\>New-BTButton -Content 'View Picture' -Arguments $Picture -ImageUri $Picture -``` - -This example creates a button with the display text "View Picture" with a picture to the left, which will launch the default picture viewer application and load the picture when clicked. - -## PARAMETERS - -### -ActivationType - -Defines the 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 rlevant system default application. - -```yaml -Type: ToastActivationType -Parameter Sets: Button -Aliases: -Accepted values: Foreground, Background, Protocol - -Required: False -Position: Named -Default value: Protocol -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Arguments - -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. - -```yaml -Type: String -Parameter Sets: Button -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Content - -Specifies the text to display on the button. - -```yaml -Type: String -Parameter Sets: Button -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -```yaml -Type: String -Parameter Sets: Snooze, Dismiss -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Dismiss - -Specifies a system handled dismiss button. Clicking the resulting button has the same affect as 'swiping away' or otherwise dismissing the Toast. - -Display text defaults to a localized 'Dismiss', but this can be overridden with the Content parameter. - -```yaml -Type: SwitchParameter -Parameter Sets: Dismiss -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Id - -Specifies the ID of a relevant Toast control. - -Standard buttons can be paried with a text box which makes the button appear to the right of it. - -Snooze buttons can be paired with a selection box to select the ammount of time to snooze. - -```yaml -Type: String -Parameter Sets: Button, Snooze -Aliases: TextBoxId, SelectionBoxId - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ImageUri - -Specifies an image icon to display on the button. - -```yaml -Type: String -Parameter Sets: Button -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Snooze - -Specifies a system handled snooze button. When paired with a selection box the snooze time is customizable and user selectable, otherwise the system default snooze time is used. - -Display text defaults to a localized 'Snooze', but this can be overridden with the Content parameter. - -```yaml -Type: SwitchParameter -Parameter Sets: Snooze -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -You cannot pipe input to this function. - -## OUTPUTS - -Microsoft.Toolkit.Uwp.Notifications.ToastButton - -Microsoft.Toolkit.Uwp.Notifications.ToastButtonDismiss - -Microsoft.Toolkit.Uwp.Notifications.ToastButtonSnooze - -## NOTES - -## RELATED LINKS - -[New-BTButton](https://github.com/Windos/BurntToast/blob/main/Help/New-BTButton.md) diff --git a/Help/New-BTContent.md b/Help/New-BTContent.md deleted file mode 100644 index 356660f..0000000 --- a/Help/New-BTContent.md +++ /dev/null @@ -1,189 +0,0 @@ -# New-BTContent - -## SYNOPSIS - -Creates a new Toast Content object. - -## SYNTAX - -```powershell -New-BTContent [[-Actions] ] [[-ActivationType] ] [[-Audio] ] - [[-Duration] ] [[-Launch] ] [[-Scenario] ] [-Visual] -``` - -## DESCRIPTION - -The New-BTContent function creates a new Toast Content object which is the Base Toast element, which contains at least a visual element. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>$binding1 = New-BTBinding -Children $text1, $text2 -AppLogoOverride $image2 -PS C:\>$visual1 = New-BTVisual -BindingGeneric $binding1 -PS C:\>$content1 = New-BTContent -Visual $visual1 -``` - -This example combines numerous objects created via BurntToast functions into a binding, then a visual element and finally into a content object. - -The resultant object can now be displayed using the Submit-BTNotification function. - -### -------------------------- EXAMPLE 2 -------------------------- - -```powershell -PS C:\>$content1 = New-BTContent -Visual $visual1 -ActivationType Protocol -Launch 'https://google.com' -``` - -This command takes a pre-existing visual object and also specifies options required to launch a browser on the Google homepage when clicking the toast. - -## PARAMETERS - -### -Actions - -Optionally create custom actions with buttons and inputs (New-BTAction.) - -```yaml -Type: IToastActions -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ActivationType - -Specifies what activation type will be used when the user clicks the body of this Toast. - -```yaml -Type: ToastActivationType -Parameter Sets: (All) -Aliases: -Accepted values: Foreground, Background, Protocol - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Audio - -Specify custom audio options (New-BTAudio.) - -```yaml -Type: ToastAudio -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Duration - -The amount of time the Toast should display. You typically should use the Scenario attribute instead, which impacts how long a Toast stays on screen. - -```yaml -Type: ToastDuration -Parameter Sets: (All) -Aliases: -Accepted values: Short, Long - -Required: False -Position: 4 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Header - -New in Creators Update: Specifies an optional header for the toast notification (New-BTHeader.) - -```yaml -Type: ToastHeader -Parameter Sets: (All) -Aliases: - -Required: False -Position: 5 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Launch - -A string that is passed to the application when it is activated by the Toast. The format and contents of this string are defined by the app for its own use. When the user taps or clicks the Toast to launch its associated app, the launch string provides the context to the app that allows it to show the user a view relevant to the Toast content, rather than launching in its default way. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 6 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Scenario - -Specify the scenario, to make the Toast behave like an alarm, reminder, or more. - -```yaml -Type: ToastScenario -Parameter Sets: (All) -Aliases: -Accepted values: Default, Alarm, Reminder, IncomingCall - -Required: False -Position: 7 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Visual - -Specify the visual element object, created with the New-BTVisual function. - -```yaml -Type: ToastVisual -Parameter Sets: (All) -Aliases: - -Required: True -Position: 8 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -## OUTPUTS - -ToastContent - -## 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 Please see the [originating repo](https://github.com/windows-toolkit/WindowsCommunityToolkit). - -## RELATED LINKS - -[New-BTContent](https://github.com/Windos/BurntToast/blob/main/Help/New-BTContent.md) diff --git a/Help/New-BTContextMenuItem.md b/Help/New-BTContextMenuItem.md deleted file mode 100644 index c6869c9..0000000 --- a/Help/New-BTContextMenuItem.md +++ /dev/null @@ -1,94 +0,0 @@ -# New-BTContextMenuItem - -## SYNOPSIS - -Creates a Context Menu Item object. - -## SYNTAX - -```powershell -New-BTContextMenuItem [-Content] [-Arguments] [[-ActivationType] ] -``` - -## DESCRIPTION - -The New-BTContextMenuItem function creates a Context Menu Item object. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>New-BTContextMenuItem -Content 'Google' -Arguments 'https://google.com' -ActivationType Protocol -``` - -This command creates a new Context Menu Item object with the specified properties. - -## PARAMETERS - -### -ActivationType - -Controls what type of activation this menu item will use when clicked. Defaults to Foreground. - -```yaml -Type: ToastActivationType -Parameter Sets: (All) -Aliases: -Accepted values: Foreground, Background, Protocol - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Arguments - -App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the menu item. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Content - -The text to display on the menu item. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -## OUTPUTS - -ToastContextMenuItem - -## 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](https://github.com/windows-toolkit/WindowsCommunityToolkit). - -## RELATED LINKS - -[New-BTContextMenuItem](https://github.com/Windos/BurntToast/blob/main/Help/New-BTContextMenuItem.md) diff --git a/Help/New-BTHeader.md b/Help/New-BTHeader.md deleted file mode 100644 index 0cf8333..0000000 --- a/Help/New-BTHeader.md +++ /dev/null @@ -1,126 +0,0 @@ -# New-BTHeader - -## SYNOPSIS - -Creates a new toast notification header. - -## SYNTAX - -```powershell -New-BTHeader [-Id] [-Title] [[-Arguments] ] [[-ActivationType] {Foreground | Background | Protocol}] -``` - -## DESCRIPTION - -The New-BTHeader function creates a new toast notification header for a Toast Notification. - -These headers are displayed at the top of a toast and are also used to categorize toasts in the Action Center. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>New-BTHeader -Id 'primary header' -Title 'First Category' -``` - -This command creates a Toast Header object, which will be displayed with the text "First Category." - -### -------------------------- EXAMPLE 2 -------------------------- - -```powershell -PS C:\>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. - -## PARAMETERS - -### -Id - -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. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Title - -The header string that is displayed to the user. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Arguments - -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. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ActivationType - -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. - -```yaml -Type: ActivationType -Parameter Sets: (All) -Aliases: -Accepted values: Foreground, Background, Protocol - -Required: False -Position: 4 -Default value: Protocol -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -You cannot pipe input to this function. - -## OUTPUTS - -Microsoft.Toolkit.Uwp.Notifications.ToastHeader - -## NOTES - -## RELATED LINKS - -[New-BTHeader](https://github.com/Windos/BurntToast/blob/main/Help/New-BTHeader.md) diff --git a/Help/New-BTImage.md b/Help/New-BTImage.md deleted file mode 100644 index 45c84e5..0000000 --- a/Help/New-BTImage.md +++ /dev/null @@ -1,212 +0,0 @@ -# New-BTImage - -## SYNOPSIS - -Creates a new Image Element for Toast Notifications. - -## SYNTAX - -### Image (Default) - -```powershell -New-BTImage [-Source ] [-AlternateText ] [-Align ] - [-Crop ] [-RemoveMargin] [-AddImageQuery] -``` - -### AppLogo - -```powershell -New-BTImage [-Source ] [-AlternateText ] [-AppLogoOverride] [-Crop ] - [-AddImageQuery] -``` - -### Hero - -```powershell -New-BTImage [-Source ] [-AlternateText ] [-HeroImage] [-AddImageQuery] -``` - -## DESCRIPTION - -The New-BTImageElement function creates a new Image Element for Toast Notifications. - -You can use the parameters of New-BTImageElement to specify the source image, alt text, placement on the Toast Notification and crop shape. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>$image1 = New-BTImage -Source 'C:\Media\BurntToast.png' -``` - -This command creates a standard image object to be included in the main body of a toast. - -### -------------------------- EXAMPLE 2 -------------------------- - -```powershell -PS C:\>$image2 = New-BTImage -Source 'C:\Media\BurntToast.png' -AppLogoOverride -Crop Circle -``` - -This command creates an image object to be used as the logo on a toast, cropped into the shape fo a circle. - -### -------------------------- EXAMPLE 3 -------------------------- - -```powershell -PS C:\>$image3 = New-BTImage -Source 'C:\Media\BurntToast.png' -HeroImage -``` - -This command creates an inmage to be used as a toast's hero image. - -## PARAMETERS - -### -AddImageQuery - -Set to true to allow Windows to append a query string to the image URI supplied in the Tile notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Align - -The horizontal alignment of the image. For Toast, this is only supported when inside a group (not yet implemented.) - -```yaml -Type: AdaptiveImageAlign -Parameter Sets: Image -Aliases: -Accepted values: Default, Stretch, Left, Center, Right - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -AlternateText - -A description of the image, for users of assistive technologies. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -AppLogoOverride - -Specifies that the image is to be used as the logo on the toast. - -```yaml -Type: SwitchParameter -Parameter Sets: AppLogo -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Crop - -Control the desired cropping of the image. Supported on Toast since Anniversary Update. - -```yaml -Type: AdaptiveImageCrop -Parameter Sets: Image, AppLogo -Aliases: -Accepted values: Default, None, Circle - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -HeroImage - -Specifies that the image is to be used as the hero image on the toast. - -```yaml -Type: SwitchParameter -Parameter Sets: Hero -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -RemoveMargin - -By default, images have an 8px margin around them. You can remove this margin by including this switch. Supported on Toast since Anniversary Update. - -```yaml -Type: SwitchParameter -Parameter Sets: Image -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Source - -The URI of the image. Can be from your application package, application data, or the internet. Internet images must be less than 200 KB in size. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: $Script:DefaultImage -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -## OUTPUTS - -AdaptiveImage - -ToastGenericAppLogo - -ToastGenericHeroImage - -## 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](https://github.com/Microsoft/UWPCommunityToolkit). - -## RELATED LINKS - -[New-BTImage](https://github.com/Windos/BurntToast/blob/main/Help/New-BTImage.md) diff --git a/Help/New-BTInput.md b/Help/New-BTInput.md deleted file mode 100644 index d469954..0000000 --- a/Help/New-BTInput.md +++ /dev/null @@ -1,164 +0,0 @@ -# New-BTInput - -## SYNOPSIS - -Creates an input element on a Toast notification. - -## SYNTAX - -### Text (Default) - -```powershell -New-BTInput -Id [-Title ] [-PlaceholderContent ] [-DefaultInput ] -``` - -### Selection - -```powershell -New-BTInput -Id [-Title ] [-DefaultSelectionBoxItemId ] - -Items -``` - -## DESCRIPTION - -The New-BTInput function creates an input element on a Toast notification. - -Returned object is either a TextBox for users to type text into or SelectionBox to users to select from a list of options. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>New-BTInput -Id Reply001 -Title 'Type a reply:' -``` - -This command creates a new text box for a user to type a reply. (n.b. this sort of functionality probably won't work through BurntToast as PowerShell cannot, currently, subscribe to WinRT events.) - -### -------------------------- EXAMPLE 2 -------------------------- - -```powershell -PS C:\>New-BTInput -Id 'Selection001' -DefaultSelectionBoxItemId 'Item5' -Items $Select1, $Select2, $Select3, $Select4, $Select5 -``` - -This command creates a new selection box containing five options and specifying the ID of one of the options as the default. - -## PARAMETERS - -### -DefaultInput - -The initial text to place in the text box. Leave this null for a blank text box. - -```yaml -Type: String -Parameter Sets: Text -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DefaultSelectionBoxItemId - -This controls which item is selected by default, and refers to the Id property of a Selection Box Item (New-BTSelectionBoxItem.) - -If you do not provide this, the default selection will be empty (user sees nothing). - -```yaml -Type: String -Parameter Sets: Selection -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Id - -Used so that developers can retrieve user input once the app is activated. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Items - -The selection items that the user can pick from in this SelectionBox. Only 5 items can be added. - -```yaml -Type: ToastSelectionBoxItem[] -Parameter Sets: Selection -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -PlaceholderContent - -Placeholder text to be displayed on the text box when the user hasn't typed any text yet. - -```yaml -Type: String -Parameter Sets: Text -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Title - -Title text to display above the element - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -## OUTPUTS - -ToastTextBox - -ToastSelectionBox - -## 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](https://github.com/Microsoft/UWPCommunityToolkit). - -## RELATED LINKS - -[New-BTInput](https://github.com/Windos/BurntToast/blob/main/Help/New-BTInput.md) diff --git a/Help/New-BTProgressBar.md b/Help/New-BTProgressBar.md deleted file mode 100644 index b0d0478..0000000 --- a/Help/New-BTProgressBar.md +++ /dev/null @@ -1,167 +0,0 @@ -# New-BTProgressBar - -## SYNOPSIS - -Creates a new Progress Bar Element for Toast Notifications. - -## SYNTAX - -### Determinate (Default) - -```powershell -New-BTProgressBar [-Title ] -Status -Value [-ValueDisplay ] -``` - -### Indeterminate - -```powershell -New-BTProgressBar [-Title ] -Status -Indeterminate [-ValueDisplay ] -``` - -## DESCRIPTION - -The New-BTProgressBar function creates a new Progress Bar Element for Toast Notifications. - -You must specify the status and value for the progress bar and can optionally give the bar a title and override the automatic text representiation of the progress. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>New-BTProgressBar -Status 'Copying files' -Value 0.2 -``` - -This command creates a Progress Bar that is 20% full with the current status of 'Copying files' and the (default) text 20% displayed underneath. - -### -------------------------- EXAMPLE 2 -------------------------- - -```powershell -PS C:\>New-BTProgressBar -Status 'Copying files' -Indeterminate -``` - -This command creates a Progress Bar with an 'indeterminate' animation rather than a bar filled to a certain percentage. - -### -------------------------- EXAMPLE 3 -------------------------- - -```powershell -PS C:\>New-BTProgressBar -Status 'Copying files' -Value 0.2 -ValueDisplay '4/20 files complete' -``` - -This command creates a Progress Bar that is 20% full with the current status of 'Copying files' and the default text displayed underneath overridden to '4/20 files complete.' - -### -------------------------- EXAMPLE 4 -------------------------- - -```powershell -PS C:\>New-BTProgressBar -Title 'File Copy' -Status 'Copying files' -Value 0.2 -``` - -This example creates a Progress Bar that is 20% full with the current status of 'Copying files' and the (default) text 20% displayed underneath. - -The Progress Bar is displayed under the title 'File Copy.' - -## PARAMETERS - -### -Title - -The text displayed above the progress bar. Generally used to give context around what the bar represents. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Names -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Status - -The text displayed under the progress bar. Used to show the current status of the operation being performed. - -Examples include: Running, Paused, Stopped, Finished. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Indeterminate - -Used where the percentage complete is unknown, the resulting progress bar displays a system generated animation rather than a filled bar. - -Cannot be used at the same time as a set Value. - -```yaml -Type: SwitchParameter -Parameter Sets: Indeterminate -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Value - -Specifies the percentage to fill the progress bar as represented by a double, between 0 and 1 (inclusive.) - -For example 0.4 is 40%, 1 is 100%. - -```yaml -Type: Double -Parameter Sets: Determinate -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ValueDisplay - -A string that replaces the default text representation of the percentage complete. - -The default text for the value 0.2 would be '20%', this parameter replaces this text with something of your own choice. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -String - -You cannot pipe input to this cmdlet. - -## OUTPUTS - -AdaptiveProgressBar - -## NOTES - -## RELATED LINKS - -[New-BTProgressBar](https://github.com/Windos/BurntToast/blob/main/Help/New-BTProgressBar.md) diff --git a/Help/New-BTSelectionBoxItem.md b/Help/New-BTSelectionBoxItem.md deleted file mode 100644 index 991ba2c..0000000 --- a/Help/New-BTSelectionBoxItem.md +++ /dev/null @@ -1,79 +0,0 @@ -# New-BTSelectionBoxItem - -## SYNOPSIS - -Creates a selection box item. - -## SYNTAX - -```powershell -New-BTSelectionBoxItem [-Id] [-Content] -``` - -## DESCRIPTION - -The New-BTSelectionBoxItem function creates a selection box item, for inclusion in a selection box created with New-BTInput. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>$Select1 = New-BTSelectionBoxItem -Id 'Item1' -Content 'First option in the list' -``` - -This command creates a new Selection Box Item object which can now be used with the New-BTInput function. - -## PARAMETERS - -### -Content - -String that is displayed on the selection item. This is what the user sees. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Id - -Developer-provided ID that the developer uses later to retrieve input when the Toast is interacted with. - -Can also be provided to a selection box to identify the default selection. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -None - -## OUTPUTS - -ToastSelectionBoxItem - -## 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](https://github.com/Microsoft/UWPCommunityToolkit). - -## RELATED LINKS - -[New-BTSelectionBoxItem](https://github.com/Windos/BurntToast/blob/main/Help/New-BTSelectionBoxItem.md) diff --git a/Help/New-BTText.md b/Help/New-BTText.md deleted file mode 100644 index a4b58f8..0000000 --- a/Help/New-BTText.md +++ /dev/null @@ -1,178 +0,0 @@ -# New-BTText - -## SYNOPSIS - -Creates a new Text Element for Toast Notifications. - -## SYNTAX - -```powershell -New-BTText [[-Text] ] [[-MaxLines] ] [[-MinLines] ] [-Wrap] - [[-Align] ] [[-Style] ] [[-Language] ] -``` - -## DESCRIPTION - -The New-BTTextElement function creates a new Text Element for Toast Notifications. - -You can specify the text you want displayed in a Toast Notification as a string, or run the function without a paramter for a blank line. - -Each Text Element is the equivalent of one line in on a Toast Notification, long lines will wrap. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>New-BTTextElement -Content 'This is a line with text!' -``` - -Creates a Text Element that will show the string 'This is a line with text!' on a Toast Notification. - -### -------------------------- EXAMPLE 2 -------------------------- - -```powershell -PS C:\>New-BTTextElement -``` - -Creates a Text Element that will show a blank line on a Toast Notification. - -## PARAMETERS - -### -Align - -The horizontal alignment of the text. Note that for Toast, this property will only take effect if the text is inside a group (not yet implemented.) - -```yaml -Type: AdaptiveTextAlign -Parameter Sets: (All) -Aliases: -Accepted values: Default, Auto, Left, Center, Right - -Required: False -Position: 4 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Language - -The target locale of the XML payload, specified as a BCP-47 language tags such as "en-US" or "fr-FR". The locale specified here overrides any other specified locale, such as that in binding or visual. If this value is a literal string, this attribute defaults to the user's UI language. If this value is a string reference, this attribute defaults to the locale chosen by Windows Runtime in resolving the string. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 6 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -MaxLines - -The maximum number of lines the text element is allowed to display. For Toasts, top-level text elements will have varying max line amounts (and in the Anniversary Update you can change the max lines). - -Text on a Toast inside a group (not yet implemented) will behave identically to Tiles (default to infinity). - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: 0 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -MinLines - -The minimum number of lines the text element must display. Note that for Toast, this property will only take effect if the text is inside a group (not yet implemented.) - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: 0 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Style - -The style controls the text's font size, weight, and opacity. Note that for Toast, the style will only take effect if the text is inside a group (not yet implemented.) - -```yaml -Type: AdaptiveTextStyle -Parameter Sets: (All) -Aliases: -Accepted values: Default, Caption, CaptionSubtle, Body, BodySubtle, Base, BaseSubtle, Subtitle, SubtitleSubtle, Title, TitleSubtle, TitleNumeral, Subheader, SubheaderSubtle, SubheaderNumeral, Header, HeaderSubtle, HeaderNumeral - -Required: False -Position: 5 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Text - -The text to display. Data binding support added in Creators Update, only works for toast top-level text elements (But appears to not be working via PowerShell yet.) - -```yaml -Type: String -Parameter Sets: (All) -Aliases: Content - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Wrap - -{{Fill Wrap Description}} - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -String - -You cannot pipe input to this function. - -## OUTPUTS - -AdaptiveText - -## NOTES - -TODO: Implement [hint-style](https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/06/30/adaptive-tile-templates-schema-and-documentation/) - -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](https://github.com/Microsoft/UWPCommunityToolkit) - -## RELATED LINKS - -[New-BTText](https://github.com/Windos/BurntToast/blob/main/Help/New-BTText.md) diff --git a/Help/New-BTVisual.md b/Help/New-BTVisual.md deleted file mode 100644 index cede5f4..0000000 --- a/Help/New-BTVisual.md +++ /dev/null @@ -1,110 +0,0 @@ -# New-BTVisual - -## SYNOPSIS - -Creates a new visual element for toast notifications. - -## SYNTAX - -```powershell -New-BTVisual [-BindingGeneric] [-AddImageQuery] [[-BaseUri] ] - [[-Language] ] -``` - -## DESCRIPTION - -The New-BTVisual function creates a new visual element for toast notifications, which defines all of the visual aspects of a toast. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>New-BTVisual -BindingGeneric $Binding1 -``` - -This command creates a new Visual element taking a previously configured binding element as input. - -## PARAMETERS - -### -AddImageQuery - -Specify this switch to allow Windows to append a query string to the image URI supplied in the Toast notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -BaseUri - -A default base URI that is combined with relative URIs in image source attributes. - -```yaml -Type: Uri -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -BindingGeneric - -The generic Toast binding, which can be rendered on all devices. This binding is created using the New-BTBinding function. - -```yaml -Type: ToastBindingGeneric -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Language - -The target locale of the XML payload, specified as BCP-47 language tags such as "en-US" or "fr-FR". This locale is overridden by any locale specified in binding or text. If this value is a literal string, this attribute defaults to the user's UI language. If this value is a string reference, this attribute defaults to the locale chosen by Windows Runtime in resolving the string. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -None - -## OUTPUTS - -ToastVisual - -## 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](https://github.com/Microsoft/UWPCommunityToolkit). - -## RELATED LINKS - -[New-BTVisual](https://github.com/Windos/BurntToast/blob/main/Help/New-BTVisual.md) diff --git a/Help/New-BurntToastNotification.md b/Help/New-BurntToastNotification.md deleted file mode 100644 index c32c0c5..0000000 --- a/Help/New-BurntToastNotification.md +++ /dev/null @@ -1,340 +0,0 @@ -# New-BurntToastNotification - -## SYNOPSIS - -Creates and displays a Toast Notification. - -## SYNTAX - -### Sound (Default) - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] [-Sound ] [-Header ] [-ProgressBar ] -``` - -### Silent - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] [-Silent] [-Header ] [-ProgressBar ] -``` - -### Snooze and Dismiss - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] -SnoozeAndDismiss [-Header ] [-ProgressBar ] -``` - -### Custom Buttons - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] -Button [-Header ] [-ProgressBar ] -``` - -### Silent and Snooze and Dismiss - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] [-Silent] -SnoozeAndDismiss [-Header ] [-ProgressBar ] -``` - -### Silent and Custom Buttons - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] [-Silent] -Button [-Header ] [-ProgressBar ] -``` - -### Sound and Snooze and Dismiss - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] [-Sound ] -SnoozeAndDismiss [-Header ] [-ProgressBar ] -``` - -### Sound and Custom Buttons - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] [-Sound ] -Button [-Header ] [-ProgressBar ] -``` - -## DESCRIPTION - -The New-BurntToastNotification function creates and displays a Toast Notification on Microsoft Windows 10. - -You can specify the text and/or image displayed as well as selecting the sound that is played when the Toast Notification is displayed. - -You can optionally call the New-BurntToastNotification function with the Toast alias. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>New-BurntToastNotification -``` - -This command creates and displays a Toast Notification with all default values. - -### -------------------------- EXAMPLE 2 -------------------------- - -```powershell -PS C:\>New-BurntToastNotification -Text 'Example Script', 'The example script has run successfully.' -``` - -This command creates and displays a Toast Notification with customized title and display text. - -### -------------------------- EXAMPLE 3 -------------------------- - -```powershell -PS C:\>New-BurntToastNotification -Text 'WAKE UP!' -Sound 'Alarm2' -``` - -This command creates and displays a Toast Notification which plays a looping alarm sound and lasts longer than a default Toast. - -### -------------------------- EXAMPLE 4 -------------------------- - -```powershell -PS C:\>$BlogButton = New-BTButton -Content 'Open Blog' -Arguments 'https://king.geek.nz' -PS C:\>New-BurntToastNotification -Text 'New Blog Post!' -Button $BlogButton -``` - -This example creates a Toast Notification with a button which will open a link to ["https://king.geek.nz"](https://king.geek.nz) when clicked. - -### -------------------------- EXAMPLE 5 -------------------------- - -```powershell -PS C:\>$ToastHeader = New-BTHeader -Id '001' -Title 'Stack Overflow Questions' -PS C:\>New-BurntToastNotification -Text 'New Stack Overflow Question!', 'More details!' -Header $ToastHeader -``` - -This example creates a Toast Notification which will be displayed under the header 'Stack Overflow Questions.' - -### -------------------------- EXAMPLE 6 -------------------------- - -```powershell -PS C:\>$Progress = New-BTProgressBar -Status 'Copying files' -Value 0.2 -PS C:\>New-BurntToastNotification -Text 'File copy script running', 'More details!' -ProgressBar $Progress -``` - -This example creates a Toast Notification which will include a progress bar. - -### -------------------------- EXAMPLE 7 -------------------------- - -```powershell -PS C:\>New-BurntToastNotification -Text 'Professional Content', 'And gr8 spelling' -UniqueIdentifier 'Toast001' -PS C:\>New-BurntToastNotification -Text 'Professional Content', 'And great spelling' -UniqueIdentifier 'Toast001' -``` - -This example will show a toast with a spelling error, which is replaced by a second toast because they both shared a unique identifier. - -## PARAMETERS - -### -AppLogo - -Specifies the path to an image that will override the default image displayed with a Toast Notification. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Button - -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. - -```yaml -Type: IToastButton[] -Parameter Sets: Custom Buttons, Silent and Custom Buttons, Sound and Custom Buttons -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Header - -Specify the Toast Header object created using the New-BTHeader function, for seperation/categorization of toasts from the same AppId. - -```yaml -Type: ToastHeader -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressBar - -Specify the Progress Bar object created using the New-BTProgressBar function. - -```yaml -Type: AdaptiveProgressBar -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Silent - -Indicates that the Toast Notification will be displayed on screen without an accompanying sound. - -Cannot be used in conjunction with the 'Sound' parameter. - -```yaml -Type: SwitchParameter -Parameter Sets: Silent, Silent and Snooze and Dismiss, Silent and Custom Buttons -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SnoozeAndDismiss - -Adds a default selection box and snooze/dismiss buttons to the bottom of the Toast Notification. - -```yaml -Type: SwitchParameter -Parameter Sets: Snooze and Dismiss, Silent and Snooze and Dismiss, Sound and Snooze and Dismiss -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Sound - -Selects the sound to accompany 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. - -Valid values: - -- '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' - -```yaml -Type: String -Parameter Sets: Sound -Aliases: - -Required: False -Position: Named -Default value: Default -Accept pipeline input: False -Accept wildcard characters: False -``` - -```yaml -Type: String -Parameter Sets: Sound and Snooze and Dismiss, Sound and Custom Buttons -Aliases: - -Required: True -Position: Named -Default value: Default -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Text - -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. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: Default Notification -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UniqueIdentifier - -A string that uniquely identifies a toast notification. Submitting a new toast with the same identifier as a previous toast will replace the previous toast. - -This is useful when updating the progress of a process, using a progress bar, or otherwise correcting/updating the information on a toast. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -You cannot pipe input to this function. - -## OUTPUTS - -TODO - -New-BurntToastNotification displays the Toast Notification that is created. - -## NOTES - -I'm *really* sorry about the number of Parameter Sets. The best explanation is: - -* You cannot specify a sound and mark the toast as silent at the same time. -* You cannot specify SnoozeAndDismiss and custom buttons at the same time. - -## RELATED LINKS - -[New-BurntToastNotification](https://github.com/Windos/BurntToast/blob/main/Help/New-BurntToastNotification.md) diff --git a/Help/New-BurntToastShoulderTap.md b/Help/New-BurntToastShoulderTap.md deleted file mode 100644 index 98a16ea..0000000 --- a/Help/New-BurntToastShoulderTap.md +++ /dev/null @@ -1,230 +0,0 @@ -# New-BurntToastShoulderTap - -## SYNOPSIS - -Creates and displays a Windows 10 Shoulder Tap Notification, which is a notification for a person pinned to your Taskbar. - -## NOTES -There's some manual steps required to create and pin a contact which matches the specified email address in the Person parameter. - -Follow the [instructions here](https://toastit.dev/2019/04/02/crouton-10/) for the prerequisites to use this cmdlet. See below for the expected output! - - - -## SYNTAX - -### Sound (Default) - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] [-Sound ] [-Header ] [-ProgressBar ] -``` - -### Silent - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] [-Silent] [-Header ] [-ProgressBar ] -``` - -### Snooze and Dismiss - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] -SnoozeAndDismiss [-Header ] [-ProgressBar ] -``` - -### Custom Buttons - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] -Button [-Header ] [-ProgressBar ] -``` - -### Silent and Snooze and Dismiss - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] [-Silent] -SnoozeAndDismiss [-Header ] [-ProgressBar ] -``` - -### Silent and Custom Buttons - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] [-Silent] -Button [-Header ] [-ProgressBar ] -``` - -### Sound and Snooze and Dismiss - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] [-Sound ] -SnoozeAndDismiss [-Header ] [-ProgressBar ] -``` - -### Sound and Custom Buttons - -```powershell -New-BurntToastNotification [-Text ] [-AppLogo ] [-Sound ] -Button [-Header ] [-ProgressBar ] -``` - -## DESCRIPTION - -The New-BurntToastShoulderTap function creates and displays a Should Tap Toast Notification on Microsoft Windows 10. - -You can specify the text and/or image displayed as well as selecting the sound that is played when the Toast Notification is displayed. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>$Image = 'https://i.imgur.com/WKiNp5o.gif' - $Contact = 'stormy@example.com' - $Text = 'First Shoulder Tap', 'This is for the fallback toast.' - - New-BurntToastShoulderTap -Image $Image -Person $Contact -Text $Text -``` - -This command creates and displays a Should Tap Toast Notification with all default values, for a pinned user named 'stormy@example.com'. If this user does not exist or is not pinned to the Taskbar, Burnt Toast will fall back to a default notification instead. - -## PARAMETERS - -### -AppLogo - -Specifies the path to an image that will override the default image displayed with a Toast Notification. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Button - -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. - -```yaml -Type: IToastButton[] -Parameter Sets: Custom Buttons, Silent and Custom Buttons, Sound and Custom Buttons -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Silent - -Indicates that the Toast Notification will be displayed on screen without an accompanying sound. - -Cannot be used in conjunction with the 'Sound' parameter. - -```yaml -Type: SwitchParameter -Parameter Sets: Silent, Silent and Snooze and Dismiss, Silent and Custom Buttons -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SnoozeAndDismiss - -Adds a default selection box and snooze/dismiss buttons to the bottom of the Toast Notification. - -```yaml -Type: SwitchParameter -Parameter Sets: Snooze and Dismiss, Silent and Snooze and Dismiss, Sound and Snooze and Dismiss -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Sound - -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. - -```yaml -Type: String -Parameter Sets: Sound -Aliases: - -Required: False -Position: Named -Default value: Default -Accept pipeline input: False -Accept wildcard characters: False -``` - -```yaml -Type: String -Parameter Sets: Sound and Snooze and Dismiss, Sound and Custom Buttons -Aliases: - -Required: True -Position: Named -Default value: Default -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Text - -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. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: Default Notification -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UniqueIdentifier - -A string that uniquely identifies a toast notification. Submitting a new toast with the same identifier as a previous toast will replace the previous toast. - -This is useful when updating the progress of a process, using a progress bar, or otherwise correcting/updating the information on a toast. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -You cannot pipe input to this function. - -## OUTPUTS - -Displays a Windows 10 Shoulder Tap message is a matching user (matches by e-mail address) is pinned to the task bar. - -If not, fails back to a standard Burnt Toast notification - -## RELATED LINKS - -[New-BurntToastShoulderTap](https://github.com/Windos/BurntToast/blob/main/Help/New-BurntToastShoulderTap.md) diff --git a/Help/README.md b/Help/README.md deleted file mode 100644 index f6a879e..0000000 --- a/Help/README.md +++ /dev/null @@ -1,77 +0,0 @@ -# BurntToast Help - -## Description -Module for creating and displaying Toast Notifications on Microsoft Windows 10. - -## BurntToast Functions -### [New-BTAction](New-BTAction.md) -The New-BTAction function creates an 'action' object which contains defines the controls displayed at the bottom of a Toast Notification. - -Actions can either be system handeled and automatically localized Snooze and Dismiss buttons or a custom collection of inputs. - -### [New-BTAppId](New-BTAppId.md) -The New-BTAppId function create a new AppId registry key in the Current User's Registery Hive. If the desired AppId is already present in the Registry then no changes are made. - -If no AppId is specified then the AppId specified in the config.json file in the BurntToast module's root directory is used. - -### [New-BTAudio](New-BTAudio.md) -The New-BTAudioElement function creates a new Audio Element for Toast Notifications. - -You can use the parameters of New-BTAudioElement to select an audio file or a standard notification sound (including alarms). Alternativly you can specify that a Toast Notification should be silent. - -### [New-BTBinding](New-BTBinding.md) -The New-BTBinding function creates a new Generic Toast Binding, where you provide text, images, and other visual elements for your Toast notification. - -### [New-BTButton](New-BTButton.md) -The New-BTButton function creates a new clickable button for a Toast Notification. Up to five buttons can be added to one Toast. - -Buttons can be fully customized with display text, images and arguments or system handled 'Snooze' and 'Dismiss' buttons. - -### [New-BTContent](New-BTContent.md) -The New-BTContent function creates a new Toast Content object which is the Base Toast element, which contains at least a visual element. - -### [New-BTContextMenuItem](New-BTContextMenuItem.md) -The New-BTContextMenuItem function creates a Context Menu Item object. - -### [New-BTHeader](New-BTHeader.md) -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. - -### [New-BTImage](New-BTImage.md) -The New-BTImageElement function creates a new Image Element for Toast Notifications. - -You can use the parameters of New-BTImageElement to specify the source image, alt text, placement on the Toast Notification and crop shape. - -### [New-BTInput](New-BTInput.md) -The New-BTInput function creates an input element on a Toast notification. - -Returned object is either a TextBox for users to type text into or SelectionBox to users to select from a list of options. - -### [New-BTProgressBar](New-BTProgressBar.md) -The New-BTProgressBar function creates a new Progress Bar Element for Toast Notifications. - -You must specify the status and value for the progress bar and can optionally give the bar a title and override the automatic text representiation of the progress. - -### [New-BTSelectionBoxItem](New-BTSelectionBoxItem.md) -The New-BTSelectionBoxItem function creates a selection box item, for inclusion in a selection box created with New-BTInput. - -### [New-BTText](New-BTText.md) -The New-BTTextElement function creates a new Text Element for Toast Notifications. - -You can specify the text you want displayed in a Toast Notification as a string, or run the function without a paramter for a blank line. - -Each Text Element is the equivalent of one line in on a Toast Notification, long lines will wrap. - -### [New-BTVisual](New-BTVisual.md) -The New-BTVisual function creates a new visual element for toast notifications, which defines all of the visual aspects of a toast. - -### [New-BurntToastNotification](New-BurntToastNotification.md) -The New-BurntToastNotification function creates and displays a Toast Notification on Microsoft Windows 10. - -You can specify the text and/or image displayed as well as selecting the sound that is played when the Toast Notification is displayed. - -You can optionally call the New-BurntToastNotification function with the Toast alias. - -### [Submit-BTNotification](Submit-BTNotification.md) -The Submit-BTNotification function submits a completed toast notification to the operating systems' notification manager for display. diff --git a/Help/Submit-BTNotification.md b/Help/Submit-BTNotification.md deleted file mode 100644 index d99e8ae..0000000 --- a/Help/Submit-BTNotification.md +++ /dev/null @@ -1,109 +0,0 @@ -# Submit-BTNotification - -## SYNOPSIS - -Submits a completed toast notification for display. - -## SYNTAX - -```powershell -Submit-BTNotification [[-Content] ] [[-SequenceNumber] ] [[-UniqueIdentifier] ] [[-AppId] ] -``` - -## DESCRIPTION - -The Submit-BTNotification function submits a completed toast notification to the operating systems' notification manager for display. - -## EXAMPLES - -### -------------------------- EXAMPLE 1 -------------------------- - -```powershell -PS C:\>Submit-BTNotification -Content $Toast1 -UniqueIdentifier 'Toast001' -``` - -This command submits the complete toast content object $Toast1, from the New-BTContent function, and tags it with a unique identifier so that it can be replaced/updated. - -## PARAMETERS - -### -AppId - -Specifies the AppId of the 'application' or process that spawned the toast notification. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 4 -Default value: $Script:Config.AppId -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Content - -A Toast Content object which is the Base Toast element, created using the New-BTContent function. - -```yaml -Type: ToastContent -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SequenceNumber - -When updating toasts (not curently working) rapidly, the sequence number helps to ensure that toasts recieved out of order will not be displayed in a manner that may confuse. - -A higher sequence number indicates a newer toast. - -```yaml -Type: UInt64 -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UniqueIdentifier - -A string that uniquely identifies a toast notification. Submitting a new toast with the same identifier as a previous toast will replace the previous toast. - -This is useful when updating the progress of a process, using a progress bar, or otherwise correcting/updating the information on a toast. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -## INPUTS - -TODO - -## OUTPUTS - -None - -## NOTES - -## RELATED LINKS - -[Submit-BTNotification](https://github.com/Windos/BurntToast/blob/main/Help/Submit-BTNotification.md) diff --git a/Installer/BurntToast.msi b/Installer/BurntToast.msi deleted file mode 100644 index a6c7ed1..0000000 Binary files a/Installer/BurntToast.msi and /dev/null differ diff --git a/Installer/src/BurntToast.ico b/Installer/src/BurntToast.ico deleted file mode 100644 index 2a9cd64..0000000 Binary files a/Installer/src/BurntToast.ico and /dev/null differ diff --git a/Installer/src/BurntToast.png b/Installer/src/BurntToast.png deleted file mode 100644 index aca301b..0000000 Binary files a/Installer/src/BurntToast.png and /dev/null differ diff --git a/Installer/src/BurntToast.wxs b/Installer/src/BurntToast.wxs deleted file mode 100644 index cfd163d..0000000 --- a/Installer/src/BurntToast.wxs +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 4022cde..1ace7ee 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ [![PowerShell Gallery Downloads](https://img.shields.io/powershellgallery/dt/BurntToast.svg)](https://www.powershellgallery.com/packages/BurntToast) [![Open Issues](https://img.shields.io/github/issues-raw/Windos/BurntToast.svg)](https://github.com/Windos/BurntToast/issues) -![BurntToast Logo Banner](/Media/BurntToast-Wide.png) +![BurntToast Logo Banner](/images/BurntToast-Wide.png) -PowerShell Module for displaying **Windows 10** and **Windows Server 2019** Toast Notifications +PowerShell Module for displaying Toast Notifications on **Windows 10** and **Windows Server 2019** and above. ## ❗❗❗ NOTICE ❗❗❗ @@ -19,121 +19,52 @@ BurntToast v1.0.0 will include **numerous** breaking changes and your existing s You can read more about the up coming changes on [ToastIT.dev](https://toastit.dev/tag/burnttoast/) and BurntToast's new [Docs Site](https://docs.toastit.dev/changelog) -## Install - -### PowerShell Gallery Install (Requires PowerShell v5) - -```powershell -Install-Module -Name BurntToast -``` - -See the [PowerShell Gallery](http://www.powershellgallery.com/packages/BurntToast/) for the complete details and instructions. -Don't forget to set the correct [Execution Policy](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.1). - -### Manual Install - -Download [BurntToast.zip](https://github.com/Windos/BurntToast/releases/latest/download/BurntToast.zip) from [Releases page](https://github.com/Windos/BurntToast/releases/latest) and extract the contents into `$env:userprofile\Documents\WindowsPowerShell\modules\BurntToast` (you may have to create these directories if they don't exist.) - -If you are using PowerShell 6 or later, extract into `$env:userprofile\Documents\PowerShell\Modules\BurntToast` - -*Please remember to "**unblock**" the zip file before extracting the contents. Not doing so will result in the module not working correctly. This can be done via the file properties or with `Unblock-File`.* +## ❗❗❗ NOTICE ❗❗❗ -## Examples +BurntToast v1.0.0 will include **numerous** breaking changes and your existing scripts **will not** work without changes. -### [Default Toast](/Examples/Example01/) +**DO NOT** upgrade to BurntToast v1.0.0 until you are ready. -```powershell -New-BurntToastNotification -``` +You can read more about the up coming changes on [ToastIT.dev](https://toastit.dev/tag/burnttoast/) and BurntToast's new [Docs Site](https://docs.toastit.dev/changelog) -![BurntToast Notification Example Default](/Examples/Example01/Example1-Default.png) +## Install -### [Customized Toast](/Examples/Example02/) +### PowerShell Gallery Install ```powershell -New-BurntToastNotification -AppLogo C:\smile.jpg -Text "Don't forget to smile!", - 'Your script ran successfully, celebrate!' +Install-Module -Name BurntToast ``` -![BurntToast Notification Example Custom](/Examples/Example02/Example2-Custom.png) +See the [PowerShell Gallery](http://www.powershellgallery.com/packages/BurntToast/) for the complete details and +instructions. -### [Alarm Clock](/Examples/Example03/) +### Chocolatey ```powershell -New-BurntToastNotification -Text 'WAKE UP!' -Sound 'Alarm2' -SnoozeAndDismiss +choco install burnttoast-psmodule ``` -![BurntToast Notification Example Alarm](/Examples/Example03/Example3-Alarm.png) +See the [Chocolatey community package](https://chocolatey.org/packages/burnttoast-psmodule) for more details. Thanks +[Bill Curran](https://github.com/bcurran3) for maintaining the package. ## Releases -**Please note:** as of v0.5.0, BurntToast no longer works on Windows 8. - -- [0.8.5](https://github.com/Windos/BurntToast/releases/download/v0.8.5/BurntToast.zip) - - - Actually implement the ability to use a UniqueIdentifier with the Remove-BTNotification function (which was half implemented in 0.8.4) - -- [0.8.4](https://github.com/Windos/BurntToast/releases/download/v0.8.4/BurntToast.zip) - - - Enhancement: Header ID on New-BTHeader is now optional. An ID will be auto generated if not specified ([#125](https://github.com/Windos/BurntToast/issues/125)) - - - Thanks [@glennsarti](https://github.com/glennsarti) - - - Enhancement: Hero images can now be specified using the New-BurntToastNotification function using the -HeroImage parameter ([#80](https://github.com/Windos/BurntToast/issues/80)) - - - Thanks [@UniverseCitiz3n](https://github.com/UniverseCitiz3n) - - - Enhancement: AppIDs can now be specified using the New-BurntToastNotification function using the -AppId parameter. - - - Thanks [@cedarbaum](https://github.com/cedarbaum) - - - Enhancement: You can now specify a UniqueIdentifier when using the Remove-BTNotification function rather than component Tag and Group strings. - - - Fix: Weird edge cases when taking text from Twitch/IRC and using them in a toast is now sorted. - - - Thanks [@potatoqualitee](https://github.com/potatoqualitee) and [@vexx32](https://github.com/vexx32) - -- [0.8.3](https://github.com/Windos/BurntToast/releases/download/v0.8.3/BurntToast.zip) - - - Fix: Error when running Update-BTNotification on PowerShell 6.0+ ([#120](https://github.com/Windos/BurntToast/issues/120)) - - - Fix: Error when using actionable toast parameters on any version ([#122](https://github.com/Windos/BurntToast/issues/122)) - - - Fix: Multiple warnings about events not being supported when specifying multiple event types. - -- [v0.8.2](https://github.com/Windos/BurntToast/releases/download/v0.8.2/BurntToast.zip) - - - Add: AdaptiveGroups are now usable via New-BTColumn - -- [v0.8.1](https://github.com/Windos/BurntToast/releases/download/v0.8.1/BurntToast.zip) - - - Fix: Toast alias removed in 0.8.0 has been restored - - - Deprecation: Signalling removal of Shoulder Tap cmdlets in future version, v0.9.0 - - - Deprecation: Signalling removal of Path parameter from New-BTAudio in future version, v0.9.0. - - - See [MicrosoftDocs/windows-uwp Issue #1593](https://github.com/MicrosoftDocs/windows-uwp/issues/1593) - -- [v0.8.0](https://github.com/Windos/BurntToast/releases/download/v0.8.0/BurntToast.zip) - - - Fix: Images from UNC path failing ([#111](https://github.com/Windos/BurntToast/issues/111)) - - - Add: Ability to force a refresh of cached images via IgnoreCache switch on New-BTImage +### [v1.0.0](https://github.com/Windos/BurntToast/releases/download/v1.0.0/BurntToast.zip) - - Add: ACTIONABLE NOTIFICATIONS! Exposed via ActivatedAction and DismissedAction parameters on Submit-BTNotification and New-BurntToastNotification +### Breaking Changes -- [v0.7.2](https://github.com/Windos/BurntToast/releases/download/v0.7.2/BurntToast.zip) +- Shoulder tap notification support has been removed - - Fix: Curly Braces when "Reminder" pops up ([#72](https://github.com/Windos/BurntToast/issues/72)) +### Features - - Fix: Caching remote gifs are saved based on their remote filename and not overwritten ([#105](https://github.com/Windos/BurntToast/issues/105)) +### Improvements - - Thanks [@KelvinTegelaar](https://github.com/KelvinTegelaar) +### Libraries - - Fix: BurntToast and .NET 5 ([#101](https://github.com/Windos/BurntToast/issues/101)) +- Microsoft.Windows.SDK.NET.Ref library bumped to 10.0.22621.28 +- Microsoft.Toolkit.Uwp.Notifications library bumped to 7.1.3 -- see more in the [Full Change Log](CHANGES.md) +### See previous releases in the [Full Change Log](CHANGES.md) ## Contributors @@ -147,13 +78,16 @@ New-BurntToastNotification -Text 'WAKE UP!' -Sound 'Alarm2' -SnoozeAndDismiss ## License -- See [LICENSE](LICENSE) file +- see [LICENSE](LICENSE) file ## Image Credit -The [default image](/Media/BurntToast.png) for BurntToast Notifications is a photo taken by [Craig Sunter](https://www.flickr.com/photos/16210667@N02/17230428864) +The [default image](/images/BurntToast.png) for BurntToast Notifications is a photo taken by +[Craig Sunter](https://www.flickr.com/photos/16210667@N02/17230428864) ## Contact +- Bluesky: [@toastit.dev](https://bsky.app/profile/toastit.dev) +- Mastodon: [@windos@mastodon.nz](https://mastodon.nz/@windos) - Twitter: [@WindosNZ](https://twitter.com/windosnz) - Blog: [ToastIT.dev](https://toastit.dev/) diff --git a/Tasks/BurntToast-Template.psm1 b/Tasks/BurntToast-Template.psm1 index bce268a..28447eb 100644 --- a/Tasks/BurntToast-Template.psm1 +++ b/Tasks/BurntToast-Template.psm1 @@ -1,50 +1,52 @@ -$WinMajorVersion = (Get-CimInstance -ClassName Win32_OperatingSystem -Property Version).Version.Split('.')[0] - -if ($WinMajorVersion -ge 10) { - $Library = @( Get-ChildItem -Path $PSScriptRoot\lib\Microsoft.Toolkit.Uwp.Notifications\*.dll -Recurse -ErrorAction SilentlyContinue ) +$OSVersion = [System.Environment]::OSVersion.Version + +if ($OSVersion.Major -ge 10 -and $null -eq $env:BurntToastPesterNotWindows10) { + if ($OSVersion.Build -ge 15063 -and $null -eq $env:BurntToastPesterNotAnniversaryUpdate) { + $Paths = if ($IsWindows) { + "$PSScriptRoot\lib\Microsoft.Toolkit.Uwp.Notifications\net5.0-windows10.0.17763\*.dll", + "$PSScriptRoot\lib\Microsoft.Windows.SDK.NET\*.dll" + } else { + "$PSScriptRoot\lib\Microsoft.Toolkit.Uwp.Notifications\net461\*.dll" + } - if ($IsWindows) { - $Library += @( Get-ChildItem -Path $PSScriptRoot\lib\Microsoft.Windows.SDK.NET\*.dll -Recurse -ErrorAction SilentlyContinue ) - } + $Library = @( Get-ChildItem -Path $Paths -Recurse -ErrorAction SilentlyContinue ) - # Add one class from each expected DLL here: - $LibraryMap = @{ - 'Microsoft.Toolkit.Uwp.Notifications.dll' = 'Microsoft.Toolkit.Uwp.Notifications.ToastContent' - } + # Add one class from each expected DLL here: + $LibraryMap = @{ + 'Microsoft.Toolkit.Uwp.Notifications.dll' = 'Microsoft.Toolkit.Uwp.Notifications.ToastContent' + 'Microsoft.Windows.SDK.NET.dll' = 'Windows.UI.Notifications.ToastNotification' + 'WinRT.Runtime.dll' = 'WinRT.WindowsRuntimeTypeAttribute' + } - $Script:Config = Get-Content -Path $PSScriptRoot\config.json -ErrorAction SilentlyContinue | ConvertFrom-Json - $Script:DefaultImage = if ($Script:Config.AppLogo -match '^[.\\]') { - "$PSScriptRoot$($Script:Config.AppLogo)" - } else { - $Script:Config.AppLogo - } + $Script:Config = Get-Content -Path $PSScriptRoot\config.json -ErrorAction SilentlyContinue | ConvertFrom-Json + $Script:DefaultImage = if ($Script:Config.AppLogo -match '^[.\\]') { + "$PSScriptRoot$($Script:Config.AppLogo)" + } else { + $Script:Config.AppLogo + } - foreach ($Type in $Library) { - try { - if (-not ($LibraryMap[$Type.Name] -as [type])) { - Add-Type -Path $Type.FullName -ErrorAction Stop + foreach ($Type in $Library) { + try { + if (-not ($LibraryMap[$Type.Name] -as [type])) { + Add-Type -Path $Type.FullName -ErrorAction Stop + } + } catch { + Write-Error -Message "Failed to load library $($Type.FullName): $_" } - } catch { - Write-Error -Message "Failed to load library $($Type.FullName): $_" } - } - - $Script:ActionsSupported = 'System.Management.Automation.SemanticVersion' -as [type] -and - $PSVersionTable.PSVersion -ge [System.Management.Automation.SemanticVersion] '7.1.0-preview.4' - - $Script:UnsupportedEvents = 'Toast events are only supported on PowerShell 7.1.0 and above. ' + - 'Your notification will still be displayed, but the actions will be ignored.' - Export-ModuleMember -Alias 'Toast' - Export-ModuleMember -Function $PublicFunctions + Export-ModuleMember -Alias 'Toast' + Export-ModuleMember -Function $PublicFunctions - # Register default AppId - New-BTAppId - - if (-not $IsWindows) { - $null = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] + if (-not $IsWindows) { + $null = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] + } + } else { + throw 'This version of BurntToast will only work on Windows 10 Creators Update (15063) and above or equivalent Windows Server version. ' + + 'If you would like to use BurntToast on earlier builds, please downgrade to a version of the module below 1.0' } } else { - throw 'This version of BurntToast will only work on Windows 10. If you would like to use BurntToast on Windows 8, please use version 0.4' + throw 'This version of BurntToast will only work on Windows 10 or equivalent Windows Server version. ' + + 'If you would like to use BurntToast on Windows 8, please use version 0.4 of the module' } diff --git a/Tasks/build.ps1 b/Tasks/build.ps1 index e69d7e7..fffc786 100644 --- a/Tasks/build.ps1 +++ b/Tasks/build.ps1 @@ -1,16 +1,10 @@ [CmdletBinding()] param( - [switch] - $Bootstrap, - [switch] $Compile, [switch] - $Test, - - [switch] - $CodeCoverage + $Test ) # Write information @@ -30,28 +24,6 @@ Write-Host '' $RootDir = Join-Path $PSScriptRoot '..' $OutputDir = Join-Path $RootDir 'Output' -# Bootstrap step -if ($Bootstrap.IsPresent) { - Write-Information "Validate and install missing prerequisits for building ..." - - # For testing Pester - if (-not (Get-Module -Name Pester -ListAvailable) -or (Get-Module -Name Pester -ListAvailable)[0].Version -eq [Version]'3.4.0') { - Write-Warning "Module 'Pester' is missing. Installing 'Pester' ..." - Install-Module -Name Pester -Scope CurrentUser -Force -RequiredVersion 4.10.1 -SkipPublisherCheck - } - - if ((Get-Module -Name Pester -ListAvailable)[0].Version -ne [Version]'4.10.1') { - Install-Module -Name Pester -Scope CurrentUser -Force -RequiredVersion 4.10.1 - } - - Import-Module -Name Pester -RequiredVersion 4.10.1 - - if (-not (Get-Module -Name PSCodeCovIo -ListAvailable)) { - Write-Warning "Module 'PSCodeCovIo' is missing. Installing 'PSCodeCovIo' ..." - Install-Module -Name PSCodeCovIo -Scope CurrentUser -Force - } -} - # Compile step if ($Compile.IsPresent) { $CompileDir = Join-Path $OutputDir 'BurntToast' @@ -65,17 +37,17 @@ if ($Compile.IsPresent) { $null = New-Item -Path $CompileDir -ItemType Directory Write-Host "Copying support files ..." - Copy-Item -Path "$RootDir/BurntToast/*" -Filter '*.*' -Exclude '*.ps1', '*.psm1' -Recurse -Destination $CompileDir -Force + Copy-Item -Path "$RootDir/src/*" -Filter '*.*' -Exclude '*.ps1', '*.psm1' -Recurse -Destination $CompileDir -Force Remove-Item -Path "$CompileDir/Private", "$CompileDir/Public" -Recurse -Force # Copy Module README file Copy-Item -Path "$RootDir/README.md" -Destination $CompileDir -Force Write-Host "Adding Private Functions ..." - Get-ChildItem -Path "$RootDir\BurntToast\Private\*.ps1" -Recurse | Get-Content | Add-Content "$CompileDir/BurntToast.psm1" + Get-ChildItem -Path "$RootDir/src/Private/*.ps1" -Recurse | Get-Content | Add-Content "$CompileDir/BurntToast.psm1" Write-Host "Adding Public Functions ..." - $Public = @( Get-ChildItem -Path "$RootDir/BurntToast/Public/*.ps1" -ErrorAction SilentlyContinue ) + $Public = @( Get-ChildItem -Path "$RootDir/src/Public/*.ps1" -ErrorAction SilentlyContinue ) $Public | Get-Content | Add-Content "$CompileDir/BurntToast.psm1" @@ -102,34 +74,25 @@ if ($Compile.IsPresent) { # Test step if ($Test.IsPresent) { - if (-not (Get-Module -Name Pester -ListAvailable)) { - throw "Cannot find the 'Pester' module. Please specify '-Bootstrap' to install build dependencies." - } - - if (-not (Get-Module -Name PSCodeCovIo -ListAvailable)) { - throw "Cannot find the 'PSCodeCovIo' module. Please specify '-Bootstrap' to install build dependencies." - } + Write-Host "Running Pester within CI with code coverage" - if ($ENV:BURNTTOAST_MODULE_ROOT) { - $ModuleDir = (Get-Item -Path $ENV:BURNTTOAST_MODULE_ROOT).Directory.FullName - Write-Host "Using Module Root directory of $ModuleDir" - $RelevantFiles = (Get-ChildItem $ModuleDir -Recurse -Include "*.psm1", "*.ps1").FullName - } else { - $RelevantFiles = (Get-ChildItem ./BurntToast -Recurse -Include "*.psm1", "*.ps1").FullName - } + $PesterConfig = New-PesterConfiguration - if ($env:CI) { - Write-Host "Running Pester within CI with code coverage for $($RelevantFiles.Count) file/s" - $res = Invoke-Pester "./Tests" -OutputFormat JUnitXml -OutputFile TestResults.xml -CodeCoverage $RelevantFiles -CodeCoverageOutputFileFormat 'JaCoCo' -CodeCoverageOutputFile CoverageResults.xml -PassThru - if ($res.FailedCount -gt 0) { throw "$($res.FailedCount) tests failed." } - } - else { - $res = Invoke-Pester "./Tests" -CodeCoverage $RelevantFiles -PassThru - } + $PesterConfig.Run.Path = './tests' + $PesterConfig.Run.PassThru = $true - if ($CodeCoverage.IsPresent) { - Export-CodeCovIoJson -CodeCoverage $res.CodeCoverage -RepoRoot $pwd -Path coverage.json + $PesterConfig.TestResult.Enabled = $true + $PesterConfig.TestResult.OutputFormat = 'JUnitXml' + $PesterConfig.TestResult.OutputPath = 'TestResults.xml' - Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh + if ($null -eq $ENV:BURNTTOAST_MODULE_ROOT) { + $PesterConfig.CodeCoverage.Enabled = $true + $PesterConfig.CodeCoverage.OutputFormat = 'JaCoCo' + $PesterConfig.CodeCoverage.OutputPath = 'CoverageResults.xml' + $PesterConfig.CodeCoverage.Path = './src' + $PesterConfig.CodeCoverage.RecursePaths = $true } + + $res = Invoke-Pester -Configuration $PesterConfig + if ($res.FailedCount -gt 0) { throw "$($res.FailedCount) tests failed." } } diff --git a/Tests/BurntToast.Tests.ps1 b/Tests/BurntToast.Tests.ps1 index 2ef79a3..34734ce 100644 --- a/Tests/BurntToast.Tests.ps1 +++ b/Tests/BurntToast.Tests.ps1 @@ -1,13 +1,58 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'BurntToast Module' { Context 'meta validation' { It 'should import functions' { - (Get-Module BurntToast).ExportedFunctions.Count | Should -Be 25 + (Get-Module BurntToast).ExportedFunctions.Count | Should -Be 20 } It 'should import aliases' { (Get-Module BurntToast).ExportedAliases.Count | Should -Be 1 } } + + Context 'Importing on Unsupported Operating Systems' { + It 'throws when importing on operating systems older than Windows 10' { + $env:BurntToastPesterNotWindows10 = $true + + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + {Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force} | Should -Throw -ExpectedMessage 'This version of BurntToast will only work on Windows 10*' + } else { + {Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force} | Should -Throw -ExpectedMessage 'This version of BurntToast will only work on Windows 10*' + } + } + + It 'throws when importing on Windows 10 builds older than the Anniversary Update' { + $env:BurntToastPesterNotAnniversaryUpdate = $true + + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + {Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force} | Should -Throw -ExpectedMessage 'This version of BurntToast will only work on Windows 10 Creators Update (15063) and above*' + } else { + {Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force} | Should -Throw -ExpectedMessage 'This version of BurntToast will only work on Windows 10 Creators Update (15063) and above*' + } + } + + AfterEach { + $env:BurntToastPesterNotWindows10 = $null + $env:BurntToastPesterNotAnniversaryUpdate = $null + } + } } diff --git a/Tests/Get-BTHeader.Tests.ps1 b/Tests/Get-BTHeader.Tests.ps1 index dc3ef79..06d67db 100644 --- a/Tests/Get-BTHeader.Tests.ps1 +++ b/Tests/Get-BTHeader.Tests.ps1 @@ -1,14 +1,21 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') - -# Helper function needs to be in the global scope so it can be used in mocks -# Note - This may not work in Pester 5+ -Function Global:New-MockNotification( - $HeaderId = (New-GUID).ToString(), - $HeaderTitle = (New-GUID).ToString(), - $HeaderArguments = '', - $HeaderActivation = 'protocol' - ) { - $Content = @" +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } + + Function Global:New-MockNotification( + $HeaderId = (New-GUID).ToString(), + $HeaderTitle = (New-GUID).ToString(), + $HeaderArguments = '', + $HeaderActivation = 'protocol' + ) { + $Content = @" @@ -20,9 +27,10 @@ Function Global:New-MockNotification(
"@ - $XMLContent = [Windows.Data.Xml.Dom.XmlDocument]::new() - $XmlContent.LoadXml($Content) - [Windows.UI.Notifications.ToastNotification]::new($XMLContent) + $XMLContent = [Windows.Data.Xml.Dom.XmlDocument]::new() + $XmlContent.LoadXml($Content) + [Windows.UI.Notifications.ToastNotification]::new($XMLContent) + } } Describe 'Get-BTHeader' { @@ -36,14 +44,16 @@ Describe 'Get-BTHeader' { } Context 'With multiple duplicate notifications' { - Mock Get-BTHistory -ModuleName BurntToast -Verifiable -ParameterFilter { $ScheduledToast } { - New-MockNotification -HeaderId 'ID01' - New-MockNotification -HeaderId 'ID01' - } - - Mock Get-BTHistory -ModuleName BurntToast -Verifiable -ParameterFilter { -not $ScheduledToast } { - New-MockNotification -HeaderId 'ID01' - New-MockNotification -HeaderId 'ID01' + BeforeAll { + Mock Get-BTHistory -ModuleName BurntToast -Verifiable -ParameterFilter { $ScheduledToast } { + New-MockNotification -HeaderId 'ID01' + New-MockNotification -HeaderId 'ID01' + } + + Mock Get-BTHistory -ModuleName BurntToast -Verifiable -ParameterFilter { -not $ScheduledToast } { + New-MockNotification -HeaderId 'ID01' + New-MockNotification -HeaderId 'ID01' + } } It 'should ignore duplicate headers' { @@ -55,14 +65,16 @@ Describe 'Get-BTHeader' { } Context 'With multiple unique notifications' { - Mock Get-BTHistory -ModuleName BurntToast -Verifiable -ParameterFilter { $ScheduledToast } { - New-MockNotification -HeaderId 'ID01' -HeaderTitle 'Title 01' - New-MockNotification -HeaderId 'ID02' -HeaderTitle 'Title 02' - } - - Mock Get-BTHistory -ModuleName BurntToast -Verifiable -ParameterFilter { -not $ScheduledToast } { - New-MockNotification -HeaderId 'ID03' -HeaderTitle 'Title 03' - New-MockNotification -HeaderId 'ID04' + BeforeAll { + Mock Get-BTHistory -ModuleName BurntToast -Verifiable -ParameterFilter { $ScheduledToast } { + New-MockNotification -HeaderId 'ID01' -HeaderTitle 'Title 01' + New-MockNotification -HeaderId 'ID02' -HeaderTitle 'Title 02' + } + + Mock Get-BTHistory -ModuleName BurntToast -Verifiable -ParameterFilter { -not $ScheduledToast } { + New-MockNotification -HeaderId 'ID03' -HeaderTitle 'Title 03' + New-MockNotification -HeaderId 'ID04' + } } It 'should return all headers' { @@ -101,8 +113,10 @@ Describe 'Get-BTHeader' { } Context 'With a single unique notifications' { - Mock Get-BTHistory -ModuleName BurntToast -Verifiable -ParameterFilter { $ScheduledToast } { - New-MockNotification -HeaderId 'ID01' -HeaderTitle 'Title 01' -HeaderArguments 'arguments' -HeaderProtocol 'protocol' + BeforeAll { + Mock Get-BTHistory -ModuleName BurntToast -Verifiable -ParameterFilter { $ScheduledToast } { + New-MockNotification -HeaderId 'ID01' -HeaderTitle 'Title 01' -HeaderArguments 'arguments' -HeaderProtocol 'protocol' + } } It 'should return all header properties' { diff --git a/Tests/Get-BTHistory.Tests.ps1 b/Tests/Get-BTHistory.Tests.ps1 index 0ae3dbc..8298261 100644 --- a/Tests/Get-BTHistory.Tests.ps1 +++ b/Tests/Get-BTHistory.Tests.ps1 @@ -1,33 +1,16 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') - -Describe 'Get-BTHistory' { - if ($PlatformAvailable) { - Context 'valid AppId, one previous toast' { - Mock Test-Path { $true } -ModuleName BurntToast -Verifiable -ParameterFilter { - $Path -eq 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe' - } - - It 'should not throw' { - { Get-BTHistory } | Should -Not -Throw - } - - It 'tested the correct path' { - Assert-VerifiableMock - } - } +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' } - Context 'invalid AppId' { - Mock Test-Path { $false } -ModuleName BurntToast -Verifiable -ParameterFilter { - $Path -eq 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Script Checker' - } - - It 'should throw' { - { Get-BTHistory -AppId 'Script Checker' } | Should -Throw "The AppId Script Checker is not present in the registry, please run New-BTAppId to avoid inconsistent Toast behaviour." - } + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} - It 'tested the correct path' { - Assert-VerifiableMock - } +Describe 'Get-BTHistory' { + if ($PlatformAvailable) { } } diff --git a/Tests/New-BTAction.Tests.ps1 b/Tests/New-BTAction.Tests.ps1 index 60b462e..21d5850 100644 --- a/Tests/New-BTAction.Tests.ps1 +++ b/Tests/New-BTAction.Tests.ps1 @@ -1,88 +1,120 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTAction' { Context 'running without arguments' { - Start-Transcript tmp.log - try { - New-BTAction -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTAction -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTAction" on target "returning: [ToastActionsCustom] with 0 Inputs, 0 Buttons, and 0 ContextMenuItems".' $Log | Should -Be $Expected } } + Context 'snooze and dismiss modal' { - Start-Transcript tmp.log - try { - New-BTAction -SnoozeAndDismiss -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTAction -SnoozeAndDismiss -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTAction" on target "returning: [ToastActionsSnoozeAndDismiss] with 0 Inputs, 0 Buttons, and 0 ContextMenuItems".' $Log | Should -Be $Expected } } + Context 'single clickable button' { - Start-Transcript tmp.log - try { - New-BTAction -Buttons (New-BTButton -Content 'Google' -Arguments 'https://google.com') -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTAction -Buttons (New-BTButton -Content 'Google' -Arguments 'https://google.com') -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTAction" on target "returning: [ToastActionsCustom] with 0 Inputs, 1 Buttons, and 0 ContextMenuItems".' $Log | Should -Be $Expected } } + Context 'mixed content: button & context menu' { - $Button = New-BTButton -Content 'Google' -Arguments 'https://google.com' - $ContextMenuItem = New-BTContextMenuItem -Content 'Bing' -Arguments 'https://bing.com' + BeforeAll { + $Button = New-BTButton -Content 'Google' -Arguments 'https://google.com' + $ContextMenuItem = New-BTContextMenuItem -Content 'Bing' -Arguments 'https://bing.com' - Start-Transcript tmp.log - try { - New-BTAction -Buttons $Button -ContextMenuItems $ContextMenuItem -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + Start-Transcript tmp.log + try { + New-BTAction -Buttons $Button -ContextMenuItems $ContextMenuItem -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTAction" on target "returning: [ToastActionsCustom] with 0 Inputs, 1 Buttons, and 1 ContextMenuItems".' $Log | Should -Be $Expected } } + Context 'including too many buttons and or context menu items' { - $Button = New-BTButton -Content 'Google' -Arguments 'https://google.com' - $ContextMenuItem = New-BTContextMenuItem -Content 'Bing' -Arguments 'https://bing.com' + BeforeAll { + $Button = New-BTButton -Content 'Google' -Arguments 'https://google.com' + $ContextMenuItem = New-BTContextMenuItem -Content 'Bing' -Arguments 'https://bing.com' + } it 'throws when providing too poolable items' { - { $Button = New-BTButton -Content 'Google' -Arguments 'https://google.com'; $ContextMenuItem = New-BTContextMenuItem -Content 'Bing' -Arguments 'https://bing.com'; New-BTAction -Buttons $Button, $Button, $Button, $Button, $Button -ContextMenuItems $ContextMenuItem } | Should Throw 'You have included too many buttons and context menu items. The maximum combined number of these elements is five.' + { $Button = New-BTButton -Content 'Google' -Arguments 'https://google.com'; $ContextMenuItem = New-BTContextMenuItem -Content 'Bing' -Arguments 'https://bing.com'; New-BTAction -Buttons $Button, $Button, $Button, $Button, $Button -ContextMenuItems $ContextMenuItem } | Should -Throw 'You have included too many buttons and context menu items. The maximum combined number of these elements is five.' } } + Context 'input objects' { - Start-Transcript tmp.log - try { - $Input1 = New-BTInput -Id Reply001 -Title 'Type a reply:' - New-BTAction -Inputs $Input1 -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + $Input1 = New-BTInput -Id Reply001 -Title 'Type a reply:' + New-BTAction -Inputs $Input1 -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTAction" on target "returning: [ToastActionsCustom] with 1 Inputs, 0 Buttons, and 0 ContextMenuItems".' $Log | Should -Be $Expected diff --git a/Tests/New-BTAppId.Tests.ps1 b/Tests/New-BTAppId.Tests.ps1 deleted file mode 100644 index 62d952b..0000000 --- a/Tests/New-BTAppId.Tests.ps1 +++ /dev/null @@ -1,42 +0,0 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') - -Describe 'New-BTAppId' { - Mock New-Item {} -ModuleName BurntToast - Mock New-ItemProperty {} -ModuleName BurntToast - - Context 'executing when AppId already exists' { - Mock Test-Path { $true } -ModuleName BurntToast -Verifiable -ParameterFilter { - $Path -eq 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe' - } - - New-BTAppId - - It 'tested the correct path' { - Assert-VerifiableMock - } - It 'should not have called cmdlet: New-Item' { - Assert-MockCalled New-Item -Time 0 -Exactly -Scope Context -ModuleName BurntToast - } - It 'should not have called cmdlet: New-Item' { - Assert-MockCalled New-ItemProperty -Time 0 -Exactly -Scope Context -ModuleName BurntToast - } - } - - Context 'executing when AppId is unique' { - Mock Test-Path { $false } -ModuleName BurntToast -Verifiable -ParameterFilter { - $Path -eq 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Script Checker' - } - - New-BTAppId -AppId 'Script Checker' - - It 'tested the correct path' { - Assert-VerifiableMock - } - It 'should have called cmdlet: New-Item' { - Assert-MockCalled New-Item -Time 1 -Exactly -Scope Context -ModuleName BurntToast - } - It 'should have called cmdlet: New-Item' { - Assert-MockCalled New-ItemProperty -Time 1 -Exactly -Scope Context -ModuleName BurntToast - } - } -} diff --git a/Tests/New-BTAudio.Tests.ps1 b/Tests/New-BTAudio.Tests.ps1 index d09bf63..e87cf8a 100644 --- a/Tests/New-BTAudio.Tests.ps1 +++ b/Tests/New-BTAudio.Tests.ps1 @@ -1,57 +1,51 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTAudio' { Context 'built in audio source' { - Start-Transcript tmp.log - try { - New-BTAudio -Source ms-winsoundevent:Notification.SMS -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTAudio -Source ms-winsoundevent:Notification.SMS -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTAudio" on target "returning: [ToastAudio]:Src=ms-winsoundevent:Notification.SMS:Loop=False:Silent=False".' $Log | Should -Be $Expected } } - Context 'custom audio source' { - Start-Transcript tmp.log - try { - New-BTAudio -Path 'C:\Windows\media\tada.wav' -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log - } - It 'has consitent WhatIf response' { - $Expected = 'What if: Performing the operation "New-BTAudio" on target "returning: [ToastAudio]:Src=file:///C:/Windows/media/tada.wav:Loop=False:Silent=False".' - $Log | Should -Be $Expected - } - } + Context 'Silent switch' { - Start-Transcript tmp.log - try { - New-BTAudio -Silent -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTAudio -Silent -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTAudio" on target "returning: [ToastAudio]:Src=:Loop=False:Silent=True".' $Log | Should -Be $Expected } } - Context 'input validation' { - It 'throws if audio file doesn''t exist' { - { New-BTAudio -Path 'C:\Fake\phantom.wav' } | Should -Throw "The file 'C:\Fake\phantom.wav' doesn't exist in the specified location. Please provide a valid path and try again." - } - It 'throws if the extension is not supported' { - { New-BTAudio -Path 'C:\Fake\phantom.mov' } | Should -Throw "The file extension '.mov' is not supported. Please provide a valid path and try again." - } - } } diff --git a/Tests/New-BTBinding.Tests.ps1 b/Tests/New-BTBinding.Tests.ps1 index 851c0aa..e26e80d 100644 --- a/Tests/New-BTBinding.Tests.ps1 +++ b/Tests/New-BTBinding.Tests.ps1 @@ -1,24 +1,37 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTBinding' { Context 'loaded with children' { - $Text1 = New-BTText -Content 'This is a test' - $Text2 = New-BTText - $Text3 = New-BTText -Content 'This more testing' - $Progress = New-BTProgressBar -Title 'Things are happening' -Status 'Working on it' -Value 0.01 - $Image1 = New-BTImage -Source $PSScriptRoot\..\Media\BurntToast.png - $Image2 = New-BTImage -Source $PSScriptRoot\..\Media\BurntToast.png -AppLogoOverride -Crop Circle - $Image3 = New-BTImage -Source $PSScriptRoot\..\Media\BurntToast.png -HeroImage + BeforeAll { + $Text1 = New-BTText -Content 'This is a test' + $Text2 = New-BTText + $Text3 = New-BTText -Content 'This more testing' + $Progress = New-BTProgressBar -Title 'Things are happening' -Status 'Working on it' -Value 0.01 + $Image1 = New-BTImage -Source $PSScriptRoot\..\Media\BurntToast.png + $Image2 = New-BTImage -Source $PSScriptRoot\..\Media\BurntToast.png -AppLogoOverride -Crop Circle + $Image3 = New-BTImage -Source $PSScriptRoot\..\Media\BurntToast.png -HeroImage - Start-Transcript tmp.log - try { - New-BTBinding -Children $Text1, $Text2, $Text3, $Image1, $Progress -AppLogoOverride $Image2 -HeroImage $Image3 -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + Start-Transcript tmp.log + try { + New-BTBinding -Children $Text1, $Text2, $Text3, $Image1, $Progress -AppLogoOverride $Image2 -HeroImage $Image3 -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BTBinding"" on target ""returning: [ToastBindingGeneric]:Children=5:AddImageQuery=0:AppLogoOverride=1:Attribution=0:BaseUri=0:HeroImage=1:Language=0""." $Log | Should -Be $Expected diff --git a/Tests/New-BTButton.Tests.ps1 b/Tests/New-BTButton.Tests.ps1 index e262f2b..142f5f9 100644 --- a/Tests/New-BTButton.Tests.ps1 +++ b/Tests/New-BTButton.Tests.ps1 @@ -1,62 +1,87 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTButton' { Context 'system defined dismiss button' { - Start-Transcript tmp.log - try { - New-BTButton -Dismiss -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTButton -Dismiss -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTButton" on target "returning: [ToastButtonDismiss]:CustomContent=:ImageUri=".' $Log | Should -Be $Expected } } + Context 'system defined snooze button' { - Start-Transcript tmp.log - try { - New-BTButton -Snooze -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTButton -Snooze -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTButton" on target "returning: [ToastButtonSnooze]:CustomContent=:ImageUri=:SelectionBoxId=".' $Log | Should -Be $Expected } } + Context 'custom button with text' { - Start-Transcript tmp.log - try { - New-BTButton -Content 'Blog' -Arguments 'https://king.geek.nz' -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTButton -Content 'Blog' -Arguments 'https://king.geek.nz' -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTButton" on target "returning: [ToastButton]:Content=Blog:Arguments=https://king.geek.nz:ActivationType=Protocol:ImageUri=:TextBoxId=".' $Log | Should -Be $Expected } } + Context 'custom button with image' { - Start-Transcript tmp.log - try { - $Picture = "$PSScriptRoot\..\Media\BurntToast.png" - New-BTButton -Content 'View Picture' -Arguments $Picture -ImageUri $Picture -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + $Picture = "$PSScriptRoot\..\Media\BurntToast.png" + New-BTButton -Content 'View Picture' -Arguments $Picture -ImageUri $Picture -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BTButton"" on target ""returning: [ToastButton]:Content=View Picture:Arguments=$PSScriptRoot\..\Media\BurntToast.png:ActivationType=Protocol:ImageUri=$PSScriptRoot\..\Media\BurntToast.png:TextBoxId=""." $Log | Should -Be $Expected diff --git a/Tests/New-BTColumn.Tests.ps1 b/Tests/New-BTColumn.Tests.ps1 index 26a72c6..f3ca01d 100644 --- a/Tests/New-BTColumn.Tests.ps1 +++ b/Tests/New-BTColumn.Tests.ps1 @@ -1,64 +1,81 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTColumn' { Context 'via New-BurntToastNotification' { - $ModuleRoot = (Get-Item (Get-Module 'BurntToast').Path).Directory.FullName - $ImagePath = Resolve-Path -Path (Join-Path $ModuleRoot 'Images\BurntToast.png') + BeforeAll { + $ModuleRoot = (Get-Item (Get-Module 'BurntToast').Path).Directory.FullName + $ImagePath = Resolve-Path -Path (Join-Path $ModuleRoot 'Images\BurntToast.png') - Start-Transcript tmp.log - try { - $TitleLabel = New-BTText -Text 'Title:' -Style Base - $AlbumLabel = New-BTText -Text 'Album:' -Style Base - $ArtistLabel = New-BTText -Text 'Artist:' -Style Base + Start-Transcript tmp.log + try { + $TitleLabel = New-BTText -Text 'Title:' -Style Base + $AlbumLabel = New-BTText -Text 'Album:' -Style Base + $ArtistLabel = New-BTText -Text 'Artist:' -Style Base - $Title = New-BTText -Text 'soft focus' -Style BaseSubtle - $Album = New-BTText -Text 'Birocratic' -Style BaseSubtle - $Artist = New-BTText -Text 'beets 4 (2017)' -Style BaseSubtle + $Title = New-BTText -Text 'soft focus' -Style BaseSubtle + $Album = New-BTText -Text 'Birocratic' -Style BaseSubtle + $Artist = New-BTText -Text 'beets 4 (2017)' -Style BaseSubtle - $Column1 = New-BTColumn -Children $TitleLabel, $AlbumLabel, $ArtistLabel -Weight 4 - $Column2 = New-BTColumn -Children $Title, $Album, $Artist -Weight 6 + $Column1 = New-BTColumn -Children $TitleLabel, $AlbumLabel, $ArtistLabel -Weight 4 + $Column2 = New-BTColumn -Children $Title, $Album, $Artist -Weight 6 - New-BurntToastNotification -Text 'Now Playing' -Column $Column1, $Column2 -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + New-BurntToastNotification -Text 'Now Playing' -Column $Column1, $Column2 -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BurntToastNotification"" on target ""submitting: {Now Playing}{Title:}{Album:}{Artist:}{soft focus}{Birocratic}{beets 4 (2017)}""." $Log | Should -Be $Expected } } + Context 'via Submit-BTNotification' { - Start-Transcript tmp.log - try { - $HeadingText = New-BTText -Text 'Now Playing' + BeforeAll { + Start-Transcript tmp.log + try { + $HeadingText = New-BTText -Text 'Now Playing' - $TitleLabel = New-BTText -Text 'Title:' -Style Base - $AlbumLabel = New-BTText -Text 'Album:' -Style Base - $ArtistLabel = New-BTText -Text 'Artist:' -Style Base + $TitleLabel = New-BTText -Text 'Title:' -Style Base + $AlbumLabel = New-BTText -Text 'Album:' -Style Base + $ArtistLabel = New-BTText -Text 'Artist:' -Style Base - $Title = New-BTText -Text 'soft focus' -Style BaseSubtle - $Album = New-BTText -Text 'Birocratic' -Style BaseSubtle - $Artist = New-BTText -Text 'beets 4 (2017)' -Style BaseSubtle + $Title = New-BTText -Text 'soft focus' -Style BaseSubtle + $Album = New-BTText -Text 'Birocratic' -Style BaseSubtle + $Artist = New-BTText -Text 'beets 4 (2017)' -Style BaseSubtle - $Column1 = New-BTColumn -Children $TitleLabel, $AlbumLabel, $ArtistLabel -Weight 4 - $Column2 = New-BTColumn -Children $Title, $Album, $Artist -Weight 6 + $Column1 = New-BTColumn -Children $TitleLabel, $AlbumLabel, $ArtistLabel -Weight 4 + $Column2 = New-BTColumn -Children $Title, $Album, $Artist -Weight 6 - $Binding1 = New-BTBinding -Children $HeadingText -Column $Column1, $Column2 - $Visual1 = New-BTVisual -BindingGeneric $Binding1 - $Content1 = New-BTContent -Visual $Visual1 + $Binding1 = New-BTBinding -Children $HeadingText -Column $Column1, $Column2 + $Visual1 = New-BTVisual -BindingGeneric $Binding1 + $Content1 = New-BTContent -Visual $Visual1 - Submit-BTNotification -Content $Content1 -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + Submit-BTNotification -Content $Content1 -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { - $Expected = 'What if: Performing the operation "Submit-BTNotification" on target "submitting: [ToastNotification] with AppId {1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe, Id , Sequence Number and XML: {Now Playing}{Title:}{Album:}{Artist:}{soft focus}{Birocratic}{beets 4 (2017)}".' + $Expected = 'What if: Performing the operation "Submit-BTNotification" on target "submitting: [ToastNotification] with Id , Sequence Number and XML: {Now Playing}{Title:}{Album:}{Artist:}{soft focus}{Birocratic}{beets 4 (2017)}".' $Log | Should -Be $Expected } } diff --git a/Tests/New-BTContent.Tests.ps1 b/Tests/New-BTContent.Tests.ps1 index 50634e2..f5d5e0f 100644 --- a/Tests/New-BTContent.Tests.ps1 +++ b/Tests/New-BTContent.Tests.ps1 @@ -1,6 +1,14 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } -Describe 'New-BTContent' { $ModuleRoot = (Get-Item (Get-Module 'BurntToast').Path).Directory.FullName $ImagePath = Resolve-Path -Path (Join-Path $ModuleRoot 'Images\BurntToast.png') @@ -9,32 +17,41 @@ Describe 'New-BTContent' { $Image2 = New-BTImage -Source $ImagePath -AppLogoOverride -Crop Circle $Binding1 = New-BTBinding -Children $Text1, $Text2 -AppLogoOverride $Image2 $Visual1 = New-BTVisual -BindingGeneric $Binding1 +} +Describe 'New-BTContent' { Context 'loaded with children' { - Start-Transcript tmp.log - try { - New-BTContent -Visual $Visual1 -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTContent -Visual $Visual1 -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BTContent"" on target ""returning: [ToastContent] with XML: {This is a test}{This more testing}""." $Log | Should -Be $Expected } } + Context 'built in activation' { - Start-Transcript tmp.log - try { - New-BTContent -Visual $Visual1 -ActivationType Protocol -Launch 'https://google.com' -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTContent -Visual $Visual1 -ActivationType Protocol -Launch 'https://google.com' -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BTContent"" on target ""returning: [ToastContent] with XML: {This is a test}{This more testing}""." $Log | Should -Be $Expected diff --git a/Tests/New-BTContextMenuItem.Tests.ps1 b/Tests/New-BTContextMenuItem.Tests.ps1 index 7d9f3c0..c09bac0 100644 --- a/Tests/New-BTContextMenuItem.Tests.ps1 +++ b/Tests/New-BTContextMenuItem.Tests.ps1 @@ -1,16 +1,29 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTContextMenuItem' { Context 'loaded with standard arguments' { - Start-Transcript tmp.log - try { - New-BTContextMenuItem -Content 'Google' -Arguments 'https://google.com' -ActivationType Protocol -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTContextMenuItem -Content 'Google' -Arguments 'https://google.com' -ActivationType Protocol -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTContextMenuItem" on target "returning: [ToastContextMenuItem]:Content=Google:Arguments=https://google.com:ActivationType=Protocol".' $Log | Should -Be $Expected diff --git a/Tests/New-BTHeader.Tests.ps1 b/Tests/New-BTHeader.Tests.ps1 index 7e44bcc..de98dad 100644 --- a/Tests/New-BTHeader.Tests.ps1 +++ b/Tests/New-BTHeader.Tests.ps1 @@ -1,16 +1,29 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTHeader' { Context 'loaded with standard arguments' { - Start-Transcript tmp.log - try { - New-BTHeader -Id 'primary header' -Title 'First Category' -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTHeader -Id 'primary header' -Title 'First Category' -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTHeader" on target "returning: [ToastHeader]:Id=primary header:Title=First Category:Arguments=:ActivationType=Protocol".' $Log | Should -Be $Expected @@ -18,15 +31,18 @@ Describe 'New-BTHeader' { } Context 'loaded without Id' { - Start-Transcript tmp.log - try { - New-BTHeader -Title 'First Category' -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTHeader -Title 'First Category' -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'generates an Id' { $Expected = 'Id=[a-zA-Z\d]+:Title' $Log | Should -Match $Expected @@ -34,15 +50,18 @@ Describe 'New-BTHeader' { } Context 'clickable header text' { - Start-Transcript tmp.log - try { - New-BTHeader -Id '001' -Title 'Stack Overflow Questions' -Arguments 'http://stackoverflow.com/' -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTHeader -Id '001' -Title 'Stack Overflow Questions' -Arguments 'http://stackoverflow.com/' -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTHeader" on target "returning: [ToastHeader]:Id=001:Title=Stack Overflow Questions:Arguments=http://stackoverflow.com/:ActivationType=Protocol".' $Log | Should -Be $Expected diff --git a/Tests/New-BTImage.Tests.ps1 b/Tests/New-BTImage.Tests.ps1 index b6f9a07..476b768 100644 --- a/Tests/New-BTImage.Tests.ps1 +++ b/Tests/New-BTImage.Tests.ps1 @@ -1,64 +1,89 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } -Describe 'New-BTImage' { $ModuleRoot = (Get-Item (Get-Module 'BurntToast').Path).Directory.FullName $ImagePath = Resolve-Path -Path (Join-Path $ModuleRoot 'Images\BurntToast.png') +} +Describe 'New-BTImage' { Context 'standard image' { - Start-Transcript tmp.log - try { - New-BTImage -Source $ImagePath -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTImage -Source $ImagePath -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BTImage"" on target ""returning: [AdaptiveImage]:Source=$($ImagePath):AlternateText=:HintCrop=Default:HintRemoveMargin=False:HintAlign=Default:AddImageQuery=""." $Log | Should -Be $Expected } } + Context 'application logo override' { - Start-Transcript tmp.log - try { - New-BTImage -Source $ImagePath -AppLogoOverride -Crop Circle -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTImage -Source $ImagePath -AppLogoOverride -Crop Circle -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BTImage"" on target ""returning: [ToastGenericAppLogo]:Source=$($ImagePath):AlternateText=:HintCrop=Circle:AddImageQuery=""." $Log | Should -Be $Expected } } + Context 'hero image' { - Start-Transcript tmp.log - try { - New-BTImage -Source $ImagePath -HeroImage -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTImage -Source $ImagePath -HeroImage -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BTImage"" on target ""returning: [ToastGenericHeroImage]:Source=$($ImagePath):AlternateText=:AddImageQuery=""." $Log | Should -Be $Expected } } + Context 'web based image' { - Start-Transcript tmp.log - try { - New-BTImage -Source https://raw.githubusercontent.com/Windos/BurntToast/main/Media/BurntToast.png -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTImage -Source https://raw.githubusercontent.com/Windos/BurntToast/main/Media/BurntToast.png -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BTImage"" on target ""returning: [AdaptiveImage]:Source=$($env:TEMP)\https---raw.githubusercontent.com-Windos-BurntToast-main-Media-BurntToast.png:AlternateText=:HintCrop=Default:HintRemoveMargin=False:HintAlign=Default:AddImageQuery=""." $Log | Should -Be $Expected diff --git a/Tests/New-BTInput.Tests.ps1 b/Tests/New-BTInput.Tests.ps1 index 2faf1df..cb98693 100644 --- a/Tests/New-BTInput.Tests.ps1 +++ b/Tests/New-BTInput.Tests.ps1 @@ -1,36 +1,53 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTInput' { Context 'text entry box' { - Start-Transcript tmp.log - try { - New-BTInput -Id Reply001 -Title 'Type a reply:' -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTInput -Id Reply001 -Title 'Type a reply:' -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTInput" on target "returning: [ToastTextBox]:Id=Reply001:Title=Type a reply::PlaceholderContent=:DefaultInput=".' $Log | Should -Be $Expected } } + Context 'selection box with five options' { - $Select1 = New-BTSelectionBoxItem -Id 'Item1' -Content 'First option in the list' - $Select2 = New-BTSelectionBoxItem -Id 'Item2' -Content 'Second option in the list' - $Select3 = New-BTSelectionBoxItem -Id 'Item3' -Content 'Third option in the list' - $Select4 = New-BTSelectionBoxItem -Id 'Item4' -Content 'Fourth option in the list' - $Select5 = New-BTSelectionBoxItem -Id 'Item5' -Content 'Fifth option in the list' - Start-Transcript tmp.log - try { - New-BTInput -Id 'Selection001' -DefaultSelectionBoxItemId 'Item5' -Items $Select1, $Select2, $Select3, $Select4, $Select5 -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + $Select1 = New-BTSelectionBoxItem -Id 'Item1' -Content 'First option in the list' + $Select2 = New-BTSelectionBoxItem -Id 'Item2' -Content 'Second option in the list' + $Select3 = New-BTSelectionBoxItem -Id 'Item3' -Content 'Third option in the list' + $Select4 = New-BTSelectionBoxItem -Id 'Item4' -Content 'Fourth option in the list' + $Select5 = New-BTSelectionBoxItem -Id 'Item5' -Content 'Fifth option in the list' + Start-Transcript tmp.log + try { + New-BTInput -Id 'Selection001' -DefaultSelectionBoxItemId 'Item5' -Items $Select1, $Select2, $Select3, $Select4, $Select5 -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTInput" on target "returning: [ToastSelectionBox]:Id=Selection001:Title=:DefaultSelectionBoxItemId=Item5:DefaultInput=5".' $Log | Should -Be $Expected diff --git a/Tests/New-BTProgressBar.Tests.ps1 b/Tests/New-BTProgressBar.Tests.ps1 index c13c8ae..deee1de 100644 --- a/Tests/New-BTProgressBar.Tests.ps1 +++ b/Tests/New-BTProgressBar.Tests.ps1 @@ -1,61 +1,86 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTProgressBar' { Context 'fixed value and status' { - Start-Transcript tmp.log - try { - New-BTProgressBar -Status 'Copying files' -Value 0.2 -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTProgressBar -Status 'Copying files' -Value 0.2 -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTProgressBar" on target "returning: [AdaptiveProgressBar]:Status=Copying files:Title=:Value=0.2:ValueStringOverride=".' $Log | Should -Be $Expected } } + Context 'indeterminate progress' { - Start-Transcript tmp.log - try { - New-BTProgressBar -Status 'Copying files' -Indeterminate -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTProgressBar -Status 'Copying files' -Indeterminate -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTProgressBar" on target "returning: [AdaptiveProgressBar]:Status=Copying files:Title=:Value=indeterminate:ValueStringOverride=".' $Log | Should -Be $Expected } } + Context 'custom value display override' { - Start-Transcript tmp.log - try { - New-BTProgressBar -Status 'Copying files' -Value 0.2 -ValueDisplay '4/20 files complete' -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTProgressBar -Status 'Copying files' -Value 0.2 -ValueDisplay '4/20 files complete' -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTProgressBar" on target "returning: [AdaptiveProgressBar]:Status=Copying files:Title=:Value=0.2:ValueStringOverride=4/20 files complete".' $Log | Should -Be $Expected } } + Context 'with title' { - Start-Transcript tmp.log - try { - New-BTProgressBar -Title 'File Copy' -Status 'Copying files' -Value 0.2 -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTProgressBar -Title 'File Copy' -Status 'Copying files' -Value 0.2 -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTProgressBar" on target "returning: [AdaptiveProgressBar]:Status=Copying files:Title=File Copy:Value=0.2:ValueStringOverride=".' $Log | Should -Be $Expected diff --git a/Tests/New-BTSelectionBoxItem.Tests.ps1 b/Tests/New-BTSelectionBoxItem.Tests.ps1 index 7d5514b..c6b9967 100644 --- a/Tests/New-BTSelectionBoxItem.Tests.ps1 +++ b/Tests/New-BTSelectionBoxItem.Tests.ps1 @@ -1,16 +1,29 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTSelectionBoxItem' { Context 'loaded with standard arguments' { - Start-Transcript tmp.log - try { - New-BTSelectionBoxItem -Id 'Item1' -Content 'First option in the list' -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTSelectionBoxItem -Id 'Item1' -Content 'First option in the list' -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTSelectionBoxItem" on target "returning: [ToastSelectionBoxItem]:Id=Item1:Content=First option in the list".' $Log | Should -Be $Expected diff --git a/Tests/New-BTText.Tests.ps1 b/Tests/New-BTText.Tests.ps1 index c3999fa..7abd601 100644 --- a/Tests/New-BTText.Tests.ps1 +++ b/Tests/New-BTText.Tests.ps1 @@ -1,31 +1,48 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } +} Describe 'New-BTText' { Context 'blank line' { - Start-Transcript tmp.log - try { - New-BTText -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTText -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTText" on target "returning: [AdaptiveText]:Text=:HintMaxLines=:HintMinLines=:HintWrap=:HintAlign=Default:HintStyle=Default:Language=".' $Log | Should -Be $Expected } } + Context 'with content' { - Start-Transcript tmp.log - try { - New-BTText -Content 'This is a line with text!' -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTText -Content 'This is a line with text!' -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTText" on target "returning: [AdaptiveText]:Text=This is a line with text!:HintMaxLines=:HintMinLines=:HintWrap=:HintAlign=Default:HintStyle=Default:Language=".' $Log | Should -Be $Expected diff --git a/Tests/New-BTVisual.Tests.ps1 b/Tests/New-BTVisual.Tests.ps1 index 395224f..30489d7 100644 --- a/Tests/New-BTVisual.Tests.ps1 +++ b/Tests/New-BTVisual.Tests.ps1 @@ -1,19 +1,32 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } -Describe 'New-BTVisual' { $Text1 = New-BTText -Content 'This is a test' $Binding1 = New-BTBinding -Children $Text1 +} +Describe 'New-BTVisual' { Context 'accept binding, create visual' { - Start-Transcript tmp.log - try { - New-BTVisual -BindingGeneric $Binding1 -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BTVisual -BindingGeneric $Binding1 -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = 'What if: Performing the operation "New-BTVisual" on target "returning: [ToastVisual]:BindingGeneric=1:BaseUri=:Language=".' $Log | Should -Be $Expected diff --git a/Tests/New-BurntToastNotification.Tests.ps1 b/Tests/New-BurntToastNotification.Tests.ps1 index be60da6..40ad549 100644 --- a/Tests/New-BurntToastNotification.Tests.ps1 +++ b/Tests/New-BurntToastNotification.Tests.ps1 @@ -1,128 +1,166 @@ -. (Join-Path -Path $PSScriptRoot -ChildPath '_envPrep.ps1') +BeforeAll { + if (Get-Module -Name 'BurntToast') { + Remove-Module -Name 'BurntToast' + } + + if ($ENV:BURNTTOAST_MODULE_ROOT) { + Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force + } else { + Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force + } -Describe 'New-BurntToastNotification' { $ModuleRoot = (Get-Item (Get-Module 'BurntToast').Path).Directory.FullName $ImagePath = Resolve-Path -Path (Join-Path $ModuleRoot 'Images\BurntToast.png') +} - Context 'has registered alias' { +Describe 'New-BurntToastNotification' { + It 'has registered alias' { $Aliases = Get-Alias -Name 'Toast' -ErrorAction SilentlyContinue $Aliases.Count | Should -BeGreaterThan 0 } + Context 'running without arguments (default toast)' { - Start-Transcript tmp.log - try { - New-BurntToastNotification -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BurntToastNotification -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BurntToastNotification"" on target ""submitting: {Default Notification}""." $Log | Should -Be $Expected } } + Context 'custom text' { - Start-Transcript tmp.log - try { - New-BurntToastNotification -Text 'Example Script', 'The example script has run successfully.' -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BurntToastNotification -Text 'Example Script', 'The example script has run successfully.' -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BurntToastNotification"" on target ""submitting: {Example Script}{The example script has run successfully.}""." $Log | Should -Be $Expected } } + Context 'system supplied sound option' { - Start-Transcript tmp.log - try { - New-BurntToastNotification -Text 'WAKE UP!' -Sound 'Alarm2' -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + New-BurntToastNotification -Text 'WAKE UP!' -Sound 'Alarm2' -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BurntToastNotification"" on target ""submitting: {WAKE UP!}""." $Log | Should -Be $Expected } } + Context 'include a button' { - Start-Transcript tmp.log - try { - $BlogButton = New-BTButton -Content 'Open Blog' -Arguments 'https://king.geek.nz' - New-BurntToastNotification -Text 'New Blog Post!' -Button $BlogButton -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + $BlogButton = New-BTButton -Content 'Open Blog' -Arguments 'https://king.geek.nz' + New-BurntToastNotification -Text 'New Blog Post!' -Button $BlogButton -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BurntToastNotification"" on target ""submitting: {New Blog Post!}""." $Log | Should -Be $Expected } } + Context 'include a header' { - Start-Transcript tmp.log - try { - $ToastHeader = New-BTHeader -Id '001' -Title 'SO Questions' - New-BurntToastNotification -Text 'New SO Question', 'Details...' -Header $ToastHeader -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + $ToastHeader = New-BTHeader -Id '001' -Title 'SO Questions' + New-BurntToastNotification -Text 'New SO Question', 'Details...' -Header $ToastHeader -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BurntToastNotification"" on target ""submitting: {New SO Question}{Details...}
""." $Log | Should -Be $Expected } } + Context 'include a progress bar' { - Start-Transcript tmp.log - try { - $Progress = New-BTProgressBar -Status 'Copying' -Value 0.2 - New-BurntToastNotification -Text 'File copy running' -ProgressBar $Progress -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + BeforeAll { + Start-Transcript tmp.log + try { + $Progress = New-BTProgressBar -Status 'Copying' -Value 0.2 + New-BurntToastNotification -Text 'File copy running' -ProgressBar $Progress -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { $Expected = "What if: Performing the operation ""New-BurntToastNotification"" on target ""submitting: {File copy running}""." $Log | Should -Be $Expected } } + Context 'attribution text' { - Start-Transcript tmp.log - try { - $Text1 = New-BTText -Content 'Default Notification' + BeforeAll { + Start-Transcript tmp.log + try { + $Text1 = New-BTText -Content 'Default Notification' - $Attrib = [Microsoft.Toolkit.Uwp.Notifications.ToastGenericAttributionText]::new() + $Attrib = [Microsoft.Toolkit.Uwp.Notifications.ToastGenericAttributionText]::new() - $Attrib.Text = 'via Pester' + $Attrib.Text = 'via Pester' - $Binding1 = New-BTBinding -Children $Text1 -Attribution $Attrib - $Visual1 = New-BTVisual -BindingGeneric $Binding1 - $Content1 = New-BTContent -Visual $Visual1 + $Binding1 = New-BTBinding -Children $Text1 -Attribution $Attrib + $Visual1 = New-BTVisual -BindingGeneric $Binding1 + $Content1 = New-BTContent -Visual $Visual1 - Submit-BTNotification -Content $Content1 -WhatIf - } - finally { - Stop-Transcript - $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) - Remove-Item tmp.log + Submit-BTNotification -Content $Content1 -WhatIf + } + finally { + Stop-Transcript + $Log = (Get-Content tmp.log).Where({ $_ -match "What if: " }) + Remove-Item tmp.log + } } + It 'has consitent WhatIf response' { - $Expected = 'What if: Performing the operation "Submit-BTNotification" on target "submitting: [ToastNotification] with AppId {1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe, Id , Sequence Number and XML: {Default Notification}via Pester".' + $Expected = 'What if: Performing the operation "Submit-BTNotification" on target "submitting: [ToastNotification] with Id , Sequence Number and XML: {Default Notification}via Pester".' $Log | Should -Be $Expected } } diff --git a/Tests/_envPrep.ps1 b/Tests/_envPrep.ps1 deleted file mode 100644 index 259b42c..0000000 --- a/Tests/_envPrep.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -if (Get-Module -Name 'BurntToast') { - Remove-Module -Name 'BurntToast' -Force -} - -try { - [Windows.UI.Notifications.ToastNotificationManager]::History.Clear('{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe') - $PlatformAvailable = $true -} catch { - $PlatformAvailable = $false -} - -if ($ENV:BURNTTOAST_MODULE_ROOT) { - Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force -} else { - Import-Module "$PSScriptRoot/../BurntToast/BurntToast.psd1" -Force -} - diff --git a/Tests/_pester.ps1 b/Tests/_pester.ps1 new file mode 100644 index 0000000..ecd39bf --- /dev/null +++ b/Tests/_pester.ps1 @@ -0,0 +1,4 @@ +$PesterResult = Invoke-Pester -PassThru +if ($PesterResult.FailedCount -ne 0) { + throw "There were $($PesterResult.FailedCount) failed tests." +} \ No newline at end of file diff --git a/Tests/_pssa.ps1 b/Tests/_pssa.ps1 new file mode 100644 index 0000000..3e7e19c --- /dev/null +++ b/Tests/_pssa.ps1 @@ -0,0 +1,12 @@ +$ExcludedRules = @() + +$PssaSplat = @{ + Path = ".\src" + Recurse = $true + EnableExit = $true + ReportSummary = $true + ExcludeRule = $ExcludedRules + #Severity = 'Error' +} + +Invoke-ScriptAnalyzer @PssaSplat diff --git a/BurntToast/Images/BurntToast-Logo.png b/images/BurntToast-Logo.png similarity index 100% rename from BurntToast/Images/BurntToast-Logo.png rename to images/BurntToast-Logo.png diff --git a/Media/BurntToast-Wide.png b/images/BurntToast-Wide.png similarity index 100% rename from Media/BurntToast-Wide.png rename to images/BurntToast-Wide.png diff --git a/BurntToast/Images/BurntToast.png b/images/BurntToast.png similarity index 100% rename from BurntToast/Images/BurntToast.png rename to images/BurntToast.png diff --git a/src/BurntToast.psd1 b/src/BurntToast.psd1 new file mode 100644 index 0000000..e593f76 --- /dev/null +++ b/src/BurntToast.psd1 @@ -0,0 +1,52 @@ +@{ + RootModule = 'BurntToast.psm1' + ModuleVersion = '1.0.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' + Author = 'Joshua (Windos) King' + CompanyName = 'king.geek.nz' + Copyright = '(c) 2015 Joshua (Windos) King. All rights reserved.' + Description = 'Module for creating and displaying Toast Notifications on Microsoft Windows 10.' + PowerShellVersion = '5.0' + FunctionsToExport = 'Get-BTHeader', + 'Get-BTHistory', + 'New-BTAction', + 'New-BTAudio', + 'New-BTBinding', + 'New-BTButton', + 'New-BTColumn', + 'New-BTContent', + 'New-BTContextMenuItem', + 'New-BTHeader', + 'New-BTImage', + 'New-BTInput', + 'New-BTProgressBar', + 'New-BTSelectionBoxItem', + 'New-BTText', + 'New-BTVisual', + 'New-BurntToastNotification', + 'Remove-BTNotification', + 'Submit-BTNotification', + 'Update-BTNotification' + CmdletsToExport = @() + AliasesToExport = @('Toast') + PrivateData = @{ + PSData = @{ + Tags = @('Notifications', 'Utilities', 'Windows10', 'Toast') + LicenseUri = 'https://github.com/Windos/BurntToast/blob/main/LICENSE' + ProjectUri = 'https://github.com/Windos/BurntToast' + IconUri = 'https://raw.githubusercontent.com/Windos/BurntToast/main/Media/BurntToast-Logo.png' + ReleaseNotes = '# 1.0.0 + +* Breaking Changes + * Shoulder tap notification support has been removed +* Features +* Improvements +* Libraries + * Microsoft.Windows.SDK.NET.Ref library bumped to 10.0.22621.28 + * Microsoft.Toolkit.Uwp.Notifications library bumped to 7.1.3 +' + } + } +} diff --git a/src/BurntToast.psm1 b/src/BurntToast.psm1 new file mode 100644 index 0000000..529d8bd --- /dev/null +++ b/src/BurntToast.psm1 @@ -0,0 +1,62 @@ +$OSVersion = [System.Environment]::OSVersion.Version + +if ($OSVersion.Major -ge 10 -and $null -eq $env:BurntToastPesterNotWindows10) { + if ($OSVersion.Build -ge 15063 -and $null -eq $env:BurntToastPesterNotAnniversaryUpdate) { + $Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue ) + $Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue ) + + $Paths = if ($IsWindows) { + "$PSScriptRoot\lib\Microsoft.Toolkit.Uwp.Notifications\net5.0-windows10.0.17763\*.dll", + "$PSScriptRoot\lib\Microsoft.Windows.SDK.NET\*.dll" + } else { + "$PSScriptRoot\lib\Microsoft.Toolkit.Uwp.Notifications\net461\*.dll" + } + + $Library = @( Get-ChildItem -Path $Paths -Recurse -ErrorAction SilentlyContinue ) + + # Add one class from each expected DLL here: + $LibraryMap = @{ + 'Microsoft.Toolkit.Uwp.Notifications.dll' = 'Microsoft.Toolkit.Uwp.Notifications.ToastContent' + 'Microsoft.Windows.SDK.NET.dll' = 'Windows.UI.Notifications.ToastNotification' + 'WinRT.Runtime.dll' = 'WinRT.WindowsRuntimeTypeAttribute' + } + + $Script:Config = Get-Content -Path $PSScriptRoot\config.json -ErrorAction SilentlyContinue | ConvertFrom-Json + $Script:DefaultImage = if ($Script:Config.AppLogo -match '^[.\\]') { + "$PSScriptRoot$($Script:Config.AppLogo)" + } else { + $Script:Config.AppLogo + } + + foreach ($Import in @($Public + $Private)) { + try { + . $Import.FullName + } catch { + Write-Error -Message "Failed to import function $($Import.FullName): $_" + } + } + + foreach ($Type in $Library) { + try { + if (-not ($LibraryMap[$Type.Name] -as [type])) { + Add-Type -Path $Type.FullName -ErrorAction Stop + } + } catch { + Write-Error -Message "Failed to load library $($Type.FullName): $_" + } + } + + Export-ModuleMember -Alias 'Toast' + Export-ModuleMember -Function $Public.BaseName + + if (-not $IsWindows) { + $null = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] + } + } else { + throw 'This version of BurntToast will only work on Windows 10 Creators Update (15063) and above or equivalent Windows Server version. ' + + 'If you would like to use BurntToast on earlier builds, please downgrade to a version of the module below 1.0' + } +} else { + throw 'This version of BurntToast will only work on Windows 10 or equivalent Windows Server version. ' + + 'If you would like to use BurntToast on Windows 8, please use version 0.4 of the module' +} diff --git a/Media/BurntToast-Logo.png b/src/Images/BurntToast-Logo.png similarity index 100% rename from Media/BurntToast-Logo.png rename to src/Images/BurntToast-Logo.png diff --git a/Media/BurntToast.png b/src/Images/BurntToast.png similarity index 100% rename from Media/BurntToast.png rename to src/Images/BurntToast.png diff --git a/BurntToast/Private/Add-PipelineObject.ps1 b/src/Private/Add-PipelineObject.ps1 similarity index 100% rename from BurntToast/Private/Add-PipelineObject.ps1 rename to src/Private/Add-PipelineObject.ps1 diff --git a/BurntToast/Private/Optimize-BTImageSource.ps1 b/src/Private/Optimize-BTImageSource.ps1 similarity index 100% rename from BurntToast/Private/Optimize-BTImageSource.ps1 rename to src/Private/Optimize-BTImageSource.ps1 diff --git a/BurntToast/Public/Get-BTHeader.ps1 b/src/Public/Get-BTHeader.ps1 similarity index 93% rename from BurntToast/Public/Get-BTHeader.ps1 rename to src/Public/Get-BTHeader.ps1 index a8bb045..005339a 100644 --- a/BurntToast/Public/Get-BTHeader.ps1 +++ b/src/Public/Get-BTHeader.ps1 @@ -22,9 +22,6 @@ function Get-BTHeader { [cmdletBinding(DefaultParametersetName = 'All', HelpUri='https://github.com/Windos/BurntToast/blob/main/Help/Get-BTHeader.md')] param ( - # Specifies the AppId of the 'application' or process that spawned the toast notification. - [string] $AppId = $Script:Config.AppId, - # A string that uniquely identifies a toast notification to retrieve the Header for [Parameter(Mandatory, ParametersetName = 'ByToastId')] @@ -43,9 +40,7 @@ function Get-BTHeader { [string] $Id ) - $HistoryParams = @{ - 'AppId' = $AppId - } + $HistoryParams = @{} if ($PSCmdlet.ParameterSetName -eq 'ByToastId') { $HistoryParams['UniqueIdentifier'] = $ToastUniqueIdentifier} $HeaderIds = New-Object -TypeName "System.Collections.ArrayList" diff --git a/BurntToast/Public/Get-BTHistory.ps1 b/src/Public/Get-BTHistory.ps1 similarity index 59% rename from BurntToast/Public/Get-BTHistory.ps1 rename to src/Public/Get-BTHistory.ps1 index a63258d..79a05ee 100644 --- a/BurntToast/Public/Get-BTHistory.ps1 +++ b/src/Public/Get-BTHistory.ps1 @@ -26,9 +26,6 @@ function Get-BTHistory { [cmdletBinding(HelpUri='https://github.com/Windos/BurntToast/blob/main/Help/Get-BTHistory.md')] param ( - # Specifies the AppId of the 'application' or process that spawned the toast notification. - [string] $AppId = $Script:Config.AppId, - # A string that uniquely identifies a toast notification. Submitting a new toast with the same identifier as a previous toast will replace the previous toast. # # This is useful when updating the progress of a process, using a progress bar, or otherwise correcting/updating the information on a toast. @@ -38,23 +35,19 @@ function Get-BTHistory { [switch] $ScheduledToast ) - if (!(Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\$AppId")) { - throw "The AppId $AppId is not present in the registry, please run New-BTAppId to avoid inconsistent Toast behaviour." + if ($Script:ActionsSupported) { + Write-Warning -Message 'The output from this function in some versions of PowerShell is not useful. Unfortunately this is expected at this time.' + } + + $Toasts = if ($ScheduledToast) { + [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::CreateToastNotifier().GetScheduledToastNotifications() + } else { + [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::History.GetHistory() + } + + if ($UniqueIdentifier) { + $Toasts | Where-Object {$_.Tag -eq $UniqueIdentifier -or $_.Group -eq $UniqueIdentifier} } else { - if ($Script:ActionsSupported) { - Write-Warning -Message 'The output from this function in some versions of PowerShell is not useful. Unfortunately this is expected at this time.' - } - - $Toasts = if ($ScheduledToast) { - [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($AppId).GetScheduledToastNotifications() - } else { - [Windows.UI.Notifications.ToastNotificationManager]::History.GetHistory($AppId) - } - - if ($UniqueIdentifier) { - $Toasts | Where-Object {$_.Tag -eq $UniqueIdentifier -or $_.Group -eq $UniqueIdentifier} - } else { - $Toasts - } + $Toasts } } diff --git a/BurntToast/Public/New-BTAction.ps1 b/src/Public/New-BTAction.ps1 similarity index 100% rename from BurntToast/Public/New-BTAction.ps1 rename to src/Public/New-BTAction.ps1 diff --git a/BurntToast/Public/New-BTAudio.ps1 b/src/Public/New-BTAudio.ps1 similarity index 87% rename from BurntToast/Public/New-BTAudio.ps1 rename to src/Public/New-BTAudio.ps1 index 3f23f9e..0c8d38c 100644 --- a/BurntToast/Public/New-BTAudio.ps1 +++ b/src/Public/New-BTAudio.ps1 @@ -72,22 +72,7 @@ 'ms-winsoundevent:Notification.Looping.Call10')] [uri] $Source, - # The full path to an audio file. Supported file types include: - # - # *.aac - # *.flac - # *.m4a - # *.mp3 - # *.wav - # *.wma - [Parameter(Mandatory, - ParameterSetName = 'CustomSound')] - [ValidateScript({Test-BTAudioPath $_})] - [Obsolete('Unfortunately, custom sounds no longer work and this parameter will be removed in v0.9.0. See: https://github.com/MicrosoftDocs/windows-uwp/issues/1593')] - [string] $Path, - # Specifies that the slected sound should play multiple times if its duration is shorter than that of the toast it accompanies. - [Parameter(ParameterSetName = 'CustomSound')] [Parameter(ParameterSetName = 'StandardSound')] [switch] $Loop, @@ -103,10 +88,6 @@ $Audio.Src = $Source } - if ($Path) { - $Audio.Src = $Path - } - $Audio.Loop = $Loop $Audio.Silent = $Silent diff --git a/BurntToast/Public/New-BTBinding.ps1 b/src/Public/New-BTBinding.ps1 similarity index 100% rename from BurntToast/Public/New-BTBinding.ps1 rename to src/Public/New-BTBinding.ps1 diff --git a/BurntToast/Public/New-BTButton.ps1 b/src/Public/New-BTButton.ps1 similarity index 100% rename from BurntToast/Public/New-BTButton.ps1 rename to src/Public/New-BTButton.ps1 diff --git a/BurntToast/Public/New-BTColumn.ps1 b/src/Public/New-BTColumn.ps1 similarity index 100% rename from BurntToast/Public/New-BTColumn.ps1 rename to src/Public/New-BTColumn.ps1 diff --git a/BurntToast/Public/New-BTContent.ps1 b/src/Public/New-BTContent.ps1 similarity index 100% rename from BurntToast/Public/New-BTContent.ps1 rename to src/Public/New-BTContent.ps1 diff --git a/BurntToast/Public/New-BTContextMenuItem.ps1 b/src/Public/New-BTContextMenuItem.ps1 similarity index 100% rename from BurntToast/Public/New-BTContextMenuItem.ps1 rename to src/Public/New-BTContextMenuItem.ps1 diff --git a/BurntToast/Public/New-BTHeader.ps1 b/src/Public/New-BTHeader.ps1 similarity index 100% rename from BurntToast/Public/New-BTHeader.ps1 rename to src/Public/New-BTHeader.ps1 diff --git a/BurntToast/Public/New-BTImage.ps1 b/src/Public/New-BTImage.ps1 similarity index 100% rename from BurntToast/Public/New-BTImage.ps1 rename to src/Public/New-BTImage.ps1 diff --git a/BurntToast/Public/New-BTInput.ps1 b/src/Public/New-BTInput.ps1 similarity index 100% rename from BurntToast/Public/New-BTInput.ps1 rename to src/Public/New-BTInput.ps1 diff --git a/BurntToast/Public/New-BTProgressBar.ps1 b/src/Public/New-BTProgressBar.ps1 similarity index 100% rename from BurntToast/Public/New-BTProgressBar.ps1 rename to src/Public/New-BTProgressBar.ps1 diff --git a/BurntToast/Public/New-BTSelectionBoxItem.ps1 b/src/Public/New-BTSelectionBoxItem.ps1 similarity index 100% rename from BurntToast/Public/New-BTSelectionBoxItem.ps1 rename to src/Public/New-BTSelectionBoxItem.ps1 diff --git a/BurntToast/Public/New-BTText.ps1 b/src/Public/New-BTText.ps1 similarity index 100% rename from BurntToast/Public/New-BTText.ps1 rename to src/Public/New-BTText.ps1 diff --git a/BurntToast/Public/New-BTVisual.ps1 b/src/Public/New-BTVisual.ps1 similarity index 100% rename from BurntToast/Public/New-BTVisual.ps1 rename to src/Public/New-BTVisual.ps1 diff --git a/BurntToast/Public/New-BurntToastNotification.ps1 b/src/Public/New-BurntToastNotification.ps1 similarity index 98% rename from BurntToast/Public/New-BurntToastNotification.ps1 rename to src/Public/New-BurntToastNotification.ps1 index 0dc1c4e..741b623 100644 --- a/BurntToast/Public/New-BurntToastNotification.ps1 +++ b/src/Public/New-BurntToastNotification.ps1 @@ -83,9 +83,6 @@ #TODO: [ValidateScript({ Test-ToastImage -Path $_ })] - # Specifies the AppId of the 'application' or process that spawned the toast notification. - [string] $AppId = $Script:Config.AppId, - # Specifies the path to an image that will override the default image displayed with a Toast Notification. [String] $AppLogo, @@ -156,7 +153,7 @@ 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. + # Specify the Toast Header object created using the New-BTHeader function, for seperation/categorization of toasts from the same application. [Microsoft.Toolkit.Uwp.Notifications.ToastHeader] $Header, # Specify one or more Progress Bar object created using the New-BTProgressBar function. @@ -262,7 +259,6 @@ $ToastSplat = @{ Content = $Content - AppId = $AppId } if ($UniqueIdentifier) { diff --git a/BurntToast/Public/Remove-BTNotification.ps1 b/src/Public/Remove-BTNotification.ps1 similarity index 53% rename from BurntToast/Public/Remove-BTNotification.ps1 rename to src/Public/Remove-BTNotification.ps1 index 392ca5a..4faa407 100644 --- a/BurntToast/Public/Remove-BTNotification.ps1 +++ b/src/Public/Remove-BTNotification.ps1 @@ -6,7 +6,7 @@ function Remove-BTNotification { .DESCRIPTION The Remove-BTNotification function removes toast notifications from the Action Center. - If no parameters are specified, all toasts (for the default AppId) will be removed. + If no parameters are specified, all toasts (for the current application) will be removed. Tags and Groups for Toasts can be found using the Get-BTHistory function. @@ -30,9 +30,6 @@ function Remove-BTNotification { SupportsShouldProcess = $true, HelpUri = 'https://github.com/Windos/BurntToast/blob/main/Help/Remove-BTNotification.md')] param ( - # Specifies the AppId of the 'application' or process that spawned the toast notification. - [string] $AppId = $Script:Config.AppId, - # Specifies the tag, which identifies a given toast notification. [Parameter(ParameterSetName = 'Individual')] [string] $Tag, @@ -48,28 +45,26 @@ function Remove-BTNotification { ) if ($UniqueIdentifier) { - if($PSCmdlet.ShouldProcess("Tag: $UniqueIdentifier, Group: $UniqueIdentifier, AppId: $AppId", 'Selectively removing notifications')) { - [Windows.UI.Notifications.ToastNotificationManager]::History.Remove($UniqueIdentifier, $UniqueIdentifier, $AppId) + if($PSCmdlet.ShouldProcess("Tag: $UniqueIdentifier, Group: $UniqueIdentifier", 'Selectively removing notifications')) { + [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::History.Remove($UniqueIdentifier, $UniqueIdentifier) } - } elseif (!(Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\$AppId")) { - Write-Warning -Message "The AppId $AppId is not present in the registry, please run New-BTAppId to avoid inconsistent Toast behaviour." } if ($Tag -and $Group) { - if($PSCmdlet.ShouldProcess("Tag: $Tag, Group: $Group, AppId: $AppId", 'Selectively removing notifications')) { - [Windows.UI.Notifications.ToastNotificationManager]::History.Remove($Tag, $Group, $AppId) + if($PSCmdlet.ShouldProcess("Tag: $Tag, Group: $Group", 'Selectively removing notifications')) { + [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::History.Remove($Tag, $Group) } } elseif ($Tag) { - if($PSCmdlet.ShouldProcess("Tag: $Tag, AppId: $AppId", 'Selectively removing notifications')) { - [Windows.UI.Notifications.ToastNotificationManager]::History.Remove($Tag, $AppId) + if($PSCmdlet.ShouldProcess("Tag: $Tag", 'Selectively removing notifications')) { + [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::History.Remove($Tag) } } elseif ($Group) { - if($PSCmdlet.ShouldProcess("Group: $Group, AppId: $AppId", 'Selectively removing notifications')) { - [Windows.UI.Notifications.ToastNotificationManager]::History.RemoveGroup($Group, $AppId) + if($PSCmdlet.ShouldProcess("Group: $Group", 'Selectively removing notifications')) { + [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::History.RemoveGroup($Group) } } else { - if($PSCmdlet.ShouldProcess("AppId: $AppId", 'Clearing all notifications')) { - [Windows.UI.Notifications.ToastNotificationManager]::History.Clear($AppId) + if($PSCmdlet.ShouldProcess("All", 'Clearing all notifications')) { + [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::History.Clear() } } } diff --git a/BurntToast/Public/Submit-BTNotification.ps1 b/src/Public/Submit-BTNotification.ps1 similarity index 90% rename from BurntToast/Public/Submit-BTNotification.ps1 rename to src/Public/Submit-BTNotification.ps1 index a2d5dd0..3c5b633 100644 --- a/BurntToast/Public/Submit-BTNotification.ps1 +++ b/src/Public/Submit-BTNotification.ps1 @@ -37,9 +37,6 @@ # This is useful when updating the progress of a process, using a progress bar, or otherwise correcting/updating the information on a toast. [string] $UniqueIdentifier, - # Specifies the AppId of the 'application' or process that spawned the toast notification. - [string] $AppId = $Script:Config.AppId, - # A hashtable that binds strings to keys in a toast notification. In order to update a toast, the original toast needs to include a databinding hashtable. [hashtable] $DataBinding, @@ -56,10 +53,6 @@ [scriptblock] $FailedAction ) - if (!(Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\$AppId")) { - Write-Warning -Message "The AppId $AppId is not present in the registry, please run New-BTAppId to avoid inconsistent Toast behaviour." - } - if (-not $IsWindows) { $null = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] } @@ -166,7 +159,7 @@ } } - if($PSCmdlet.ShouldProcess( "submitting: [$($Toast.GetType().Name)] with AppId $AppId, Id $UniqueIdentifier, Sequence Number $($Toast.Data.SequenceNumber) and XML: $($Content.GetContent())")) { - [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($AppId).Show($Toast) + if($PSCmdlet.ShouldProcess( "submitting: [$($Toast.GetType().Name)] with Id $UniqueIdentifier, Sequence Number $($Toast.Data.SequenceNumber) and XML: $($Content.GetContent())")) { + [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::CreateToastNotifier().Show($Toast) } } diff --git a/BurntToast/Public/Update-BTNotification.ps1 b/src/Public/Update-BTNotification.ps1 similarity index 79% rename from BurntToast/Public/Update-BTNotification.ps1 rename to src/Public/Update-BTNotification.ps1 index 59a1804..e02c405 100644 --- a/BurntToast/Public/Update-BTNotification.ps1 +++ b/src/Public/Update-BTNotification.ps1 @@ -44,17 +44,10 @@ # This is useful when updating the progress of a process, using a progress bar, or otherwise correcting/updating the information on a toast. [string] $UniqueIdentifier, - # Specifies the AppId of the 'application' or process that spawned the toast notification. - [string] $AppId = $Script:Config.AppId, - # A hashtable that binds strings to keys in a toast notification. In order to update a toast, the original toast needs to include a databinding hashtable. [hashtable] $DataBinding ) - if (!(Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\$AppId")) { - Write-Warning -Message "The AppId $AppId is not present in the registry, please run New-BTAppId to avoid inconsistent Toast behaviour." - } - if (-not $IsWindows) { $null = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] } @@ -73,7 +66,7 @@ $ToastData.SequenceNumber = $SequenceNumber } - if($PSCmdlet.ShouldProcess("AppId: $AppId, UniqueId: $UniqueIdentifier", 'Updating notification')) { - [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($AppId).Update($ToastData, $UniqueIdentifier, $UniqueIdentifier) + if($PSCmdlet.ShouldProcess("UniqueId: $UniqueIdentifier", 'Updating notification')) { + [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::CreateToastNotifier().Update($ToastData, $UniqueIdentifier, $UniqueIdentifier) } } diff --git a/src/config.json b/src/config.json new file mode 100644 index 0000000..3ffc2dd --- /dev/null +++ b/src/config.json @@ -0,0 +1,3 @@ +{ + "AppLogo": "\\Images\\BurntToast.png" +} diff --git a/BurntToast/en-us/about_BurntToast.help.txt b/src/en-us/about_BurntToast.help.txt similarity index 100% rename from BurntToast/en-us/about_BurntToast.help.txt rename to src/en-us/about_BurntToast.help.txt diff --git a/BurntToast/lib/Microsoft.Toolkit.Uwp.Notifications/Microsoft.Toolkit.Uwp.Notifications.dll b/src/lib/Microsoft.Toolkit.Uwp.Notifications/Microsoft.Toolkit.Uwp.Notifications.dll similarity index 100% rename from BurntToast/lib/Microsoft.Toolkit.Uwp.Notifications/Microsoft.Toolkit.Uwp.Notifications.dll rename to src/lib/Microsoft.Toolkit.Uwp.Notifications/Microsoft.Toolkit.Uwp.Notifications.dll diff --git a/src/lib/Microsoft.Toolkit.Uwp.Notifications/README.md b/src/lib/Microsoft.Toolkit.Uwp.Notifications/README.md new file mode 100644 index 0000000..8e66ce0 --- /dev/null +++ b/src/lib/Microsoft.Toolkit.Uwp.Notifications/README.md @@ -0,0 +1,4 @@ +* Name: Microsoft.Toolkit.Uwp.Notifications +* Source: https://www.nuget.org/packages/Microsoft.Toolkit.Uwp.Notifications +* Version: 7.1.3 +* Directory: \lib\net461 & \lib\net5.0-windows10.0.17763 diff --git a/src/lib/Microsoft.Toolkit.Uwp.Notifications/net461/Microsoft.Toolkit.Uwp.Notifications.dll b/src/lib/Microsoft.Toolkit.Uwp.Notifications/net461/Microsoft.Toolkit.Uwp.Notifications.dll new file mode 100644 index 0000000..4505680 Binary files /dev/null and b/src/lib/Microsoft.Toolkit.Uwp.Notifications/net461/Microsoft.Toolkit.Uwp.Notifications.dll differ diff --git a/src/lib/Microsoft.Toolkit.Uwp.Notifications/net5.0-windows10.0.17763/Microsoft.Toolkit.Uwp.Notifications.dll b/src/lib/Microsoft.Toolkit.Uwp.Notifications/net5.0-windows10.0.17763/Microsoft.Toolkit.Uwp.Notifications.dll new file mode 100644 index 0000000..e384e34 Binary files /dev/null and b/src/lib/Microsoft.Toolkit.Uwp.Notifications/net5.0-windows10.0.17763/Microsoft.Toolkit.Uwp.Notifications.dll differ diff --git a/BurntToast/lib/Microsoft.Windows.SDK.NET/Microsoft.Windows.SDK.NET.dll b/src/lib/Microsoft.Windows.SDK.NET/Microsoft.Windows.SDK.NET.dll similarity index 54% rename from BurntToast/lib/Microsoft.Windows.SDK.NET/Microsoft.Windows.SDK.NET.dll rename to src/lib/Microsoft.Windows.SDK.NET/Microsoft.Windows.SDK.NET.dll index 9eb29e6..ad94a62 100644 Binary files a/BurntToast/lib/Microsoft.Windows.SDK.NET/Microsoft.Windows.SDK.NET.dll and b/src/lib/Microsoft.Windows.SDK.NET/Microsoft.Windows.SDK.NET.dll differ diff --git a/src/lib/Microsoft.Windows.SDK.NET/README.md b/src/lib/Microsoft.Windows.SDK.NET/README.md new file mode 100644 index 0000000..44ab279 --- /dev/null +++ b/src/lib/Microsoft.Windows.SDK.NET/README.md @@ -0,0 +1,4 @@ +* Name: Microsoft.Windows.SDK.NET.Ref +* Source: https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref +* Version: 10.0.22621.28 +* Directory: \lib diff --git a/src/lib/Microsoft.Windows.SDK.NET/WinRT.Runtime.dll b/src/lib/Microsoft.Windows.SDK.NET/WinRT.Runtime.dll new file mode 100644 index 0000000..3e2a391 Binary files /dev/null and b/src/lib/Microsoft.Windows.SDK.NET/WinRT.Runtime.dll differ