From 8e49a2d62462678ebbca15c8e8c961c68e3ed20d Mon Sep 17 00:00:00 2001 From: Rephl3x Date: Fri, 30 Jan 2026 11:33:13 +1300 Subject: [PATCH] Improve layout, nav links, and help visibility --- certy.ps1 | 84 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 15 deletions(-) diff --git a/certy.ps1 b/certy.ps1 index a506ee2..1b41950 100644 --- a/certy.ps1 +++ b/certy.ps1 @@ -526,6 +526,7 @@ $navSub.Size = [System.Drawing.Size]::new(140, 18) $sidebar.Controls.Add($navSub) $navItems = @("Input", "DNS", "ACME", "Run", "Logs") +$navLabels = @{} $navY = 80 foreach ($item in $navItems) { $navLabel = New-Object System.Windows.Forms.Label @@ -535,9 +536,17 @@ foreach ($item in $navItems) { $navLabel.Location = [System.Drawing.Point]::new(16, $navY) $navLabel.Size = [System.Drawing.Size]::new(140, 20) $sidebar.Controls.Add($navLabel) + $navLabels[$item] = $navLabel $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 { param([System.Windows.Forms.Button]$Button) $Button.BackColor = $colorAccent @@ -616,6 +625,7 @@ function Add-SectionHeader { $script:sectionLines.Add($sectionLine) | Out-Null $script:y += 30 + return $sectionLabel } $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) $helpBtn = New-Object System.Windows.Forms.Button -$helpBtn.Text = "How to use me" -$helpBtn.Size = [System.Drawing.Size]::new(140, 28) -$helpBtn.Location = [System.Drawing.Point]::new(($header.Width - 152), 20) +$helpBtn.Text = "How to use (1-5)" +$helpBtn.Size = [System.Drawing.Size]::new(170, 32) +$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) -Style-ButtonSecondary $helpBtn +Style-ButtonPrimary $helpBtn $y = $header.Bottom + 16 -Add-SectionHeader "Input" +$sectionInput = Add-SectionHeader "Input" Add-Label "Hostnames (one per line)" $xLabel $y $labelWidth $rowHeight $hostsBox = Add-TextBox $xInput $y $inputWidth 100 $true $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 $y += $rowHeight + $gap -Add-SectionHeader "DNS & Replication" +$sectionDns = Add-SectionHeader "DNS & Replication" Add-Label "Default DNS zone" $xLabel $y $labelWidth $rowHeight $zoneBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false $zoneBox.Text = "record.domain.govt.nz" @@ -794,7 +805,7 @@ $y += $rowHeight + $gap $y += $gap -Add-SectionHeader "ACME / Output" +$sectionAcme = Add-SectionHeader "ACME / Output" Add-Label "WACS path" $xLabel $y $labelWidth $rowHeight $wacsPathBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false $wacsPathBox.Text = "C:\ProgramData\Wacs\wacs.exe" @@ -817,7 +828,9 @@ $y += $rowHeight + $gap $pfxPasswordLabel = Add-Label "PFX password" $xLabel $y $labelWidth $rowHeight $pfxPasswordBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false $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 $y += $rowHeight + $gap @@ -841,10 +854,12 @@ $validationPortBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false $validationPortBox.Text = "9998" $y += $rowHeight + $gap -Add-SectionHeader "Run" -$verboseBox = Add-CheckBox "Verbose" $xInput $y 120 $rowHeight -$perHostBox = Add-CheckBox "One cert per host" ($xInput + 430) $y 180 $rowHeight -$disableCertsBox = Add-CheckBox "Turn off cert generation (DNS-only mode)" ($xInput + 140) $y 360 $rowHeight +$sectionRun = Add-SectionHeader "Run" +$verboseBox = Add-CheckBox "Verbose" $xInput $y $inputWidth $rowHeight +$y += $rowHeight + $gap +$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) $runBtn = New-Object System.Windows.Forms.Button @@ -869,7 +884,7 @@ $panel.Controls.Add($saveDefaultsBtn) Style-ButtonSecondary $saveDefaultsBtn $y += 40 -Add-SectionHeader "Activity" +$sectionActivity = Add-SectionHeader "Activity" Add-Label "Activity log" $xLabel $y $labelWidth $rowHeight $logBox = Add-TextBox $xInput $y $inputWidth 200 $true $logBox.ReadOnly = $true @@ -880,6 +895,38 @@ $logAction = { $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 { if ($outputTypeBox.SelectedItem -eq "PEM") { $outputPathLabel.Text = "PEM output path" @@ -1161,8 +1208,11 @@ function Apply-Layout { $wacsPathBox.Width = $inputWidthCalc $outputTypeBox.Width = $inputWidthCalc $outputPathBox.Width = $inputWidthCalc - $pfxPasswordToggle.Left = $xInput + $inputWidthCalc - $pfxPasswordToggle.Width - $pfxPasswordBox.Width = $inputWidthCalc - ($pfxPasswordToggle.Width + $buttonGap) + $pfxPasswordBox.Width = $inputWidthCalc + $pfxPasswordToggle.Width = $inputWidthCalc + $verboseBox.Width = $inputWidthCalc + $disableCertsBox.Width = $inputWidthCalc + $perHostBox.Width = $inputWidthCalc $baseUriBox.Width = $inputWidthCalc $validationBox.Width = $inputWidthCalc $validationPortBox.Width = $inputWidthCalc @@ -1304,6 +1354,10 @@ $helpBtn.Add_Click({ Show-HelpDialog }) +$helpNavBtn.Add_Click({ + Show-HelpDialog +}) + $replicationCredBtn.Add_Click({ $cred = Get-Credential -Message "Enter credentials for replication sessions." if (-not $cred) {