Skip to content

Commit c749505

Browse files
Offline Capabilities
1 parent dff9741 commit c749505

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

Compile.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Update-Progress "Pre-req: Running Preprocessor..." 0
5151
$preprocessingFilePath = ".\tools\Invoke-Preprocessing.ps1"
5252
. $preprocessingFilePath
5353

54-
$excludedFiles = @('.\.git\', '.\.gitignore', '.\.gitattributes', '.\.github\CODEOWNERS', '.\LICENSE', "$preprocessingFilePath", '*.png', '*.exe','.\.preprocessor_hashes.json')
54+
$excludedFiles = @('.\.git\', '.\binary\', '.\.gitignore', '.\.gitattributes', '.\.github\CODEOWNERS', '.\LICENSE', "$preprocessingFilePath", '*.png', '*.exe','.\.preprocessor_hashes.json')
5555
$msg = "Pre-req: Code Formatting"
5656
Invoke-Preprocessing -WorkingDir "$workingdir" -ExcludedFiles $excludedFiles -ProgressStatusMessage $msg
5757

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function Test-WinUtilInternetConnection {
2+
<#
3+
.SYNOPSIS
4+
Tests if the computer has internet connectivity
5+
.OUTPUTS
6+
Boolean - True if connected, False if offline
7+
#>
8+
try {
9+
# Test multiple reliable endpoints
10+
$testSites = @(
11+
"8.8.8.8", # Google DNS
12+
"1.1.1.1", # Cloudflare DNS
13+
"208.67.222.222" # OpenDNS
14+
)
15+
16+
foreach ($site in $testSites) {
17+
if (Test-Connection -ComputerName $site -Count 1 -Quiet -TimeoutSeconds 3 -ErrorAction SilentlyContinue) {
18+
return $true
19+
}
20+
}
21+
return $false
22+
}
23+
catch {
24+
return $false
25+
}
26+
}

scripts/main.ps1

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,35 @@ $sync["Form"].Add_ContentRendered({
310310
Write-Debug "Unable to retrieve information about the primary monitor."
311311
}
312312

313-
Invoke-WPFTab "WPFTab1BT"
313+
# Check internet connectivity and disable install tab if offline
314+
$isOnline = Test-WinUtilInternetConnection
315+
316+
if (-not $isOnline) {
317+
# Disable the install tab
318+
$sync.WPFTab1BT.IsEnabled = $false
319+
$sync.WPFTab1BT.Opacity = 0.5
320+
$sync.WPFTab1BT.ToolTip = "Internet connection required for installing applications"
321+
322+
# Disable install-related buttons
323+
$sync.WPFInstall.IsEnabled = $false
324+
$sync.WPFUninstall.IsEnabled = $false
325+
$sync.WPFInstallUpgrade.IsEnabled = $false
326+
$sync.WPFGetInstalled.IsEnabled = $false
327+
328+
# Show offline indicator
329+
Write-Host "Offline mode detected - Install tab disabled" -ForegroundColor Yellow
330+
331+
# Optionally switch to a different tab if install tab was going to be default
332+
Invoke-WPFTab "WPFTab2BT" # Switch to Tweaks tab instead
333+
}
334+
else {
335+
# Online - ensure install tab is enabled
336+
$sync.WPFTab1BT.IsEnabled = $true
337+
$sync.WPFTab1BT.Opacity = 1.0
338+
$sync.WPFTab1BT.ToolTip = $null
339+
Invoke-WPFTab "WPFTab1BT" # Default to install tab
340+
}
341+
314342
$sync["Form"].Focus()
315343

316344
# maybe this is not the best place to load and execute config file?

0 commit comments

Comments
 (0)