Skip to content
Open
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
2 changes: 0 additions & 2 deletions functions/private/Initialize-WinUtilRunspacePool.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ function Initialize-WinUtilRunspacePool {

# 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()

$initialSessionState.Variables.Add($hashVars)
$initialSessionState.Variables.Add($offlineVar)

# Get every WinUtil/WPF function and add it to the session state.
$functions = Get-ChildItem function:\ | Where-Object { $_.Name -imatch 'winutil|WPF' }
Expand Down
20 changes: 1 addition & 19 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -281,34 +281,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()
$sync["Form"].Dispatcher.BeginInvoke([System.Windows.Threading.DispatcherPriority]::Background, [action]{ Initialize-WinUtilRunspacePool | Out-Null }) | Out-Null
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