diff --git a/functions/private/Set-WinUtilTaskbarItem.ps1 b/functions/private/Set-WinUtilTaskbarItem.ps1 index 18305d05..46be1e2f 100644 --- a/functions/private/Set-WinUtilTaskbarItem.ps1 +++ b/functions/private/Set-WinUtilTaskbarItem.ps1 @@ -41,6 +41,38 @@ function Set-WinUtilTaskbaritem { [string]$description ) + 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 } @@ -59,10 +91,10 @@ function Set-WinUtilTaskbaritem { if ($overlay) { switch ($overlay) { 'logo' { - $sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -image $winutildir["logo.png"]) + $sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -imageFilePath "$env:LOCALAPPDATA\winutil\cttlogo.png") } 'checkmark' { - $sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -image $winutildir["checkmark.png"]) + $sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -imageFilePath "$env:LOCALAPPDATA\winutil\cttcheckmark.png"]) } 'None' { $sync["Form"].taskbarItemInfo.Overlay = $null diff --git a/functions/private/convertTo-Bitmap.ps1 b/functions/private/convertTo-Bitmap.ps1 deleted file mode 100644 index f84e804b..00000000 --- a/functions/private/convertTo-Bitmap.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -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 -} \ No newline at end of file diff --git a/scripts/main.ps1 b/scripts/main.ps1 index ab52dfc4..ba6fe961 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -450,7 +450,7 @@ if (-NOT (Test-Path -Path $winutildir["logo.ico"])) { ConvertTo-Icon -bitmapPath $winutildir["logo.png"] -iconPath $winutildir["logo.ico"] } -$winutildir["checkmark.png"] = "$env:LOCALAPPDATA\winutil\cttcheckmark.png" +$winutildir["checkmark.png"] = $winutildir["path"] + "cttcheckmark.png" if (-NOT (Test-Path -Path $winutildir["checkmark.png"])) { Invoke-WebRequest -Uri "https://christitus.com/images/checkmark.png" -OutFile $winutildir["checkmark.png"] }