From 5885c067e09d7b03b662abcc96fd12cc5286da38 Mon Sep 17 00:00:00 2001 From: MyDrift Date: Tue, 3 Sep 2024 21:53:31 +0200 Subject: [PATCH] performance improvement instead of rendering the image another time on each item switch, it caches it at the start and uses the render afterwards --- functions/private/Set-WinUtilTaskbarItem.ps1 | 6 +++--- scripts/main.ps1 | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/functions/private/Set-WinUtilTaskbarItem.ps1 b/functions/private/Set-WinUtilTaskbarItem.ps1 index cfd72249..6eeb7674 100644 --- a/functions/private/Set-WinUtilTaskbarItem.ps1 +++ b/functions/private/Set-WinUtilTaskbarItem.ps1 @@ -61,13 +61,13 @@ function Set-WinUtilTaskbaritem { if ($overlay) { switch ($overlay) { 'logo' { - $sync["Form"].taskbarItemInfo.Overlay = (Invoke-WinUtilAssets -Type "Logo" -Size 80 -Render) + $sync["Form"].taskbarItemInfo.Overlay = $sync["logorender"] } 'checkmark' { - $sync["Form"].taskbarItemInfo.Overlay = (Invoke-WinUtilAssets -Type "checkmark" -Size 512 -Render) + $sync["Form"].taskbarItemInfo.Overlay = $sync["checkmarkrender"] } 'warning' { - $sync["Form"].taskbarItemInfo.Overlay = (Invoke-WinUtilAssets -Type "warning" -Size 512 -Render) + $sync["Form"].taskbarItemInfo.Overlay = $sync["warningrender"] } 'None' { $sync["Form"].taskbarItemInfo.Overlay = $null diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 4334f087..e7b67c2a 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -457,6 +457,10 @@ $winutildir["path"] = "$env:LOCALAPPDATA\winutil\" $winutildir["logo.ico"] = $winutildir["path"] + "cttlogo.ico" +$sync["logorender"] = (Invoke-WinUtilAssets -Type "Logo" -Size 90 -Render) +$sync["checkmarkrender"] = (Invoke-WinUtilAssets -Type "checkmark" -Size 512 -Render) +$sync["warningrender"] = (Invoke-WinUtilAssets -Type "warning" -Size 512 -Render) + Set-WinUtilTaskbaritem -overlay "logo" $sync["Form"].Add_Activated({