Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ $maxthreads = [int]$env:NUMBER_OF_PROCESSORS

# Create a new session state for parsing variables into our runspace
$hashVars = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'sync',$sync,$Null
$offlineVar = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'PARAM_OFFLINE',$PARAM_OFFLINE,$Null
$InitialSessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault()

# Add the variable to the session state
$InitialSessionState.Variables.Add($hashVars)
$InitialSessionState.Variables.Add($offlineVar)

# Get every private function and add them to the session state
$functions = Get-ChildItem function:\ | Where-Object { $_.Name -imatch 'winutil|WPF' }
Expand Down Expand Up @@ -339,34 +337,16 @@ $sync["Form"].Add_ContentRendered({
}
}

if ($PARAM_OFFLINE) {
if ($Offline) {
# Show offline banner
$sync.WPFOfflineBanner.Visibility = [System.Windows.Visibility]::Visible

# 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()
})
Expand Down
5 changes: 0 additions & 5 deletions scripts/start.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ param (
[switch]$Offline
)

$PARAM_OFFLINE = $false
if ($Offline) {
$PARAM_OFFLINE = $true
}

if ($ExecutionContext.SessionState.LanguageMode -ne 'FullLanguage') {
Write-Host "WinUtil is unable to run on your system. PowerShell execution is restricted by security policies." -ForegroundColor Red
return
Expand Down