mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-15 09:20:36 -06:00
fix layouting
This commit is contained in:
parent
26fe1f2415
commit
7cb025621d
@ -1,79 +1,79 @@
|
||||
function Invoke-WinUtilLogoviewbox {
|
||||
param (
|
||||
param (
|
||||
$type,
|
||||
$Size,
|
||||
[switch]$render
|
||||
)
|
||||
)
|
||||
|
||||
# Create the Viewbox and set its size
|
||||
$LogoViewbox = New-Object Windows.Controls.Viewbox
|
||||
$LogoViewbox.Width = $Size
|
||||
$LogoViewbox.Height = $Size
|
||||
# Create the Viewbox and set its size
|
||||
$LogoViewbox = New-Object Windows.Controls.Viewbox
|
||||
$LogoViewbox.Width = $Size
|
||||
$LogoViewbox.Height = $Size
|
||||
|
||||
# Create a Canvas to hold the paths
|
||||
$canvas = New-Object Windows.Controls.Canvas
|
||||
$canvas.Width = 100
|
||||
$canvas.Height = 100
|
||||
# Create a Canvas to hold the paths
|
||||
$canvas = New-Object Windows.Controls.Canvas
|
||||
$canvas.Width = 100
|
||||
$canvas.Height = 100
|
||||
|
||||
# Define a scale factor for the content inside the Canvas
|
||||
$scaleFactor = $Size / 100
|
||||
# Define a scale factor for the content inside the Canvas
|
||||
$scaleFactor = $Size / 100
|
||||
|
||||
# Apply a scale transform to the Canvas content
|
||||
$scaleTransform = New-Object Windows.Media.ScaleTransform($scaleFactor, $scaleFactor)
|
||||
$canvas.LayoutTransform = $scaleTransform
|
||||
# Apply a scale transform to the Canvas content
|
||||
$scaleTransform = New-Object Windows.Media.ScaleTransform($scaleFactor, $scaleFactor)
|
||||
$canvas.LayoutTransform = $scaleTransform
|
||||
|
||||
switch ($type) {
|
||||
'logo' {
|
||||
switch ($type) {
|
||||
'logo' {
|
||||
$LogoPathData1 = @"
|
||||
M 18.00,14.00
|
||||
C 18.00,14.00 45.00,27.74 45.00,27.74
|
||||
45.00,27.74 57.40,34.63 57.40,34.63
|
||||
57.40,34.63 59.00,43.00 59.00,43.00
|
||||
59.00,43.00 59.00,83.00 59.00,83.00
|
||||
55.35,81.66 46.99,77.79 44.72,74.79
|
||||
41.17,70.10 42.01,59.80 42.00,54.00
|
||||
42.00,51.62 42.20,48.29 40.98,46.21
|
||||
38.34,41.74 25.78,38.60 21.28,33.79
|
||||
16.81,29.02 18.00,20.20 18.00,14.00 Z
|
||||
M 18.00,14.00
|
||||
C 18.00,14.00 45.00,27.74 45.00,27.74
|
||||
45.00,27.74 57.40,34.63 57.40,34.63
|
||||
57.40,34.63 59.00,43.00 59.00,43.00
|
||||
59.00,43.00 59.00,83.00 59.00,83.00
|
||||
55.35,81.66 46.99,77.79 44.72,74.79
|
||||
41.17,70.10 42.01,59.80 42.00,54.00
|
||||
42.00,51.62 42.20,48.29 40.98,46.21
|
||||
38.34,41.74 25.78,38.60 21.28,33.79
|
||||
16.81,29.02 18.00,20.20 18.00,14.00 Z
|
||||
"@
|
||||
$LogoPath1 = New-Object Windows.Shapes.Path
|
||||
$LogoPath1.Data = [Windows.Media.Geometry]::Parse($LogoPathData1)
|
||||
$LogoPath1.Fill = [Windows.Media.Brushes]::Blue
|
||||
|
||||
$LogoPathData2 = @"
|
||||
M 107.00,14.00
|
||||
C 109.01,19.06 108.93,30.37 104.66,34.21
|
||||
100.47,37.98 86.38,43.10 84.60,47.21
|
||||
83.94,48.74 84.01,51.32 84.00,53.00
|
||||
83.97,57.04 84.46,68.90 83.26,72.00
|
||||
81.06,77.70 72.54,81.42 67.00,83.00
|
||||
67.00,83.00 67.00,43.00 67.00,43.00
|
||||
67.00,43.00 67.99,35.63 67.99,35.63
|
||||
67.99,35.63 80.00,28.26 80.00,28.26
|
||||
80.00,28.26 107.00,14.00 107.00,14.00 Z
|
||||
M 107.00,14.00
|
||||
C 109.01,19.06 108.93,30.37 104.66,34.21
|
||||
100.47,37.98 86.38,43.10 84.60,47.21
|
||||
83.94,48.74 84.01,51.32 84.00,53.00
|
||||
83.97,57.04 84.46,68.90 83.26,72.00
|
||||
81.06,77.70 72.54,81.42 67.00,83.00
|
||||
67.00,83.00 67.00,43.00 67.00,43.00
|
||||
67.00,43.00 67.99,35.63 67.99,35.63
|
||||
67.99,35.63 80.00,28.26 80.00,28.26
|
||||
80.00,28.26 107.00,14.00 107.00,14.00 Z
|
||||
"@
|
||||
$LogoPath2 = New-Object Windows.Shapes.Path
|
||||
$LogoPath2.Data = [Windows.Media.Geometry]::Parse($LogoPathData2)
|
||||
$LogoPath2.Fill = [Windows.Media.Brushes]::Blue
|
||||
|
||||
$LogoPathData3 = @"
|
||||
M 20.00,46.00
|
||||
C 22.36,47.14 29.67,50.71 31.01,52.63
|
||||
32.17,54.30 31.99,57.04 32.00,59.00
|
||||
32.04,65.41 31.35,72.16 34.56,78.00
|
||||
39.19,86.45 47.10,89.04 55.00,93.31
|
||||
57.55,94.69 61.10,97.20 64.00,97.22
|
||||
66.50,97.24 69.77,95.36 72.00,94.25
|
||||
77.42,91.55 85.51,87.78 89.82,83.68
|
||||
95.56,78.20 96.96,70.59 97.00,63.00
|
||||
97.01,60.24 96.59,54.63 98.02,52.39
|
||||
99.80,49.60 104.95,47.87 108.00,47.00
|
||||
108.00,47.00 108.00,67.00 108.00,67.00
|
||||
107.90,87.69 97.10,93.85 81.00,103.00
|
||||
77.51,104.98 67.66,110.67 64.00,110.52
|
||||
61.33,110.41 56.55,107.53 54.00,106.25
|
||||
47.21,102.83 37.63,98.57 32.04,93.68
|
||||
17.88,81.28 20.00,62.88 20.00,46.00 Z
|
||||
M 20.00,46.00
|
||||
C 22.36,47.14 29.67,50.71 31.01,52.63
|
||||
32.17,54.30 31.99,57.04 32.00,59.00
|
||||
32.04,65.41 31.35,72.16 34.56,78.00
|
||||
39.19,86.45 47.10,89.04 55.00,93.31
|
||||
57.55,94.69 61.10,97.20 64.00,97.22
|
||||
66.50,97.24 69.77,95.36 72.00,94.25
|
||||
77.42,91.55 85.51,87.78 89.82,83.68
|
||||
95.56,78.20 96.96,70.59 97.00,63.00
|
||||
97.01,60.24 96.59,54.63 98.02,52.39
|
||||
99.80,49.60 104.95,47.87 108.00,47.00
|
||||
108.00,47.00 108.00,67.00 108.00,67.00
|
||||
107.90,87.69 97.10,93.85 81.00,103.00
|
||||
77.51,104.98 67.66,110.67 64.00,110.52
|
||||
61.33,110.41 56.55,107.53 54.00,106.25
|
||||
47.21,102.83 37.63,98.57 32.04,93.68
|
||||
17.88,81.28 20.00,62.88 20.00,46.00 Z
|
||||
"@
|
||||
$LogoPath3 = New-Object Windows.Shapes.Path
|
||||
$LogoPath3.Data = [Windows.Media.Geometry]::Parse($LogoPathData3)
|
||||
@ -82,9 +82,8 @@ function Invoke-WinUtilLogoviewbox {
|
||||
$canvas.Children.Add($LogoPath1) | Out-Null
|
||||
$canvas.Children.Add($LogoPath2) | Out-Null
|
||||
$canvas.Children.Add($LogoPath3) | Out-Null
|
||||
|
||||
}
|
||||
'checkmark' {
|
||||
}
|
||||
'checkmark' {
|
||||
$canvas.Width = 512
|
||||
$canvas.Height = 512
|
||||
|
||||
@ -107,29 +106,28 @@ function Invoke-WinUtilLogoviewbox {
|
||||
# Add the paths to the Canvas
|
||||
$canvas.Children.Add($circlePath) | Out-Null
|
||||
$canvas.Children.Add($checkmarkPath) | Out-Null
|
||||
}
|
||||
'warning' {
|
||||
$canvas.Width = 512
|
||||
$canvas.Height = 512
|
||||
}
|
||||
'warning' {
|
||||
$canvas.Width = 512
|
||||
$canvas.Height = 512
|
||||
|
||||
# Define a scale factor for the content inside the Canvas
|
||||
$scaleFactor = $Size / 512 # Adjust scaling based on the canvas size
|
||||
$scaleTransform = New-Object Windows.Media.ScaleTransform($scaleFactor, $scaleFactor)
|
||||
$canvas.LayoutTransform = $scaleTransform
|
||||
# Define a scale factor for the content inside the Canvas
|
||||
$scaleFactor = $Size / 512 # Adjust scaling based on the canvas size
|
||||
$scaleTransform = New-Object Windows.Media.ScaleTransform($scaleFactor, $scaleFactor)
|
||||
$canvas.LayoutTransform = $scaleTransform
|
||||
|
||||
# Define the circle path
|
||||
$circlePathData = "M 256,0 A 256,256 0 1,0 256,512 A 256,256 0 1,0 256,0"
|
||||
$circlePath = New-Object Windows.Shapes.Path
|
||||
$circlePath.Data = [Windows.Media.Geometry]::Parse($circlePathData)
|
||||
$circlePath.Fill = [Windows.Media.Brushes]::Red # Set fill color to red
|
||||
# Define the circle path
|
||||
$circlePathData = "M 256,0 A 256,256 0 1,0 256,512 A 256,256 0 1,0 256,0"
|
||||
$circlePath = New-Object Windows.Shapes.Path
|
||||
$circlePath.Data = [Windows.Media.Geometry]::Parse($circlePathData)
|
||||
$circlePath.Fill = [Windows.Media.Brushes]::Red # Set fill color to red
|
||||
|
||||
# Define the exclamation mark path
|
||||
$exclamationPathData = "M 256 307.2 A 35.89 35.89 0 0 1 220.14 272.74 L 215.41 153.3 A 35.89 35.89 0 0 1 251.27 116 H 260.73 A 35.89 35.89 0 0 1 296.59 153.3 L 291.86 272.74 A 35.89 35.89 0 0 1 256 307.2 Z"
|
||||
$exclamationPath = New-Object Windows.Shapes.Path
|
||||
$exclamationPath.Data = [Windows.Media.Geometry]::Parse($exclamationPathData)
|
||||
$exclamationPath.Fill = [Windows.Media.Brushes]::White # Set fill color to white
|
||||
# Define the exclamation mark path
|
||||
$exclamationPathData = "M 256 307.2 A 35.89 35.89 0 0 1 220.14 272.74 L 215.41 153.3 A 35.89 35.89 0 0 1 251.27 116 H 260.73 A 35.89 35.89 0 0 1 296.59 153.3 L 291.86 272.74 A 35.89 35.89 0 0 1 256 307.2 Z"
|
||||
$exclamationPath = New-Object Windows.Shapes.Path
|
||||
$exclamationPath.Data = [Windows.Media.Geometry]::Parse($exclamationPathData)
|
||||
$exclamationPath.Fill = [Windows.Media.Brushes]::White # Set fill color to white
|
||||
|
||||
# Calculate the center position for the exclamation mark path
|
||||
# Get the bounds of the exclamation mark path
|
||||
$exclamationBounds = $exclamationPath.Data.Bounds
|
||||
|
||||
@ -137,39 +135,33 @@ function Invoke-WinUtilLogoviewbox {
|
||||
$exclamationCenterX = ($canvas.Width - $exclamationBounds.Width) / 2 - $exclamationBounds.X
|
||||
$exclamationPath.SetValue([Windows.Controls.Canvas]::LeftProperty, $exclamationCenterX)
|
||||
|
||||
# Define the rounded rectangle at the bottom (dot of exclamation mark)
|
||||
$roundedRectangle = New-Object Windows.Shapes.Rectangle
|
||||
$roundedRectangle.Width = 80
|
||||
$roundedRectangle.Height = 80
|
||||
$roundedRectangle.RadiusX = 30
|
||||
$roundedRectangle.RadiusY = 30
|
||||
$roundedRectangle.Fill = [Windows.Media.Brushes]::White
|
||||
|
||||
# Calculate the center position for the rounded rectangle
|
||||
$centerX = ($canvas.Width - $roundedRectangle.Width) / 2
|
||||
$roundedRectangle.SetValue([Windows.Controls.Canvas]::LeftProperty, $centerX)
|
||||
$roundedRectangle.SetValue([Windows.Controls.Canvas]::TopProperty, 324.34)
|
||||
|
||||
# Define the rounded rectangle at the bottom (dot of exclamation mark)
|
||||
$roundedRectangle = New-Object Windows.Shapes.Rectangle
|
||||
$roundedRectangle.Width = 80
|
||||
$roundedRectangle.Height = 80
|
||||
$roundedRectangle.RadiusX = 30
|
||||
$roundedRectangle.RadiusY = 30
|
||||
$roundedRectangle.Fill = [Windows.Media.Brushes]::White
|
||||
# Add the paths to the Canvas
|
||||
$canvas.Children.Add($circlePath) | Out-Null
|
||||
$canvas.Children.Add($exclamationPath) | Out-Null
|
||||
$canvas.Children.Add($roundedRectangle) | Out-Null
|
||||
}
|
||||
default {
|
||||
Write-Host "Invalid type: $type"
|
||||
}
|
||||
}
|
||||
|
||||
# Calculate the center position for the rounded rectangle
|
||||
$centerX = ($canvas.Width - $roundedRectangle.Width) / 2
|
||||
$roundedRectangle.SetValue([Windows.Controls.Canvas]::LeftProperty, $centerX)
|
||||
$roundedRectangle.SetValue([Windows.Controls.Canvas]::TopProperty, 324.34)
|
||||
# Add the Canvas to the Viewbox
|
||||
$LogoViewbox.Child = $canvas
|
||||
|
||||
|
||||
# Add the paths to the Canvas
|
||||
$canvas.Children.Add($circlePath) | Out-Null
|
||||
$canvas.Children.Add($exclamationPath) | Out-Null
|
||||
$canvas.Children.Add($roundedRectangle) | Out-Null
|
||||
|
||||
# Add the Canvas to the Viewbox
|
||||
$LogoViewbox.Child = $canvas
|
||||
}
|
||||
default {
|
||||
Write-Host "Invalid type: $type"
|
||||
}
|
||||
}
|
||||
|
||||
# Add the Canvas to the Viewbox
|
||||
$LogoViewbox.Child = $canvas
|
||||
|
||||
if ($render) {
|
||||
if ($render) {
|
||||
# Measure and arrange the canvas to ensure proper rendering
|
||||
$canvas.Measure([Windows.Size]::new($canvas.Width, $canvas.Height))
|
||||
$canvas.Arrange([Windows.Rect]::new(0, 0, $canvas.Width, $canvas.Height))
|
||||
@ -201,7 +193,7 @@ function Invoke-WinUtilLogoviewbox {
|
||||
$bitmapImage.EndInit()
|
||||
|
||||
return $bitmapImage
|
||||
} else {
|
||||
return $LogoViewbox
|
||||
}
|
||||
} else {
|
||||
return $LogoViewbox
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user