mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-12-17 17:55:28 +00:00
Offline Capabilities
This commit is contained in:
parent
dff974144f
commit
c7495059fd
@ -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
|
||||||
|
|
||||||
|
|||||||
26
functions/private/Test-WinUtilInternetConnection.ps1
Normal file
26
functions/private/Test-WinUtilInternetConnection.ps1
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user