fix: make tweak/feature link (?) follow font scaling (#4700)

* Update Invoke-WPFUIElements.ps1

* Update Invoke-WPFUIElements.ps1

* Update Invoke-WPFUIElements.ps1

Update Invoke-WPFUIElements.ps1

* Fix tweak link margin scaling

---------

Co-authored-by: Chris Titus <contact@christitus.com>
This commit is contained in:
Paweł Gwozdowski
2026-07-04 06:51:11 +02:00
committed by GitHub
parent 8147903ff2
commit 27e590577b

View File

@@ -404,6 +404,27 @@ function Invoke-WPFUIElements {
$textBlock.ToolTip = $entryInfo.Link
$textBlock.Style = $HoverTextBlockStyle
$textBlock.UseLayoutRounding = $true
$textBlock.VerticalAlignment = "Center"
$textBlock.SetResourceReference([Windows.Controls.Control]::FontSizeProperty, "FontSize")
$textBlock.Tag = $checkBox
$updateLinkMargin = {
[System.Object]$Sender = $args[0]
$linkedCheckBox = $Sender.Tag
$MarginTopBase = if ($linkedCheckBox) { $linkedCheckBox.Margin.Top } else { 0 }
$Sender.Margin = New-Object Windows.Thickness(
[math]::Round($Sender.FontSize * 0.5),
($MarginTopBase - [math]::Round($Sender.FontSize / 2)),
0, 0
)
}
$textBlock.Add_Loaded($updateLinkMargin)
$fontSizeDescriptor = [System.ComponentModel.DependencyPropertyDescriptor]::FromProperty(
[Windows.Controls.Control]::FontSizeProperty,
[Windows.Controls.TextBlock]
)
$fontSizeDescriptor.AddValueChanged($textBlock, $updateLinkMargin)
$horizontalStackPanel.Children.Add($textBlock) | Out-Null