Improve layout, nav links, and help visibility

This commit is contained in:
2026-01-30 11:33:13 +13:00
parent f225be433b
commit 8e49a2d624

View File

@@ -526,6 +526,7 @@ $navSub.Size = [System.Drawing.Size]::new(140, 18)
$sidebar.Controls.Add($navSub) $sidebar.Controls.Add($navSub)
$navItems = @("Input", "DNS", "ACME", "Run", "Logs") $navItems = @("Input", "DNS", "ACME", "Run", "Logs")
$navLabels = @{}
$navY = 80 $navY = 80
foreach ($item in $navItems) { foreach ($item in $navItems) {
$navLabel = New-Object System.Windows.Forms.Label $navLabel = New-Object System.Windows.Forms.Label
@@ -535,9 +536,17 @@ foreach ($item in $navItems) {
$navLabel.Location = [System.Drawing.Point]::new(16, $navY) $navLabel.Location = [System.Drawing.Point]::new(16, $navY)
$navLabel.Size = [System.Drawing.Size]::new(140, 20) $navLabel.Size = [System.Drawing.Size]::new(140, 20)
$sidebar.Controls.Add($navLabel) $sidebar.Controls.Add($navLabel)
$navLabels[$item] = $navLabel
$navY += 26 $navY += 26
} }
$helpNavBtn = New-Object System.Windows.Forms.Button
$helpNavBtn.Text = "How to use"
$helpNavBtn.Location = [System.Drawing.Point]::new(16, ($navY + 8))
$helpNavBtn.Size = [System.Drawing.Size]::new(130, 28)
$sidebar.Controls.Add($helpNavBtn)
Style-ButtonSecondary $helpNavBtn
function Style-ButtonPrimary { function Style-ButtonPrimary {
param([System.Windows.Forms.Button]$Button) param([System.Windows.Forms.Button]$Button)
$Button.BackColor = $colorAccent $Button.BackColor = $colorAccent
@@ -616,6 +625,7 @@ function Add-SectionHeader {
$script:sectionLines.Add($sectionLine) | Out-Null $script:sectionLines.Add($sectionLine) | Out-Null
$script:y += 30 $script:y += 30
return $sectionLabel
} }
$sectionLines = New-Object System.Collections.Generic.List[System.Windows.Forms.Panel] $sectionLines = New-Object System.Collections.Generic.List[System.Windows.Forms.Panel]
@@ -651,15 +661,16 @@ $headerSub.Size = [System.Drawing.Size]::new(600, 20)
$header.Controls.Add($headerSub) $header.Controls.Add($headerSub)
$helpBtn = New-Object System.Windows.Forms.Button $helpBtn = New-Object System.Windows.Forms.Button
$helpBtn.Text = "How to use me" $helpBtn.Text = "How to use (1-5)"
$helpBtn.Size = [System.Drawing.Size]::new(140, 28) $helpBtn.Size = [System.Drawing.Size]::new(170, 32)
$helpBtn.Location = [System.Drawing.Point]::new(($header.Width - 152), 20) $helpBtn.Font = New-Object System.Drawing.Font("Segoe UI Semibold", 9)
$helpBtn.Location = [System.Drawing.Point]::new(($header.Width - 182), 18)
$header.Controls.Add($helpBtn) $header.Controls.Add($helpBtn)
Style-ButtonSecondary $helpBtn Style-ButtonPrimary $helpBtn
$y = $header.Bottom + 16 $y = $header.Bottom + 16
Add-SectionHeader "Input" $sectionInput = Add-SectionHeader "Input"
Add-Label "Hostnames (one per line)" $xLabel $y $labelWidth $rowHeight Add-Label "Hostnames (one per line)" $xLabel $y $labelWidth $rowHeight
$hostsBox = Add-TextBox $xInput $y $inputWidth 100 $true $hostsBox = Add-TextBox $xInput $y $inputWidth 100 $true
$y += 100 + $gap $y += 100 + $gap
@@ -704,7 +715,7 @@ $y += $rowHeight + $gap
$useFqdnBox = Add-CheckBox "Input contains FQDNs (otherwise default zone is appended)" $xInput $y $inputWidth $rowHeight $useFqdnBox = Add-CheckBox "Input contains FQDNs (otherwise default zone is appended)" $xInput $y $inputWidth $rowHeight
$y += $rowHeight + $gap $y += $rowHeight + $gap
Add-SectionHeader "DNS & Replication" $sectionDns = Add-SectionHeader "DNS & Replication"
Add-Label "Default DNS zone" $xLabel $y $labelWidth $rowHeight Add-Label "Default DNS zone" $xLabel $y $labelWidth $rowHeight
$zoneBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false $zoneBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false
$zoneBox.Text = "record.domain.govt.nz" $zoneBox.Text = "record.domain.govt.nz"
@@ -794,7 +805,7 @@ $y += $rowHeight + $gap
$y += $gap $y += $gap
Add-SectionHeader "ACME / Output" $sectionAcme = Add-SectionHeader "ACME / Output"
Add-Label "WACS path" $xLabel $y $labelWidth $rowHeight Add-Label "WACS path" $xLabel $y $labelWidth $rowHeight
$wacsPathBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false $wacsPathBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false
$wacsPathBox.Text = "C:\ProgramData\Wacs\wacs.exe" $wacsPathBox.Text = "C:\ProgramData\Wacs\wacs.exe"
@@ -817,7 +828,9 @@ $y += $rowHeight + $gap
$pfxPasswordLabel = Add-Label "PFX password" $xLabel $y $labelWidth $rowHeight $pfxPasswordLabel = Add-Label "PFX password" $xLabel $y $labelWidth $rowHeight
$pfxPasswordBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false $pfxPasswordBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false
$pfxPasswordBox.UseSystemPasswordChar = $true $pfxPasswordBox.UseSystemPasswordChar = $true
$pfxPasswordToggle = Add-CheckBox "Use PFX password" ($xInput + $inputWidth - 180) $y 180 $rowHeight $y += $rowHeight + $gap
$pfxPasswordToggle = Add-CheckBox "Use PFX password" $xInput $y $inputWidth $rowHeight
$pfxPasswordToggle.Checked = $true $pfxPasswordToggle.Checked = $true
$y += $rowHeight + $gap $y += $rowHeight + $gap
@@ -841,10 +854,12 @@ $validationPortBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false
$validationPortBox.Text = "9998" $validationPortBox.Text = "9998"
$y += $rowHeight + $gap $y += $rowHeight + $gap
Add-SectionHeader "Run" $sectionRun = Add-SectionHeader "Run"
$verboseBox = Add-CheckBox "Verbose" $xInput $y 120 $rowHeight $verboseBox = Add-CheckBox "Verbose" $xInput $y $inputWidth $rowHeight
$perHostBox = Add-CheckBox "One cert per host" ($xInput + 430) $y 180 $rowHeight $y += $rowHeight + $gap
$disableCertsBox = Add-CheckBox "Turn off cert generation (DNS-only mode)" ($xInput + 140) $y 360 $rowHeight $disableCertsBox = Add-CheckBox "Turn off cert generation (DNS-only mode)" $xInput $y $inputWidth $rowHeight
$y += $rowHeight + $gap
$perHostBox = Add-CheckBox "One cert per host" $xInput $y $inputWidth $rowHeight
$y += $rowHeight + ($gap * 2) $y += $rowHeight + ($gap * 2)
$runBtn = New-Object System.Windows.Forms.Button $runBtn = New-Object System.Windows.Forms.Button
@@ -869,7 +884,7 @@ $panel.Controls.Add($saveDefaultsBtn)
Style-ButtonSecondary $saveDefaultsBtn Style-ButtonSecondary $saveDefaultsBtn
$y += 40 $y += 40
Add-SectionHeader "Activity" $sectionActivity = Add-SectionHeader "Activity"
Add-Label "Activity log" $xLabel $y $labelWidth $rowHeight Add-Label "Activity log" $xLabel $y $labelWidth $rowHeight
$logBox = Add-TextBox $xInput $y $inputWidth 200 $true $logBox = Add-TextBox $xInput $y $inputWidth 200 $true
$logBox.ReadOnly = $true $logBox.ReadOnly = $true
@@ -880,6 +895,38 @@ $logAction = {
$logBox.AppendText("[$timestamp] $Message`r`n") $logBox.AppendText("[$timestamp] $Message`r`n")
} }
function Scroll-ToSection {
param([System.Windows.Forms.Control]$Target)
if (-not $Target) { return }
$panel.AutoScrollPosition = [System.Drawing.Point]::new(0, $Target.Top)
}
$sectionAnchors = @{
Input = $sectionInput
DNS = $sectionDns
ACME = $sectionAcme
Run = $sectionRun
Logs = $sectionActivity
}
foreach ($key in $sectionAnchors.Keys) {
$label = $navLabels[$key]
if (-not $label) { continue }
$target = $sectionAnchors[$key]
$localLabel = $label
$localTarget = $target
$label.Cursor = [System.Windows.Forms.Cursors]::Hand
$label.Add_Click({
Scroll-ToSection -Target $localTarget
})
$label.Add_MouseEnter({
$localLabel.ForeColor = [System.Drawing.Color]::White
})
$label.Add_MouseLeave({
$localLabel.ForeColor = [System.Drawing.Color]::FromArgb(210, 220, 236)
})
}
function Update-OutputTypeUI { function Update-OutputTypeUI {
if ($outputTypeBox.SelectedItem -eq "PEM") { if ($outputTypeBox.SelectedItem -eq "PEM") {
$outputPathLabel.Text = "PEM output path" $outputPathLabel.Text = "PEM output path"
@@ -1161,8 +1208,11 @@ function Apply-Layout {
$wacsPathBox.Width = $inputWidthCalc $wacsPathBox.Width = $inputWidthCalc
$outputTypeBox.Width = $inputWidthCalc $outputTypeBox.Width = $inputWidthCalc
$outputPathBox.Width = $inputWidthCalc $outputPathBox.Width = $inputWidthCalc
$pfxPasswordToggle.Left = $xInput + $inputWidthCalc - $pfxPasswordToggle.Width $pfxPasswordBox.Width = $inputWidthCalc
$pfxPasswordBox.Width = $inputWidthCalc - ($pfxPasswordToggle.Width + $buttonGap) $pfxPasswordToggle.Width = $inputWidthCalc
$verboseBox.Width = $inputWidthCalc
$disableCertsBox.Width = $inputWidthCalc
$perHostBox.Width = $inputWidthCalc
$baseUriBox.Width = $inputWidthCalc $baseUriBox.Width = $inputWidthCalc
$validationBox.Width = $inputWidthCalc $validationBox.Width = $inputWidthCalc
$validationPortBox.Width = $inputWidthCalc $validationPortBox.Width = $inputWidthCalc
@@ -1304,6 +1354,10 @@ $helpBtn.Add_Click({
Show-HelpDialog Show-HelpDialog
}) })
$helpNavBtn.Add_Click({
Show-HelpDialog
})
$replicationCredBtn.Add_Click({ $replicationCredBtn.Add_Click({
$cred = Get-Credential -Message "Enter credentials for replication sessions." $cred = Get-Credential -Message "Enter credentials for replication sessions."
if (-not $cred) { if (-not $cred) {