Add embedded Certy logo and icon
This commit is contained in:
87
certy.ps1
87
certy.ps1
@@ -4,6 +4,72 @@ $ErrorActionPreference = "Stop"
|
|||||||
Add-Type -AssemblyName System.Windows.Forms
|
Add-Type -AssemblyName System.Windows.Forms
|
||||||
Add-Type -AssemblyName System.Drawing
|
Add-Type -AssemblyName System.Drawing
|
||||||
|
|
||||||
|
function New-RoundedRectPath {
|
||||||
|
param(
|
||||||
|
[System.Drawing.RectangleF]$Rect,
|
||||||
|
[float]$Radius
|
||||||
|
)
|
||||||
|
$path = New-Object System.Drawing.Drawing2D.GraphicsPath
|
||||||
|
$diameter = $Radius * 2
|
||||||
|
$path.AddArc($Rect.X, $Rect.Y, $diameter, $diameter, 180, 90) | Out-Null
|
||||||
|
$path.AddArc($Rect.Right - $diameter, $Rect.Y, $diameter, $diameter, 270, 90) | Out-Null
|
||||||
|
$path.AddArc($Rect.Right - $diameter, $Rect.Bottom - $diameter, $diameter, $diameter, 0, 90) | Out-Null
|
||||||
|
$path.AddArc($Rect.X, $Rect.Bottom - $diameter, $diameter, $diameter, 90, 90) | Out-Null
|
||||||
|
$path.CloseFigure()
|
||||||
|
return $path
|
||||||
|
}
|
||||||
|
|
||||||
|
function New-CertyLogoBitmap {
|
||||||
|
param([int]$Size = 64)
|
||||||
|
$bmp = New-Object System.Drawing.Bitmap($Size, $Size)
|
||||||
|
$g = [System.Drawing.Graphics]::FromImage($bmp)
|
||||||
|
$g.SmoothingMode = "AntiAlias"
|
||||||
|
$g.Clear([System.Drawing.Color]::Transparent)
|
||||||
|
|
||||||
|
$accent = [System.Drawing.Color]::FromArgb(32, 46, 77)
|
||||||
|
$accentSoft = [System.Drawing.Color]::FromArgb(41, 58, 96)
|
||||||
|
$paper = [System.Drawing.Color]::FromArgb(255, 255, 255)
|
||||||
|
$border = [System.Drawing.Color]::FromArgb(210, 214, 222)
|
||||||
|
|
||||||
|
$pad = [Math]::Floor($Size * 0.14)
|
||||||
|
$rect = New-Object System.Drawing.RectangleF($pad, $pad, ($Size - ($pad * 2)), ($Size - ($pad * 2)))
|
||||||
|
$radius = [Math]::Max(4, [Math]::Floor($Size * 0.1))
|
||||||
|
$path = New-RoundedRectPath -Rect $rect -Radius $radius
|
||||||
|
|
||||||
|
$g.FillPath((New-Object System.Drawing.SolidBrush($paper)), $path)
|
||||||
|
$g.DrawPath((New-Object System.Drawing.Pen($border, 1.5)), $path)
|
||||||
|
|
||||||
|
$sealSize = [Math]::Floor($Size * 0.26)
|
||||||
|
$sealX = $rect.Right - $sealSize - ($pad * 0.2)
|
||||||
|
$sealY = $rect.Bottom - $sealSize - ($pad * 0.2)
|
||||||
|
$sealRect = New-Object System.Drawing.RectangleF($sealX, $sealY, $sealSize, $sealSize)
|
||||||
|
$g.FillEllipse((New-Object System.Drawing.SolidBrush($accent)), $sealRect)
|
||||||
|
|
||||||
|
$tri1 = @(
|
||||||
|
[System.Drawing.PointF]::new($sealRect.X + ($sealSize * 0.18), $sealRect.Bottom + 2),
|
||||||
|
[System.Drawing.PointF]::new($sealRect.X + ($sealSize * 0.42), $sealRect.Bottom + 2),
|
||||||
|
[System.Drawing.PointF]::new($sealRect.X + ($sealSize * 0.30), $sealRect.Bottom + ($sealSize * 0.28))
|
||||||
|
)
|
||||||
|
$tri2 = @(
|
||||||
|
[System.Drawing.PointF]::new($sealRect.X + ($sealSize * 0.58), $sealRect.Bottom + 2),
|
||||||
|
[System.Drawing.PointF]::new($sealRect.X + ($sealSize * 0.82), $sealRect.Bottom + 2),
|
||||||
|
[System.Drawing.PointF]::new($sealRect.X + ($sealSize * 0.70), $sealRect.Bottom + ($sealSize * 0.28))
|
||||||
|
)
|
||||||
|
$g.FillPolygon((New-Object System.Drawing.SolidBrush($accentSoft)), $tri1)
|
||||||
|
$g.FillPolygon((New-Object System.Drawing.SolidBrush($accentSoft)), $tri2)
|
||||||
|
|
||||||
|
$fontSize = [Math]::Floor($Size * 0.36)
|
||||||
|
$font = New-Object System.Drawing.Font("Segoe UI Semibold", $fontSize, [System.Drawing.FontStyle]::Regular, [System.Drawing.GraphicsUnit]::Pixel)
|
||||||
|
$format = New-Object System.Drawing.StringFormat
|
||||||
|
$format.Alignment = "Center"
|
||||||
|
$format.LineAlignment = "Center"
|
||||||
|
$textRect = New-Object System.Drawing.RectangleF($rect.X, $rect.Y, $rect.Width, $rect.Height)
|
||||||
|
$g.DrawString("C", $font, (New-Object System.Drawing.SolidBrush($accent)), $textRect, $format)
|
||||||
|
|
||||||
|
$g.Dispose()
|
||||||
|
return $bmp
|
||||||
|
}
|
||||||
|
|
||||||
function Split-List {
|
function Split-List {
|
||||||
param([string]$Text)
|
param([string]$Text)
|
||||||
if ([string]::IsNullOrWhiteSpace($Text)) { return @() }
|
if ([string]::IsNullOrWhiteSpace($Text)) { return @() }
|
||||||
@@ -412,6 +478,10 @@ $colorInput = [System.Drawing.Color]::FromArgb(255, 255, 255)
|
|||||||
|
|
||||||
$form.BackColor = $colorBg
|
$form.BackColor = $colorBg
|
||||||
|
|
||||||
|
$logoSmall = New-CertyLogoBitmap -Size 32
|
||||||
|
$logoLarge = New-CertyLogoBitmap -Size 64
|
||||||
|
$form.Icon = [System.Drawing.Icon]::FromHandle($logoSmall.GetHicon())
|
||||||
|
|
||||||
$sidebarWidth = 170
|
$sidebarWidth = 170
|
||||||
$sidebar = New-Object System.Windows.Forms.Panel
|
$sidebar = New-Object System.Windows.Forms.Panel
|
||||||
$sidebar.Dock = "Left"
|
$sidebar.Dock = "Left"
|
||||||
@@ -557,11 +627,18 @@ $header.BackColor = $colorPanel
|
|||||||
$header.BorderStyle = "FixedSingle"
|
$header.BorderStyle = "FixedSingle"
|
||||||
$panel.Controls.Add($header)
|
$panel.Controls.Add($header)
|
||||||
|
|
||||||
|
$logoBox = New-Object System.Windows.Forms.PictureBox
|
||||||
|
$logoBox.Image = $logoLarge
|
||||||
|
$logoBox.SizeMode = "Zoom"
|
||||||
|
$logoBox.Location = [System.Drawing.Point]::new(12, 12)
|
||||||
|
$logoBox.Size = [System.Drawing.Size]::new(40, 40)
|
||||||
|
$header.Controls.Add($logoBox)
|
||||||
|
|
||||||
$headerTitle = New-Object System.Windows.Forms.Label
|
$headerTitle = New-Object System.Windows.Forms.Label
|
||||||
$headerTitle.Text = "Certy Enterprise"
|
$headerTitle.Text = "Certy Enterprise"
|
||||||
$headerTitle.Font = New-Object System.Drawing.Font("Segoe UI Semibold", 16)
|
$headerTitle.Font = New-Object System.Drawing.Font("Segoe UI Semibold", 16)
|
||||||
$headerTitle.ForeColor = $colorText
|
$headerTitle.ForeColor = $colorText
|
||||||
$headerTitle.Location = [System.Drawing.Point]::new(12, 10)
|
$headerTitle.Location = [System.Drawing.Point]::new(60, 10)
|
||||||
$headerTitle.Size = [System.Drawing.Size]::new(300, 28)
|
$headerTitle.Size = [System.Drawing.Size]::new(300, 28)
|
||||||
$header.Controls.Add($headerTitle)
|
$header.Controls.Add($headerTitle)
|
||||||
|
|
||||||
@@ -569,7 +646,7 @@ $headerSub = New-Object System.Windows.Forms.Label
|
|||||||
$headerSub.Text = "WACS helper for DNS + ACME proxy workflows"
|
$headerSub.Text = "WACS helper for DNS + ACME proxy workflows"
|
||||||
$headerSub.Font = New-Object System.Drawing.Font("Segoe UI", 9)
|
$headerSub.Font = New-Object System.Drawing.Font("Segoe UI", 9)
|
||||||
$headerSub.ForeColor = $colorMuted
|
$headerSub.ForeColor = $colorMuted
|
||||||
$headerSub.Location = [System.Drawing.Point]::new(12, 38)
|
$headerSub.Location = [System.Drawing.Point]::new(60, 38)
|
||||||
$headerSub.Size = [System.Drawing.Size]::new(600, 20)
|
$headerSub.Size = [System.Drawing.Size]::new(600, 20)
|
||||||
$header.Controls.Add($headerSub)
|
$header.Controls.Add($headerSub)
|
||||||
|
|
||||||
@@ -1411,4 +1488,10 @@ $runBtn.Add_Click({
|
|||||||
try { Apply-Layout } catch {}
|
try { Apply-Layout } catch {}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
[void]$form.Add_FormClosed({
|
||||||
|
try { $logoBox.Image = $null } catch {}
|
||||||
|
try { $logoLarge.Dispose() } catch {}
|
||||||
|
try { $logoSmall.Dispose() } catch {}
|
||||||
|
})
|
||||||
|
|
||||||
[void]$form.ShowDialog()
|
[void]$form.ShowDialog()
|
||||||
|
|||||||
Reference in New Issue
Block a user