Offline Capabilities

This commit is contained in:
Chris Titus Tech 2025-09-18 10:26:11 -05:00
parent dff974144f
commit c7495059fd
3 changed files with 56 additions and 2 deletions

View File

@ -51,7 +51,7 @@ Update-Progress "Pre-req: Running Preprocessor..." 0
$preprocessingFilePath = ".\tools\Invoke-Preprocessing.ps1" $preprocessingFilePath = ".\tools\Invoke-Preprocessing.ps1"
. $preprocessingFilePath . $preprocessingFilePath
$excludedFiles = @('.\.git\', '.\.gitignore', '.\.gitattributes', '.\.github\CODEOWNERS', '.\LICENSE', "$preprocessingFilePath", '*.png', '*.exe','.\.preprocessor_hashes.json') $excludedFiles = @('.\.git\', '.\binary\', '.\.gitignore', '.\.gitattributes', '.\.github\CODEOWNERS', '.\LICENSE', "$preprocessingFilePath", '*.png', '*.exe','.\.preprocessor_hashes.json')
$msg = "Pre-req: Code Formatting" $msg = "Pre-req: Code Formatting"
Invoke-Preprocessing -WorkingDir "$workingdir" -ExcludedFiles $excludedFiles -ProgressStatusMessage $msg Invoke-Preprocessing -WorkingDir "$workingdir" -ExcludedFiles $excludedFiles -ProgressStatusMessage $msg

View File

@ -0,0 +1,26 @@
function Test-WinUtilInternetConnection {
<#
.SYNOPSIS
Tests if the computer has internet connectivity
.OUTPUTS
Boolean - True if connected, False if offline
#>
try {
# Test multiple reliable endpoints
$testSites = @(
"8.8.8.8", # Google DNS
"1.1.1.1", # Cloudflare DNS
"208.67.222.222" # OpenDNS
)
foreach ($site in $testSites) {
if (Test-Connection -ComputerName $site -Count 1 -Quiet -TimeoutSeconds 3 -ErrorAction SilentlyContinue) {
return $true
}
}
return $false
}
catch {
return $false
}
}

View File

@ -310,7 +310,35 @@ $sync["Form"].Add_ContentRendered({
Write-Debug "Unable to retrieve information about the primary monitor." Write-Debug "Unable to retrieve information about the primary monitor."
} }
Invoke-WPFTab "WPFTab1BT" # Check internet connectivity and disable install tab if offline
$isOnline = Test-WinUtilInternetConnection
if (-not $isOnline) {
# Disable the install tab
$sync.WPFTab1BT.IsEnabled = $false
$sync.WPFTab1BT.Opacity = 0.5
$sync.WPFTab1BT.ToolTip = "Internet connection required for installing applications"
# Disable install-related buttons
$sync.WPFInstall.IsEnabled = $false
$sync.WPFUninstall.IsEnabled = $false
$sync.WPFInstallUpgrade.IsEnabled = $false
$sync.WPFGetInstalled.IsEnabled = $false
# Show offline indicator
Write-Host "Offline mode detected - Install tab disabled" -ForegroundColor Yellow
# Optionally switch to a different tab if install tab was going to be default
Invoke-WPFTab "WPFTab2BT" # Switch to Tweaks tab instead
}
else {
# Online - ensure install tab is enabled
$sync.WPFTab1BT.IsEnabled = $true
$sync.WPFTab1BT.Opacity = 1.0
$sync.WPFTab1BT.ToolTip = $null
Invoke-WPFTab "WPFTab1BT" # Default to install tab
}
$sync["Form"].Focus() $sync["Form"].Focus()
# maybe this is not the best place to load and execute config file? # maybe this is not the best place to load and execute config file?