diff --git a/functions/private/Set-WinUtilTaskbarItem.ps1 b/functions/private/Set-WinUtilTaskbarItem.ps1 index e08d0eb6..7f290fac 100644 --- a/functions/private/Set-WinUtilTaskbarItem.ps1 +++ b/functions/private/Set-WinUtilTaskbarItem.ps1 @@ -29,7 +29,7 @@ function Set-WinUtilTaskbaritem { - Set-WinUtilTaskbaritem -overlay "warning" No overlay: - Set-WinUtilTaskbaritem -overlay "None" - Custom icon: + Custom icon (needs to be supported by WPF): - Set-WinUtilTaskbaritem -overlay "C:\path\to\icon.png" .PARAMETER description @@ -43,39 +43,6 @@ function Set-WinUtilTaskbaritem { [string]$description ) - # TODO: Make a better solution for this function, accessing problem when calling Set-WinUtilTaskbaritem inside a runspace. Future me or other contributors, please fix this. - function ConvertTo-Bitmap { - <# - .SYNOPSIS - Converts an image file to a Bitmap object - - .PARAMETER image - The path to the image file to convert - - .EXAMPLE - ConvertTo-Bitmap -imageFilePath "C:\path\to\image.png" - #> - param ( - $imageFilePath - ) - - # Read the image file as a byte array - $imageBytes = [System.IO.File]::ReadAllBytes($imageFilePath) - - # Convert the byte array to a Base64 string - $base64String = [System.Convert]::ToBase64String($imageBytes) - - # Create a streaming image by streaming the base64 string to a bitmap streamsource - $bitmap = New-Object System.Windows.Media.Imaging.BitmapImage - $bitmap.BeginInit() - $bitmap.StreamSource = [System.IO.MemoryStream][System.Convert]::FromBase64String($base64String) - $bitmap.EndInit() - $bitmap.Freeze() - - # Return the bitmap object - return $bitmap - } - if ($value) { $sync["Form"].taskbarItemInfo.ProgressValue = $value } @@ -94,20 +61,20 @@ function Set-WinUtilTaskbaritem { if ($overlay) { switch ($overlay) { 'logo' { - $sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -imageFilePath "$env:LOCALAPPDATA\winutil\cttlogo.png") + $sync["Form"].taskbarItemInfo.Overlay = "$env:LOCALAPPDATA\winutil\cttlogo.png" } 'checkmark' { - $sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -imageFilePath "$env:LOCALAPPDATA\winutil\checkmark.png"]) + $sync["Form"].taskbarItemInfo.Overlay = "$env:LOCALAPPDATA\winutil\checkmark.png" } 'warning' { - $sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -imageFilePath "$env:LOCALAPPDATA\winutil\warning.png"]) + $sync["Form"].taskbarItemInfo.Overlay = "$env:LOCALAPPDATA\winutil\warning.png" } 'None' { $sync["Form"].taskbarItemInfo.Overlay = $null } default { if (Test-Path $overlay) { - $sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -image $overlay) + $sync["Form"].taskbarItemInfo.Overlay = $overlay } } } diff --git a/scripts/main.ps1 b/scripts/main.ps1 index ea79507c..248bf605 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -460,7 +460,7 @@ if (-NOT (Test-Path -Path $winutildir["warning.png"])) { } -Set-WinUtilTaskbaritem -overlay "logo" | Out-Null +Set-WinUtilTaskbaritem -overlay "logo" $sync["Form"].Add_Activated({ Set-WinUtilTaskbaritem -overlay "logo"