Guard Update-ReplicationUI calls

This commit is contained in:
2026-01-29 10:11:10 +13:00
parent 0611adda2f
commit 22714b536d

View File

@@ -679,6 +679,15 @@ function Update-OutputTypeUI {
} }
} }
function Update-ReplicationUI {
$enabled = $replicationEnabledBox.Checked
$replicationTargetsBox.Enabled = $enabled
$replicationFromSelectedBtn.Enabled = $enabled
$primaryFromSelectedBtn.Enabled = $enabled
$replicationCmdBox.Enabled = $enabled
$dnsListBox.Enabled = $enabled
}
$loadedDefaults = Load-Defaults $loadedDefaults = Load-Defaults
if ($loadedDefaults) { if ($loadedDefaults) {
if ($loadedDefaults.DefaultZone) { $zoneBox.Text = $loadedDefaults.DefaultZone } if ($loadedDefaults.DefaultZone) { $zoneBox.Text = $loadedDefaults.DefaultZone }
@@ -702,7 +711,7 @@ if ($loadedDefaults) {
if ($loadedDefaults.OutputType) { $outputTypeBox.SelectedItem = $loadedDefaults.OutputType } if ($loadedDefaults.OutputType) { $outputTypeBox.SelectedItem = $loadedDefaults.OutputType }
if (-not $outputTypeBox.SelectedItem) { $outputTypeBox.SelectedIndex = 0 } if (-not $outputTypeBox.SelectedItem) { $outputTypeBox.SelectedIndex = 0 }
Update-OutputTypeUI Update-OutputTypeUI
Update-ReplicationUI if (Test-Path function:Update-ReplicationUI) { Update-ReplicationUI }
& $logAction "Defaults loaded from $(Get-DefaultsPath)." & $logAction "Defaults loaded from $(Get-DefaultsPath)."
} }
@@ -747,15 +756,6 @@ function Apply-Layout {
$saveDefaultsBtn.Left = $clearBtn.Left + $clearBtn.Width + $buttonGap $saveDefaultsBtn.Left = $clearBtn.Left + $clearBtn.Width + $buttonGap
} }
function Update-ReplicationUI {
$enabled = $replicationEnabledBox.Checked
$replicationTargetsBox.Enabled = $enabled
$replicationFromSelectedBtn.Enabled = $enabled
$primaryFromSelectedBtn.Enabled = $enabled
$replicationCmdBox.Enabled = $enabled
$dnsListBox.Enabled = $enabled
}
$browseBtn.Add_Click({ $browseBtn.Add_Click({
$dialog = New-Object System.Windows.Forms.OpenFileDialog $dialog = New-Object System.Windows.Forms.OpenFileDialog
$dialog.Filter = "Text/CSV files (*.txt;*.csv)|*.txt;*.csv|All files (*.*)|*.*" $dialog.Filter = "Text/CSV files (*.txt;*.csv)|*.txt;*.csv|All files (*.*)|*.*"
@@ -773,7 +773,7 @@ $browseBtn.Add_Click({
}) })
$replicationEnabledBox.Add_CheckedChanged({ $replicationEnabledBox.Add_CheckedChanged({
Update-ReplicationUI if (Test-Path function:Update-ReplicationUI) { Update-ReplicationUI }
}) })
$filePreviewBtn.Add_Click({ $filePreviewBtn.Add_Click({