mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-15 17:30:37 -06:00
last fixes
This commit is contained in:
parent
e8d1bd8eb8
commit
39c3e9062f
@ -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
|
||||
|
@ -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
|
||||
}
|
@ -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"]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user