mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-15 17:30:37 -06:00
Compare commits
No commits in common. "2fab47dd1356311f56f5146203a4977359f0383a" and "172f893c9fd3c1e2313a3ab050fb48d21ab632e0" have entirely different histories.
2fab47dd13
...
172f893c9f
@ -25,11 +25,9 @@ function Set-WinUtilTaskbaritem {
|
||||
- Set-WinUtilTaskbaritem -overlay "logo"
|
||||
Checkmark preset:
|
||||
- Set-WinUtilTaskbaritem -overlay "checkmark"
|
||||
Warning preset:
|
||||
- Set-WinUtilTaskbaritem -overlay "warning"
|
||||
No overlay:
|
||||
- Set-WinUtilTaskbaritem -overlay "None"
|
||||
Custom icon (needs to be supported by WPF):
|
||||
Custom icon:
|
||||
- Set-WinUtilTaskbaritem -overlay "C:\path\to\icon.png"
|
||||
|
||||
.PARAMETER description
|
||||
@ -43,6 +41,39 @@ function Set-WinUtilTaskbaritem {
|
||||
[string]$description
|
||||
)
|
||||
|
||||
# TODO: Make a better solution for this function, accessing problem when calling Set-WinUtilTaskbaritem inside a runspace. Future me or other contributors, please fix this.
|
||||
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
|
||||
}
|
||||
@ -61,20 +92,17 @@ function Set-WinUtilTaskbaritem {
|
||||
if ($overlay) {
|
||||
switch ($overlay) {
|
||||
'logo' {
|
||||
$sync["Form"].taskbarItemInfo.Overlay = "$env:LOCALAPPDATA\winutil\cttlogo.png"
|
||||
$sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -imageFilePath "$env:LOCALAPPDATA\winutil\cttlogo.png")
|
||||
}
|
||||
'checkmark' {
|
||||
$sync["Form"].taskbarItemInfo.Overlay = "$env:LOCALAPPDATA\winutil\checkmark.png"
|
||||
}
|
||||
'warning' {
|
||||
$sync["Form"].taskbarItemInfo.Overlay = "$env:LOCALAPPDATA\winutil\warning.png"
|
||||
$sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -imageFilePath "$env:LOCALAPPDATA\winutil\cttcheckmark.png"])
|
||||
}
|
||||
'None' {
|
||||
$sync["Form"].taskbarItemInfo.Overlay = $null
|
||||
}
|
||||
default {
|
||||
if (Test-Path $overlay) {
|
||||
$sync["Form"].taskbarItemInfo.Overlay = $overlay
|
||||
$sync["Form"].taskbarItemInfo.Overlay = (ConvertTo-Bitmap -image $overlay)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ function Invoke-WPFGetIso {
|
||||
{
|
||||
# It's critical and we can't continue. Output an error
|
||||
Write-Host "You don't have enough space for this operation. You need at least $([Math]::Round(($isoSize / ([Math]::Pow(1024, 2))) * 2, 2)) MB of free space to copy the ISO files to a temp directory and to be able to perform additional operations."
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1
|
||||
return
|
||||
}
|
||||
else
|
||||
@ -126,7 +126,7 @@ function Invoke-WPFGetIso {
|
||||
Write-Error "Failed to mount the image. Error: $($_.Exception.Message)"
|
||||
Write-Error "This is NOT winutil's problem, your ISO might be corrupt, or there is a problem on the system"
|
||||
Write-Error "Please refer to this wiki for more details https://github.com/ChrisTitusTech/winutil/blob/main/wiki/Error-in-Winutil-MicroWin-during-ISO-mounting%2Cmd"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1
|
||||
return
|
||||
}
|
||||
# storing off values in hidden fields for further steps
|
||||
@ -204,7 +204,7 @@ function Invoke-WPFGetIso {
|
||||
$msg = "Neither install.wim nor install.esd exist in the image, this could happen if you use unofficial Windows images. Please don't use shady images from the internet, use only official images. Here are instructions how to download ISO images if the Microsoft website is not showing the link to download and ISO. https://www.techrepublic.com/article/how-to-download-a-windows-10-iso-file-without-using-the-media-creation-tool/"
|
||||
Write-Host $msg
|
||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1
|
||||
throw
|
||||
}
|
||||
elseif ((-not (Test-Path -Path $wimFile -PathType Leaf)) -and (Test-Path -Path $wimFile.Replace(".wim", ".esd").Trim() -PathType Leaf))
|
||||
|
@ -64,7 +64,7 @@ function Invoke-WPFInstall {
|
||||
Write-Host "==========================================="
|
||||
Write-Host "Error: $_"
|
||||
Write-Host "==========================================="
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" -overlay "warning" })
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
|
||||
}
|
||||
$sync.ProcessRunning = $False
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class PowerManagement {
|
||||
|
||||
if ($SaveDialog.FileName -eq "") {
|
||||
Write-Host "No file name for the target image was specified"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1
|
||||
return
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ public class PowerManagement {
|
||||
$msg = "The export process has failed and MicroWin processing cannot continue"
|
||||
Write-Host "Failed to export the image"
|
||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -92,7 +92,7 @@ public class PowerManagement {
|
||||
$dlg_msg = $msg + "`n`nIf you want more information, the version of the image selected is $($imgVersion)`n`nIf an image has been incorrectly marked as incompatible, report an issue to the developers."
|
||||
Write-Host $msg
|
||||
[System.Windows.MessageBox]::Show($dlg_msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Exclamation)
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1
|
||||
return
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ public class PowerManagement {
|
||||
if (-not $mountDirExists -or -not $scratchDirExists)
|
||||
{
|
||||
Write-Error "Required directories '$mountDirExists' '$scratchDirExists' and do not exist."
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1
|
||||
return
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public class PowerManagement {
|
||||
else
|
||||
{
|
||||
Write-Host "Could not mount image. Exiting..."
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1
|
||||
return
|
||||
}
|
||||
|
||||
@ -386,7 +386,7 @@ public class PowerManagement {
|
||||
if (-not (Test-Path -Path "$mountDir\sources\install.wim"))
|
||||
{
|
||||
Write-Error "Something went wrong and '$mountDir\sources\install.wim' doesn't exist. Please report this bug to the devs"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1
|
||||
return
|
||||
}
|
||||
Write-Host "Windows image completed. Continuing with boot.wim."
|
||||
|
@ -73,7 +73,7 @@ function Invoke-WPFUnInstall {
|
||||
Write-Host "==========================================="
|
||||
Write-Host "Error: $_"
|
||||
Write-Host "==========================================="
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" -overlay "warning" })
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
|
||||
}
|
||||
$sync.ProcessRunning = $False
|
||||
|
||||
|
@ -450,17 +450,12 @@ 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"
|
||||
$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"]
|
||||
}
|
||||
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"
|
||||
Set-WinUtilTaskbaritem -overlay "logo" | Out-Null
|
||||
|
||||
$sync["Form"].Add_Activated({
|
||||
Set-WinUtilTaskbaritem -overlay "logo"
|
||||
|
Loading…
Reference in New Issue
Block a user