Compare commits

..

2 Commits

Author SHA1 Message Date
MyDrift
f50845078e fixes
- ability to set no overlay added
- added relative path to winutildir
2024-07-15 12:42:39 +02:00
MyDrift
c490cbff1a rework assets directory & its usage 2024-07-15 12:08:58 +02:00
3 changed files with 34 additions and 18 deletions

View File

@ -20,11 +20,13 @@ function Set-WinUtilTaskbaritem {
- Set-WinUtilTaskbaritem -state "Paused" - Set-WinUtilTaskbaritem -state "Paused"
.PARAMETER overlay .PARAMETER overlay
Overlay icon to display on the taskbar item, there are the presets 'logo' and 'checkmark' or you can specify a path/link to an image file. Overlay icon to display on the taskbar item, there are the presets 'None', 'logo' and 'checkmark' or you can specify a path/link to an image file.
CTT logo preset: CTT logo preset:
- Set-WinUtilTaskbaritem -overlay "logo" - Set-WinUtilTaskbaritem -overlay "logo"
Checkmark preset: Checkmark preset:
- Set-WinUtilTaskbaritem -overlay "checkmark" - Set-WinUtilTaskbaritem -overlay "checkmark"
No overlay:
- Set-WinUtilTaskbaritem -overlay "None"
Custom icon: Custom icon:
- Set-WinUtilTaskbaritem -overlay "C:\path\to\icon.png" - Set-WinUtilTaskbaritem -overlay "C:\path\to\icon.png"
@ -57,10 +59,13 @@ function Set-WinUtilTaskbaritem {
if ($overlay) { if ($overlay) {
switch ($overlay) { switch ($overlay) {
'logo' { 'logo' {
$sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -image "$env:LOCALAPPDATA\winutil\cttlogo.png") $sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -image $winutildir["logo.png"])
} }
'checkmark' { 'checkmark' {
$sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -image "$env:LOCALAPPDATA\winutil\cttcheckmark.png") $sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -image $winutildir["checkmark.png"])
}
'None' {
$sync["Form"].taskbarItemInfo.Overlay = $null
} }
default { default {
if (Test-Path $overlay) { if (Test-Path $overlay) {

View File

@ -17,8 +17,7 @@ function Invoke-WPFShortcut {
[bool]$RunAsAdmin = $false [bool]$RunAsAdmin = $false
) )
# Preper the Shortcut Fields and add an a Custom Icon if it's available at "$env:TEMP\cttlogo.png", else don't add a Custom Icon. # Preper the Shortcut Fields and add an a Custom Icon if it's available, else don't add a Custom Icon.
$iconPath = $null
Switch ($ShortcutToAdd) { Switch ($ShortcutToAdd) {
"WinUtil" { "WinUtil" {
$SourceExe = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" $SourceExe = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe"
@ -48,8 +47,8 @@ function Invoke-WPFShortcut {
$Shortcut = $WshShell.CreateShortcut($FileBrowser.FileName) $Shortcut = $WshShell.CreateShortcut($FileBrowser.FileName)
$Shortcut.TargetPath = $SourceExe $Shortcut.TargetPath = $SourceExe
$Shortcut.Arguments = $ArgumentsToSourceExe $Shortcut.Arguments = $ArgumentsToSourceExe
if (Test-Path -Path $ctticologo) { if (Test-Path -Path $winutildir["logo.ico"]) {
$shortcut.IconLocation = $ctticologo $shortcut.IconLocation = $winutildir["logo.ico"]
} }
# Save the Shortcut to disk # Save the Shortcut to disk

View File

@ -430,22 +430,34 @@ $sync["SearchBar"].Add_TextChanged({
$label.Visibility = "Collapsed"} $label.Visibility = "Collapsed"}
}) })
$cttpnglogo = "$env:LOCALAPPDATA\winutil\cttlogo.png" # Initialize the hashtable
$ctticologo = "$env:LOCALAPPDATA\winutil\cttlogo.ico" $winutildir = @{}
if (-NOT (Test-Path -Path $cttpnglogo) -or -NOT (Test-Path -Path $ctticologo)) {
Invoke-WebRequest -Uri "https://christitus.com/images/logo-full.png" -OutFile $cttpnglogo
}
$cttpngcheckmark = "$env:LOCALAPPDATA\winutil\cttcheckmark.png" # Set the path for the winutil directory
$ctticocheckmark = "$env:LOCALAPPDATA\winutil\cttcheckmark.ico" $winutildir["path"] = "$env:LOCALAPPDATA\winutil\"
if (-NOT (Test-Path -Path $cttpngcheckmark) -or -NOT (Test-Path -Path $ctticocheckmark)) { if (-NOT (Test-Path -Path $winutildir["path"])) {
Invoke-WebRequest -Uri "https://christitus.com/images/checkmark.png" -OutFile $cttpngcheckmark New-Item -Path $winutildir["path"] -ItemType Directory
} }
ConvertTo-Icon -bitmapPath $cttpnglogo -iconPath $ctticologo # 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"] = "$env:LOCALAPPDATA\winutil\cttcheckmark.png"
if (-NOT (Test-Path -Path $winutildir["checkmark.png"])) {
Invoke-WebRequest -Uri "https://christitus.com/images/checkmark.png" -OutFile $winutildir["checkmark.png"]
}
Set-WinUtilTaskbaritem -overlay "logo" | Out-Null Set-WinUtilTaskbaritem -overlay "logo" | Out-Null
$sync["Form"].icon = $cttpnglogo
$sync["Form"].icon = $winutildir["logo.png"]
$sync["Form"].Add_Activated({ $sync["Form"].Add_Activated({
Set-WinUtilTaskbaritem -overlay "logo" Set-WinUtilTaskbaritem -overlay "logo"