Compare commits

...

7 Commits

Author SHA1 Message Date
MyDrift
1c2b301613 add error handling for styles 2024-08-20 21:32:16 +02:00
MyDrift
cbb5691982 add Dispatcher.Invoke 2024-08-20 21:03:56 +02:00
MyDrift
210d288035 little fix 2024-08-20 20:53:00 +02:00
MyDrift
c914a7bc79 move fixed values outside of iterations 2024-08-20 20:31:52 +02:00
MyDrift
60f3615926 fix some other margin issues 2024-08-20 20:09:39 +02:00
MyDrift
07436992fc fix tabcontent margin 2024-08-20 20:07:39 +02:00
MyDrift
2f7ff31630 fix margin 2024-08-20 19:47:24 +02:00
4 changed files with 55 additions and 41 deletions

View File

@ -12,8 +12,9 @@
"HeaderFontFamily": "Consolas, Monaco",
"CheckBoxBulletDecoratorFontSize": "14",
"CheckBoxMargin": "5,0,0,2",
"CheckBoxMargin": "5,0,0,1",
"TabContentMargin": "5",
"TabButtonFontSize": "14",
"TabButtonWidth": "100",
"TabButtonHeight": "25",
@ -88,6 +89,7 @@
"CheckBoxBulletDecoratorFontSize": "14",
"CheckBoxMargin": "5,0,0,1",
"TabContentMargin": "5",
"TabButtonFontSize": "14",
"TabButtonWidth": "100",
"TabButtonHeight": "25",
@ -158,8 +160,9 @@
"HeaderFontFamily": "Consolas, Monaco",
"CheckBoxBulletDecoratorFontSize": "14",
"CheckBoxMargin": "5,0,0,0.8",
"CheckBoxMargin": "5,0,0,1",
"TabContentMargin": "5",
"TabButtonFontSize": "14",
"TabButtonWidth": "100",
"TabButtonHeight": "25",

View File

@ -25,7 +25,29 @@ function Invoke-WPFUIElements {
[int]$columncount
)
$window = $sync["Form"]
$theme = $sync.configs.themes.$ctttheme
$borderstyle = $window.FindResource("BorderStyle")
$HoverTextBlockStyle = $window.FindResource("HoverTextBlockStyle")
$ColorfulToggleSwitchStyle = $window.FindResource("ColorfulToggleSwitchStyle")
if (!$borderstyle -or !$HoverTextBlockStyle -or !$ColorfulToggleSwitchStyle) {
throw "Failed to retrieve Styles using 'FindResource' from main window element."
}
$targetGrid = $window.FindName($targetGridName)
# Clear existing ColumnDefinitions and Children
$targetGrid.ColumnDefinitions.Clear() | Out-Null
$targetGrid.Children.Clear() | Out-Null
# Add ColumnDefinitions to the target Grid
for ($i = 0; $i -lt $columncount; $i++) {
$colDef = New-Object Windows.Controls.ColumnDefinition
$colDef.Width = New-Object Windows.GridLength(1, [Windows.GridUnitType]::Star)
$targetGrid.ColumnDefinitions.Add($colDef) | Out-Null
}
# Convert PSCustomObject to Hashtable
$configHashtable = @{}
@ -65,28 +87,13 @@ function Invoke-WPFUIElements {
# Store application data in an array under the category
$organizedData[$entryObject.Panel][$entryObject.Category] += $entryObject
}
# Retrieve the main window and the target Grid by name
$window = $sync["Form"]
$targetGrid = $window.FindName($targetGridName)
# Clear existing ColumnDefinitions and Children
$targetGrid.ColumnDefinitions.Clear() | Out-Null
$targetGrid.Children.Clear() | Out-Null
# Add ColumnDefinitions to the target Grid
for ($i = 0; $i -lt $columncount; $i++) {
$colDef = New-Object Windows.Controls.ColumnDefinition
$colDef.Width = New-Object Windows.GridLength(1, [Windows.GridUnitType]::Star)
$targetGrid.ColumnDefinitions.Add($colDef) | Out-Null
}
# Only apply the logic for distributing entries across columns if the targetGridName is "appspanel"
if ($targetGridName -eq "appspanel") {
$panelcount = 0
$entrycount = $configHashtable.Keys.Count + $organizedData["0"].Keys.Count
$maxcount = [Math]::Round($entrycount / $columncount + 0.5)
# Only apply the logic for distributing entries across columns if the targetGridName is "appspanel"
if ($targetGridName -eq "appspanel") {
$panelcount = 0
$entrycount = $configHashtable.Keys.Count + $organizedData["0"].Keys.Count
$maxcount = [Math]::Round($entrycount / $columncount + 0.5)
}
}
# Iterate through 'organizedData' by panel, category, and application
@ -96,7 +103,7 @@ function Invoke-WPFUIElements {
$border = New-Object Windows.Controls.Border
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
$border.style = $window.FindResource("BorderStyle")
$border.style = $borderstyle
$targetGrid.Children.Add($border) | Out-Null
# Create a StackPanel inside the Border
@ -116,7 +123,7 @@ function Invoke-WPFUIElements {
$border = New-Object Windows.Controls.Border
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
$border.style = $window.FindResource("BorderStyle")
$border.style = $borderstyle
$targetGrid.Children.Add($border) | Out-Null
# Create a new StackPanel inside the Border
@ -148,7 +155,7 @@ function Invoke-WPFUIElements {
$border = New-Object Windows.Controls.Border
$border.VerticalAlignment = "Stretch" # Ensure the border stretches vertically
[System.Windows.Controls.Grid]::SetColumn($border, $panelcount)
$border.style = $window.FindResource("BorderStyle")
$border.style = $borderstyle
$targetGrid.Children.Add($border) | Out-Null
# Create a new StackPanel inside the Border
@ -168,7 +175,7 @@ function Invoke-WPFUIElements {
$checkBox.Name = $entryInfo.Name
$checkBox.HorizontalAlignment = "Right"
$dockPanel.Children.Add($checkBox) | Out-Null
$checkBox.Style = $window.FindResource("ColorfulToggleSwitchStyle")
$checkBox.Style = $ColorfulToggleSwitchStyle
$label = New-Object Windows.Controls.Label
$label.Content = $entryInfo.Content
@ -238,7 +245,7 @@ function Invoke-WPFUIElements {
$comboBox.Width = $theme.ButtonWidth
$comboBox.HorizontalAlignment = "Left"
$comboBox.VerticalAlignment = "Center"
$comboBox.Margin = "5,5"
$comboBox.Margin = $theme.ButtonMargin
foreach ($comboitem in ($entryInfo.ComboItems -split " ")) {
$comboBoxItem = New-Object Windows.Controls.ComboBoxItem
@ -260,8 +267,7 @@ function Invoke-WPFUIElements {
$button.Name = $entryInfo.Name
$button.Content = $entryInfo.Content
$button.HorizontalAlignment = "Left"
$button.Margin = "5"
$button.Padding = "20,5"
$button.Margin = $theme.ButtonMargin
$button.FontSize = $theme.ButtonFontSize
if ($entryInfo.ButtonWidth) {
$button.Width = $entryInfo.ButtonWidth
@ -291,7 +297,7 @@ function Invoke-WPFUIElements {
$textBlock.Name = $checkBox.Name + "Link"
$textBlock.Text = "(?)"
$textBlock.ToolTip = $entryInfo.Link
$textBlock.Style = $window.FindResource("HoverTextBlockStyle")
$textBlock.Style = $HoverTextBlockStyle
# Add event handler for click to open link
$handler = [System.Windows.Input.MouseButtonEventHandler]{

View File

@ -84,10 +84,15 @@ try {
# Load the configuration files
#Invoke-WPFUIElements -configVariable $sync.configs.nav -targetGridName "WPFMainGrid"
Invoke-WPFUIElements -configVariable $sync.configs.applications -targetGridName "appspanel" -columncount 5
Invoke-WPFUIElements -configVariable $sync.configs.tweaks -targetGridName "tweakspanel" -columncount 2
Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "featurespanel" -columncount 2
$sync.form.Dispatcher.Invoke([action] {
Invoke-WPFUIElements -configVariable $sync.configs.applications -targetGridName "appspanel" -columncount 5
})
$sync.form.Dispatcher.Invoke([action] {
Invoke-WPFUIElements -configVariable $sync.configs.tweaks -targetGridName "tweakspanel" -columncount 2
})
$sync.form.Dispatcher.Invoke([action] {
Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "featurespanel" -columncount 2
})
#===========================================================================
# Store Form Objects In PowerShell

View File

@ -787,7 +787,7 @@
<RowDefinition Height="45px"/>
<RowDefinition Height="0.95*"/>
</Grid.RowDefinitions>
<StackPanel Background="{MainBackgroundColor}" Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0" Grid.ColumnSpan="3" Margin="5">
<StackPanel Background="{MainBackgroundColor}" Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0" Grid.ColumnSpan="3" Margin="{TabContentMargin}">
<Button Name="WPFinstall" Content=" Install/Upgrade Selected" Margin="2" />
<Button Name="WPFInstallUpgrade" Content=" Upgrade All" Margin="2"/>
<Button Name="WPFuninstall" Content=" Uninstall Selected" Margin="2"/>
@ -795,7 +795,7 @@
<Button Name="WPFclearWinget" Content=" Clear Selection" Margin="2"/>
</StackPanel>
<ScrollViewer x:Name="scrollViewer" Grid.Row="1" Grid.Column="0" Padding="-1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
<ScrollViewer x:Name="scrollViewer" Grid.Row="1" Grid.Column="0" Margin="{TabContentMargin}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
BorderBrush="Transparent" BorderThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid Name="appspanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
</Grid>
@ -813,7 +813,7 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="0">
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="0" Margin="{TabContentMargin}">
<Grid Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="45px"/>
@ -846,13 +846,13 @@
</Grid>
</TabItem>
<TabItem Header="Config" Visibility="Collapsed" Name="WPFTab3">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ScrollViewer VerticalScrollBarVisibility="Auto" Margin="{TabContentMargin}">
<Grid Name="featurespanel" Grid.Row="1" Background="Transparent">
</Grid>
</ScrollViewer>
</TabItem>
<TabItem Header="Updates" Visibility="Collapsed" Name="WPFTab4">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ScrollViewer VerticalScrollBarVisibility="Auto" Margin="{TabContentMargin}">
<Grid Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
@ -882,7 +882,7 @@
</ScrollViewer>
</TabItem>
<TabItem Header="MicroWin" Visibility="Collapsed" Name="WPFTab5">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ScrollViewer VerticalScrollBarVisibility="Auto" Margin="{TabContentMargin}">
<Grid Width="Auto" Height="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>