MyDrift 2024-07-09 00:52:24 +02:00
parent b47036630c
commit a86b07a826
11 changed files with 37 additions and 0 deletions

View File

@ -14,15 +14,19 @@ function Install-WinUtilChoco {
return return
} }
$sync["Form"].taskbarItemInfo.ProgressState = "Indeterminate"
Write-Host "Seems Chocolatey is not installed, installing now." Write-Host "Seems Chocolatey is not installed, installing now."
Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) -ErrorAction Stop Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) -ErrorAction Stop
powershell choco feature enable -n allowGlobalConfirmation powershell choco feature enable -n allowGlobalConfirmation
$sync["Form"].taskbarItemInfo.ProgressState = "None"
} }
Catch { Catch {
Write-Host "===========================================" -Foregroundcolor Red Write-Host "===========================================" -Foregroundcolor Red
Write-Host "-- Chocolatey failed to install ---" -Foregroundcolor Red Write-Host "-- Chocolatey failed to install ---" -Foregroundcolor Red
Write-Host "===========================================" -Foregroundcolor Red Write-Host "===========================================" -Foregroundcolor Red
$sync["Form"].taskbarItemInfo.ProgressState = "Error"
} }
} }

View File

@ -80,6 +80,7 @@ function Install-WinUtilProgramChoco {
} }
} }
$x++ $x++
# $sync["Form"].TaskbarItemInfo.ProgressValue = $x/$count
} }
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed

View File

@ -97,6 +97,7 @@ Function Install-WinUtilProgramWinget {
} }
} }
$X++ $X++
# $sync["Form"].TaskbarItemInfo.ProgressValue = $x/$count
} }
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
return $failedPackages; return $failedPackages;

View File

@ -19,6 +19,8 @@ function Install-WinUtilWinget {
Write-Host "`nWinget is not Installed. Continuing with install.`r" -ForegroundColor Red Write-Host "`nWinget is not Installed. Continuing with install.`r" -ForegroundColor Red
} }
$sync["Form"].taskbarItemInfo.ProgressState = "Indeterminate"
# Gets the computer's information # Gets the computer's information
if ($null -eq $sync.ComputerInfo){ if ($null -eq $sync.ComputerInfo){
$ComputerInfo = Get-ComputerInfo -ErrorAction Stop $ComputerInfo = Get-ComputerInfo -ErrorAction Stop
@ -63,4 +65,5 @@ function Install-WinUtilWinget {
throw [WingetFailedInstall]::new('Failed to install!') throw [WingetFailedInstall]::new('Failed to install!')
} }
} }
$sync["Form"].taskbarItemInfo.ProgressState = "None"
} }

View File

@ -10,6 +10,9 @@ function Invoke-WinUtilFeatureInstall {
$CheckBox $CheckBox
) )
$sync["Form"].taskbarItemInfo.ProgressState = "Normal"
$sync["Form"].taskbarItemInfo.ProgressValue = 1 # Get amount of affected features & scripts
$CheckBox | ForEach-Object { $CheckBox | ForEach-Object {
if($sync.configs.feature.$psitem.feature){ if($sync.configs.feature.$psitem.feature){
Foreach( $feature in $sync.configs.feature.$psitem.feature ){ Foreach( $feature in $sync.configs.feature.$psitem.feature ){
@ -23,6 +26,7 @@ function Invoke-WinUtilFeatureInstall {
} }
else{ else{
$sync["Form"].taskbarItemInfo.ProgressState = "Error"
Write-Warning "Unable to Install $feature due to unhandled exception" Write-Warning "Unable to Install $feature due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace Write-Warning $psitem.Exception.StackTrace
} }
@ -43,6 +47,7 @@ function Invoke-WinUtilFeatureInstall {
} }
else{ else{
$sync["Form"].taskbarItemInfo.ProgressState = "Error"
Write-Warning "Unable to Install $feature due to unhandled exception" Write-Warning "Unable to Install $feature due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace Write-Warning $psitem.Exception.StackTrace
} }
@ -50,4 +55,7 @@ function Invoke-WinUtilFeatureInstall {
} }
} }
} }
if ($sync["Form"].taskbarItemInfo.ProgressState -ne "Error"){
$sync["Form"].taskbarItemInfo.ProgressState = "None"
}
} }

View File

@ -24,6 +24,7 @@ function Invoke-WPFGetInstalled {
param($checkbox, $DebugPreference) param($checkbox, $DebugPreference)
$sync.ProcessRunning = $true $sync.ProcessRunning = $true
# $sync["Form"].taskbarItemInfo.ProgressState = "Indeterminate"
if($checkbox -eq "winget"){ if($checkbox -eq "winget"){
Write-Host "Getting Installed Programs..." Write-Host "Getting Installed Programs..."
@ -42,5 +43,6 @@ function Invoke-WPFGetInstalled {
Write-Host "Done..." Write-Host "Done..."
$sync.ProcessRunning = $false $sync.ProcessRunning = $false
# $sync["Form"].taskbarItemInfo.ProgressState = "None"
} }
} }

View File

@ -15,6 +15,8 @@ function Invoke-WPFGetIso {
$sync.BusyMessage.Visibility="Visible" $sync.BusyMessage.Visibility="Visible"
$sync.BusyText.Text="N Busy" $sync.BusyText.Text="N Busy"
$sync["Form"].taskbarItemInfo.ProgressState = "Indeterminate"
Write-Host " _ __ __ _ " Write-Host " _ __ __ _ "
Write-Host " /\/\ (_) ___ _ __ ___ / / /\ \ \(_) _ __ " Write-Host " /\/\ (_) ___ _ __ ___ / / /\ \ \(_) _ __ "
@ -239,6 +241,7 @@ function Invoke-WPFGetIso {
$sync.BusyMessage.Visibility="Hidden" $sync.BusyMessage.Visibility="Hidden"
$sync.ProcessRunning = $false $sync.ProcessRunning = $false
$sync["Form"].taskbarItemInfo.ProgressState = "None"
} }

View File

@ -20,6 +20,8 @@ function Invoke-WPFInstall {
return return
} }
$sync["Form"].taskbarItemInfo.ProgressState = "Normal"
Invoke-WPFRunspace -ArgumentList $PackagesToInstall -DebugPreference $DebugPreference -ScriptBlock { Invoke-WPFRunspace -ArgumentList $PackagesToInstall -DebugPreference $DebugPreference -ScriptBlock {
param($PackagesToInstall, $DebugPreference) param($PackagesToInstall, $DebugPreference)
$packagesWinget, $packagesChoco = { $packagesWinget, $packagesChoco = {
@ -52,11 +54,13 @@ function Invoke-WPFInstall {
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "-- Installs have finished ---" Write-Host "-- Installs have finished ---"
Write-Host "===========================================" Write-Host "==========================================="
# $sync["Form"].taskbarItemInfo.ProgressState = "Indeterminate"
} }
Catch { Catch {
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "Error: $_" Write-Host "Error: $_"
Write-Host "===========================================" Write-Host "==========================================="
# $sync["Form"].taskbarItemInfo.ProgressState = "Error"
} }
Start-Sleep -Seconds 5 Start-Sleep -Seconds 5
$sync.ProcessRunning = $False $sync.ProcessRunning = $False

View File

@ -4,6 +4,8 @@ function Invoke-WPFMicrowin {
Invoke MicroWin routines... Invoke MicroWin routines...
#> #>
$sync["Form"].taskbarItemInfo.ProgressState = "Indeterminate"
if($sync.ProcessRunning) { if($sync.ProcessRunning) {
$msg = "GetIso process is currently running." $msg = "GetIso process is currently running."
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
@ -477,5 +479,6 @@ public class PowerManagement {
# Allow the machine to sleep again (optional) # Allow the machine to sleep again (optional)
[PowerManagement]::SetThreadExecutionState(0) [PowerManagement]::SetThreadExecutionState(0)
$sync.ProcessRunning = $false $sync.ProcessRunning = $false
$sync["Form"].taskbarItemInfo.ProgressState = "None"
} }
} }

View File

@ -29,6 +29,8 @@ function Invoke-WPFUnInstall {
if($confirm -eq "No"){return} if($confirm -eq "No"){return}
$sync["Form"].taskbarItemInfo.ProgressState = "Normal"
Invoke-WPFRunspace -ArgumentList $PackagesToInstall -DebugPreference $DebugPreference -ScriptBlock { Invoke-WPFRunspace -ArgumentList $PackagesToInstall -DebugPreference $DebugPreference -ScriptBlock {
param($PackagesToInstall, $DebugPreference) param($PackagesToInstall, $DebugPreference)
$packagesWinget, $packagesChoco = { $packagesWinget, $packagesChoco = {
@ -66,11 +68,13 @@ function Invoke-WPFUnInstall {
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "-- Uninstalls have finished ---" Write-Host "-- Uninstalls have finished ---"
Write-Host "===========================================" Write-Host "==========================================="
# $sync["Form"].taskbarItemInfo.ProgressState = "Indeterminate"
} }
Catch { Catch {
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "Error: $_" Write-Host "Error: $_"
Write-Host "===========================================" Write-Host "==========================================="
# $sync["Form"].taskbarItemInfo.ProgressState = "Error"
} }
$sync.ProcessRunning = $False $sync.ProcessRunning = $False
} }

View File

@ -153,6 +153,10 @@ Invoke-WPFRunspace -ScriptBlock {
# Print the logo # Print the logo
Invoke-WPFFormVariables Invoke-WPFFormVariables
# https://learn.microsoft.com/en-us/dotnet/api/system.windows.shell.taskbariteminfo?view=windowsdesktop-8.0
$sync["Form"].TaskbarItemInfo = New-Object System.Windows.Shell.TaskbarItemInfo
$sync["Form"].taskbarItemInfo.ProgressState = "None"
# Set the titlebar # Set the titlebar
$sync["Form"].title = $sync["Form"].title + " " + $sync.version $sync["Form"].title = $sync["Form"].title + " " + $sync.version
# Set the commands that will run when the form is closed # Set the commands that will run when the form is closed