mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-06-27 16:44:46 -05:00
Taskbaritem > Progressbar / Overlay icon / description / asset mgmt (#2309)
* Add Progress bar to some stuff https://learn.microsoft.com/en-us/dotnet/api/system.windows.shell.taskbariteminfo?view=windowsdesktop-8.0 * add function to manage taskbar item changed from manually setting the taskbar overlay, progressvalue and progress state to setting them through a function * add description feature * use Dispatcher.Invoke * restructure, fix, additions * fix merge conflicts * add check to progresses * remove progress from wiget & choco install * fix * polish * fix * Update functions/private/Set-WinUtilTaskbarItem.ps1 Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * fix syntax * Update functions/private/Set-WinUtilTaskbarItem.ps1 Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * rework - add overlay presets - rework image saving & converting - removed popup after uninstalling applications * fix description of function * undo winutil * remove check.png * Update functions/private/Set-WinUtilTaskbarItem.ps1 Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * Update functions/private/Set-WinUtilTaskbarItem.ps1 Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * rework assets directory & its usage * fixes - ability to set no overlay added - added relative path to winutildir * hotfix * last fixes * add comment * remove trailing whitespaces THX to Mr.K :) * renamed checkmark & added warning * last fixes remove bitmap remove unneeded "| out-null" * hotfix for new commit --------- Co-authored-by: Mr.k <mineshtine28546271@gmail.com>
This commit is contained in:
@ -154,6 +154,10 @@ Invoke-WPFRunspace -ScriptBlock {
|
||||
# Print the logo
|
||||
Invoke-WPFFormVariables
|
||||
|
||||
# Progress bar in taskbaritem > Set-WinUtilProgressbar
|
||||
$sync["Form"].TaskbarItemInfo = New-Object System.Windows.Shell.TaskbarItemInfo
|
||||
Set-WinUtilTaskbaritem -state "None"
|
||||
|
||||
# Set the titlebar
|
||||
$sync["Form"].title = $sync["Form"].title + " " + $sync.version
|
||||
# Set the commands that will run when the form is closed
|
||||
@ -288,38 +292,6 @@ Add-Type @"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Using a TaskbarItem Overlay until someone figures out how to replace the icon correctly
|
||||
|
||||
# URL of the image
|
||||
$imageUrl = "https://christitus.com/images/logo-full.png"
|
||||
|
||||
# Download the image
|
||||
$imagePath = "$env:TEMP\logo-full.png"
|
||||
Invoke-WebRequest -Uri $imageUrl -OutFile $imagePath
|
||||
|
||||
# Read the image file as a byte array
|
||||
$imageBytes = [System.IO.File]::ReadAllBytes($imagePath)
|
||||
|
||||
# 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()
|
||||
|
||||
# Ensure TaskbarItemInfo is created if not already
|
||||
if (-not $sync["Form"].TaskbarItemInfo) {
|
||||
$sync["Form"].TaskbarItemInfo = New-Object System.Windows.Shell.TaskbarItemInfo
|
||||
}
|
||||
|
||||
# Set the overlay icon for the taskbar
|
||||
$sync["Form"].TaskbarItemInfo.Overlay = $bitmap
|
||||
|
||||
|
||||
$rect = New-Object RECT
|
||||
[Window]::GetWindowRect($windowHandle, [ref]$rect)
|
||||
$width = $rect.Right - $rect.Left
|
||||
@ -458,6 +430,42 @@ $sync["SearchBar"].Add_TextChanged({
|
||||
$label.Visibility = "Collapsed"}
|
||||
})
|
||||
|
||||
# Initialize the hashtable
|
||||
$winutildir = @{}
|
||||
|
||||
# Set the path for the winutil directory
|
||||
$winutildir["path"] = "$env:LOCALAPPDATA\winutil\"
|
||||
if (-NOT (Test-Path -Path $winutildir["path"])) {
|
||||
New-Item -Path $winutildir["path"] -ItemType Directory
|
||||
}
|
||||
|
||||
# Set the path for the logo and checkmark images
|
||||
$winutildir["logo.png"] = $winutildir["path"] + "cttlogo.png"
|
||||
$winutildir["logo.ico"] = $winutildir["path"] + "cttlogo.ico"
|
||||
if (-NOT (Test-Path -Path $winutildir["logo.png"])) {
|
||||
Invoke-WebRequest -Uri "https://christitus.com/images/logo-full.png" -OutFile $winutildir["logo.png"]
|
||||
}
|
||||
|
||||
if (-NOT (Test-Path -Path $winutildir["logo.ico"])) {
|
||||
ConvertTo-Icon -bitmapPath $winutildir["logo.png"] -iconPath $winutildir["logo.ico"]
|
||||
}
|
||||
|
||||
$winutildir["checkmark.png"] = $winutildir["path"] + "checkmark.png"
|
||||
$winutildir["warning.png"] = $winutildir["path"] + "warning.png"
|
||||
if (-NOT (Test-Path -Path $winutildir["checkmark.png"])) {
|
||||
Invoke-WebRequest -Uri "https://christitus.com/images/checkmark.png" -OutFile $winutildir["checkmark.png"]
|
||||
}
|
||||
if (-NOT (Test-Path -Path $winutildir["warning.png"])) {
|
||||
Invoke-WebRequest -Uri "https://christitus.com/images/warning.png" -OutFile $winutildir["warning.png"]
|
||||
}
|
||||
|
||||
|
||||
Set-WinUtilTaskbaritem -overlay "logo"
|
||||
|
||||
$sync["Form"].Add_Activated({
|
||||
Set-WinUtilTaskbaritem -overlay "logo"
|
||||
})
|
||||
|
||||
# Define event handler for button click
|
||||
$sync["SettingsButton"].Add_Click({
|
||||
Write-Debug "SettingsButton clicked"
|
||||
|
Reference in New Issue
Block a user