mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Updated formatting
This commit is contained in:
@@ -146,11 +146,15 @@ function Set-UIValue {
|
|||||||
$itemValue = $null
|
$itemValue = $null
|
||||||
if ($item -is [System.Windows.Controls.ComboBoxItem]) {
|
if ($item -is [System.Windows.Controls.ComboBoxItem]) {
|
||||||
$itemValue = $item.Content
|
$itemValue = $item.Content
|
||||||
} elseif ($item -is [pscustomobject] -and $item.PSObject.Properties['Value']) {
|
}
|
||||||
|
elseif ($item -is [pscustomobject] -and $item.PSObject.Properties['Value']) {
|
||||||
$itemValue = $item.Value
|
$itemValue = $item.Value
|
||||||
} elseif ($item -is [pscustomobject] -and $item.PSObject.Properties['Display']) { # Assuming 'Display' might be used if 'Value' isn't
|
}
|
||||||
|
elseif ($item -is [pscustomobject] -and $item.PSObject.Properties['Display']) {
|
||||||
|
# Assuming 'Display' might be used if 'Value' isn't
|
||||||
$itemValue = $item.Display
|
$itemValue = $item.Display
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$itemValue = $item # For simple string items or direct object comparison
|
$itemValue = $item # For simple string items or direct object comparison
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,10 +168,12 @@ function Set-UIValue {
|
|||||||
if ($null -ne $itemToSelect) {
|
if ($null -ne $itemToSelect) {
|
||||||
$control.SelectedItem = $itemToSelect
|
$control.SelectedItem = $itemToSelect
|
||||||
WriteLog "LoadConfig: Successfully set '$ControlName.SelectedItem' by finding matching item for value '$finalValue'."
|
WriteLog "LoadConfig: Successfully set '$ControlName.SelectedItem' by finding matching item for value '$finalValue'."
|
||||||
} elseif ($control.IsEditable -and ($finalValue -is [string] -or $finalValue -is [int] -or $finalValue -is [long])) {
|
}
|
||||||
|
elseif ($control.IsEditable -and ($finalValue -is [string] -or $finalValue -is [int] -or $finalValue -is [long])) {
|
||||||
$control.Text = $finalValue.ToString()
|
$control.Text = $finalValue.ToString()
|
||||||
WriteLog "LoadConfig: Set '$ControlName.Text' to '$($finalValue.ToString())' as SelectedItem match failed (editable ComboBox)."
|
WriteLog "LoadConfig: Set '$ControlName.Text' to '$($finalValue.ToString())' as SelectedItem match failed (editable ComboBox)."
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$itemsString = ""
|
$itemsString = ""
|
||||||
try {
|
try {
|
||||||
# Safer way to get item strings
|
# Safer way to get item strings
|
||||||
@@ -176,10 +182,12 @@ function Set-UIValue {
|
|||||||
if ($null -ne $cbItem) { $itemStrings += $cbItem.ToString() } else { $itemStrings += "[NULL_ITEM]" }
|
if ($null -ne $cbItem) { $itemStrings += $cbItem.ToString() } else { $itemStrings += "[NULL_ITEM]" }
|
||||||
}
|
}
|
||||||
$itemsString = $itemStrings -join "; "
|
$itemsString = $itemStrings -join "; "
|
||||||
} catch { $itemsString = "Error retrieving item strings." }
|
}
|
||||||
|
catch { $itemsString = "Error retrieving item strings." }
|
||||||
WriteLog "LoadConfig Warning: Could not find or set item matching value '$finalValue' for '$ControlName.SelectedItem'. Current items: [$itemsString]"
|
WriteLog "LoadConfig Warning: Could not find or set item matching value '$finalValue' for '$ControlName.SelectedItem'. Current items: [$itemsString]"
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
# For other properties or controls
|
# For other properties or controls
|
||||||
$control.$PropertyName = $finalValue
|
$control.$PropertyName = $finalValue
|
||||||
WriteLog "LoadConfig: Successfully set '$ControlName.$PropertyName' to '$finalValue'."
|
WriteLog "LoadConfig: Successfully set '$ControlName.$PropertyName' to '$finalValue'."
|
||||||
@@ -594,7 +602,8 @@ function Get-UIConfig {
|
|||||||
$vars[$item.Key] = $item.Value
|
$vars[$item.Key] = $item.Value
|
||||||
}
|
}
|
||||||
if ($vars.Count -gt 0) { $vars } else { $null }
|
if ($vars.Count -gt 0) { $vars } else { $null }
|
||||||
} else { $null }
|
}
|
||||||
|
else { $null }
|
||||||
BuildUSBDrive = $window.FindName('chkBuildUSBDriveEnable').IsChecked
|
BuildUSBDrive = $window.FindName('chkBuildUSBDriveEnable').IsChecked
|
||||||
CleanupAppsISO = $window.FindName('chkCleanupAppsISO').IsChecked
|
CleanupAppsISO = $window.FindName('chkCleanupAppsISO').IsChecked
|
||||||
CleanupCaptureISO = $window.FindName('chkCleanupCaptureISO').IsChecked
|
CleanupCaptureISO = $window.FindName('chkCleanupCaptureISO').IsChecked
|
||||||
@@ -629,7 +638,8 @@ function Get-UIConfig {
|
|||||||
Memory = [int64]$window.FindName('txtMemory').Text * 1GB
|
Memory = [int64]$window.FindName('txtMemory').Text * 1GB
|
||||||
Model = if ($window.FindName('chkDownloadDrivers').IsChecked) {
|
Model = if ($window.FindName('chkDownloadDrivers').IsChecked) {
|
||||||
$selectedModels = $script:lstDriverModels.Items | Where-Object { $_.IsSelected }
|
$selectedModels = $script:lstDriverModels.Items | Where-Object { $_.IsSelected }
|
||||||
if ($selectedModels.Count -ge 1) { # If one or more models are selected
|
if ($selectedModels.Count -ge 1) {
|
||||||
|
# If one or more models are selected
|
||||||
$selectedModels[0].Model # Use the 'Model' property (display name) of the first selected one
|
$selectedModels[0].Model # Use the 'Model' property (display name) of the first selected one
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1110,7 +1120,8 @@ function Invoke-ListViewSort {
|
|||||||
elseif ($property -eq "Value") {
|
elseif ($property -eq "Value") {
|
||||||
$secondarySortPropertyName = "Key"
|
$secondarySortPropertyName = "Key"
|
||||||
}
|
}
|
||||||
else { # Default secondary sort for IsSelected or other properties
|
else {
|
||||||
|
# Default secondary sort for IsSelected or other properties
|
||||||
$secondarySortPropertyName = "Key"
|
$secondarySortPropertyName = "Key"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1367,7 +1378,8 @@ function Add-SelectableGridViewColumn {
|
|||||||
$headerChk = Get-Variable -Name $headerCheckboxNameFromTag -Scope Script -ValueOnly -ErrorAction SilentlyContinue
|
$headerChk = Get-Variable -Name $headerCheckboxNameFromTag -Scope Script -ValueOnly -ErrorAction SilentlyContinue
|
||||||
if ($null -ne $headerChk) {
|
if ($null -ne $headerChk) {
|
||||||
Update-SelectAllHeaderCheckBoxState -ListView $targetListView -HeaderCheckBox $headerChk
|
Update-SelectAllHeaderCheckBoxState -ListView $targetListView -HeaderCheckBox $headerChk
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
WriteLog "Add-SelectableGridViewColumn: Error - Could not retrieve script variable for header checkbox named '$headerCheckboxNameFromTag' for ListView '$listViewNameFromTag'."
|
WriteLog "Add-SelectableGridViewColumn: Error - Could not retrieve script variable for header checkbox named '$headerCheckboxNameFromTag' for ListView '$listViewNameFromTag'."
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1394,7 +1406,8 @@ function Update-SelectAllHeaderCheckBoxState {
|
|||||||
if ($null -ne $ListView.ItemsSource) {
|
if ($null -ne $ListView.ItemsSource) {
|
||||||
$collectionToInspect = @($ListView.ItemsSource)
|
$collectionToInspect = @($ListView.ItemsSource)
|
||||||
}
|
}
|
||||||
elseif ($ListView.HasItems) { # Check if Items collection has items and ItemsSource is null
|
elseif ($ListView.HasItems) {
|
||||||
|
# Check if Items collection has items and ItemsSource is null
|
||||||
$collectionToInspect = @($ListView.Items)
|
$collectionToInspect = @($ListView.Items)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1407,7 +1420,8 @@ function Update-SelectAllHeaderCheckBoxState {
|
|||||||
$selectedCount = ($collectionToInspect | Where-Object { $_.IsSelected }).Count
|
$selectedCount = ($collectionToInspect | Where-Object { $_.IsSelected }).Count
|
||||||
$totalItemCount = $collectionToInspect.Count # Get the total count from the collection being inspected
|
$totalItemCount = $collectionToInspect.Count # Get the total count from the collection being inspected
|
||||||
|
|
||||||
if ($totalItemCount -eq 0) { # Handle empty list case specifically
|
if ($totalItemCount -eq 0) {
|
||||||
|
# Handle empty list case specifically
|
||||||
$HeaderCheckBox.IsChecked = $false
|
$HeaderCheckBox.IsChecked = $false
|
||||||
}
|
}
|
||||||
elseif ($selectedCount -eq $totalItemCount) {
|
elseif ($selectedCount -eq $totalItemCount) {
|
||||||
@@ -2800,7 +2814,8 @@ $script:chkInstallApps.Add_Unchecked({
|
|||||||
$script:lstAppsScriptVariables.ItemsSource = $script:appsScriptVariablesDataList.ToArray()
|
$script:lstAppsScriptVariables.ItemsSource = $script:appsScriptVariablesDataList.ToArray()
|
||||||
|
|
||||||
# Update the header checkbox state
|
# Update the header checkbox state
|
||||||
if ($null -ne $script:chkSelectAllAppsScriptVariables) { # Check if variable exists
|
if ($null -ne $script:chkSelectAllAppsScriptVariables) {
|
||||||
|
# Check if variable exists
|
||||||
Update-SelectAllHeaderCheckBoxState -ListView $script:lstAppsScriptVariables -HeaderCheckBox $script:chkSelectAllAppsScriptVariables
|
Update-SelectAllHeaderCheckBoxState -ListView $script:lstAppsScriptVariables -HeaderCheckBox $script:chkSelectAllAppsScriptVariables
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -3238,7 +3253,8 @@ $btnLoadConfig.Add_Click({
|
|||||||
if (($configContent.PSObject.Properties.Match('AppsScriptVariables')).Count -gt 0) {
|
if (($configContent.PSObject.Properties.Match('AppsScriptVariables')).Count -gt 0) {
|
||||||
$appsScriptVarsKeyExists = $true
|
$appsScriptVarsKeyExists = $true
|
||||||
}
|
}
|
||||||
} catch { WriteLog "ERROR: Exception while trying to Match key 'AppsScriptVariables'. Error: $($_.Exception.Message)" }
|
}
|
||||||
|
catch { WriteLog "ERROR: Exception while trying to Match key 'AppsScriptVariables'. Error: $($_.Exception.Message)" }
|
||||||
}
|
}
|
||||||
|
|
||||||
$lstAppsScriptVars = $window.FindName('lstAppsScriptVariables')
|
$lstAppsScriptVars = $window.FindName('lstAppsScriptVariables')
|
||||||
@@ -3258,12 +3274,14 @@ $btnLoadConfig.Add_Click({
|
|||||||
$chkDefineAppsScriptVars.IsChecked = $true
|
$chkDefineAppsScriptVars.IsChecked = $true
|
||||||
$appsScriptVarsPanel.Visibility = 'Visible'
|
$appsScriptVarsPanel.Visibility = 'Visible'
|
||||||
WriteLog "LoadConfig: Loaded AppsScriptVariables and checked 'Define Apps Script Variables'."
|
WriteLog "LoadConfig: Loaded AppsScriptVariables and checked 'Define Apps Script Variables'."
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$chkDefineAppsScriptVars.IsChecked = $false
|
$chkDefineAppsScriptVars.IsChecked = $false
|
||||||
$appsScriptVarsPanel.Visibility = 'Collapsed'
|
$appsScriptVarsPanel.Visibility = 'Collapsed'
|
||||||
WriteLog "LoadConfig: AppsScriptVariables key was present but empty. Unchecked 'Define Apps Script Variables'."
|
WriteLog "LoadConfig: AppsScriptVariables key was present but empty. Unchecked 'Define Apps Script Variables'."
|
||||||
}
|
}
|
||||||
} elseif ($appsScriptVarsKeyExists -and $null -ne $configContent.AppsScriptVariables -and $configContent.AppsScriptVariables -is [hashtable]) {
|
}
|
||||||
|
elseif ($appsScriptVarsKeyExists -and $null -ne $configContent.AppsScriptVariables -and $configContent.AppsScriptVariables -is [hashtable]) {
|
||||||
# Handle if it's already a hashtable (e.g., from older config or direct creation)
|
# Handle if it's already a hashtable (e.g., from older config or direct creation)
|
||||||
WriteLog "LoadConfig: Processing AppsScriptVariables (Hashtable) from config."
|
WriteLog "LoadConfig: Processing AppsScriptVariables (Hashtable) from config."
|
||||||
$loadedVars = $configContent.AppsScriptVariables
|
$loadedVars = $configContent.AppsScriptVariables
|
||||||
@@ -3276,12 +3294,14 @@ $btnLoadConfig.Add_Click({
|
|||||||
$chkDefineAppsScriptVars.IsChecked = $true
|
$chkDefineAppsScriptVars.IsChecked = $true
|
||||||
$appsScriptVarsPanel.Visibility = 'Visible'
|
$appsScriptVarsPanel.Visibility = 'Visible'
|
||||||
WriteLog "LoadConfig: Loaded AppsScriptVariables (Hashtable) and checked 'Define Apps Script Variables'."
|
WriteLog "LoadConfig: Loaded AppsScriptVariables (Hashtable) and checked 'Define Apps Script Variables'."
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$chkDefineAppsScriptVars.IsChecked = $false
|
$chkDefineAppsScriptVars.IsChecked = $false
|
||||||
$appsScriptVarsPanel.Visibility = 'Collapsed'
|
$appsScriptVarsPanel.Visibility = 'Collapsed'
|
||||||
WriteLog "LoadConfig: AppsScriptVariables (Hashtable) key was present but empty. Unchecked 'Define Apps Script Variables'."
|
WriteLog "LoadConfig: AppsScriptVariables (Hashtable) key was present but empty. Unchecked 'Define Apps Script Variables'."
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$chkDefineAppsScriptVars.IsChecked = $false
|
$chkDefineAppsScriptVars.IsChecked = $false
|
||||||
$appsScriptVarsPanel.Visibility = 'Collapsed'
|
$appsScriptVarsPanel.Visibility = 'Collapsed'
|
||||||
WriteLog "LoadConfig Info: Key 'AppsScriptVariables' not found, is null, or not a PSCustomObject/Hashtable. Unchecked 'Define Apps Script Variables'."
|
WriteLog "LoadConfig Info: Key 'AppsScriptVariables' not found, is null, or not a PSCustomObject/Hashtable. Unchecked 'Define Apps Script Variables'."
|
||||||
@@ -3300,7 +3320,8 @@ $btnLoadConfig.Add_Click({
|
|||||||
if (($configContent.PSObject.Properties.Match('USBDriveList')).Count -gt 0) {
|
if (($configContent.PSObject.Properties.Match('USBDriveList')).Count -gt 0) {
|
||||||
$usbDriveListKeyExists = $true
|
$usbDriveListKeyExists = $true
|
||||||
}
|
}
|
||||||
} catch {
|
}
|
||||||
|
catch {
|
||||||
WriteLog "ERROR: Exception while trying to Match key 'USBDriveList' on configContent.PSObject.Properties. Error: $($_.Exception.Message)"
|
WriteLog "ERROR: Exception while trying to Match key 'USBDriveList' on configContent.PSObject.Properties. Error: $($_.Exception.Message)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3333,7 +3354,8 @@ $btnLoadConfig.Add_Click({
|
|||||||
if ($propertyExists -and ($propertyValue -eq $item.SerialNumber)) {
|
if ($propertyExists -and ($propertyValue -eq $item.SerialNumber)) {
|
||||||
WriteLog "LoadConfig: Selecting USB Drive Model '$($item.Model)' with Serial '$($item.SerialNumber)'."
|
WriteLog "LoadConfig: Selecting USB Drive Model '$($item.Model)' with Serial '$($item.SerialNumber)'."
|
||||||
$item.IsSelected = $true
|
$item.IsSelected = $true
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (-not $propertyExists -and ($null -ne $configContent.USBDriveList)) {
|
if (-not $propertyExists -and ($null -ne $configContent.USBDriveList)) {
|
||||||
WriteLog "LoadConfig: Property '$($propertyName)' not found on USBDriveList for item Model '$($item.Model)'."
|
WriteLog "LoadConfig: Property '$($propertyName)' not found on USBDriveList for item Model '$($item.Model)'."
|
||||||
}
|
}
|
||||||
@@ -3346,7 +3368,8 @@ $btnLoadConfig.Add_Click({
|
|||||||
$allSelected = $script:lstUSBDrives.Items.Count -gt 0 -and -not ($script:lstUSBDrives.Items | Where-Object { -not $_.IsSelected })
|
$allSelected = $script:lstUSBDrives.Items.Count -gt 0 -and -not ($script:lstUSBDrives.Items | Where-Object { -not $_.IsSelected })
|
||||||
$script:chkSelectAllUSBDrives.IsChecked = $allSelected
|
$script:chkSelectAllUSBDrives.IsChecked = $allSelected
|
||||||
WriteLog "LoadConfig: USBDriveList processing complete."
|
WriteLog "LoadConfig: USBDriveList processing complete."
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
WriteLog "LoadConfig Info: Key 'USBDriveList' not found or is null in configuration file. Skipping USB drive selection."
|
WriteLog "LoadConfig Info: Key 'USBDriveList' not found or is null in configuration file. Skipping USB drive selection."
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3359,7 +3382,8 @@ $btnLoadConfig.Add_Click({
|
|||||||
$shouldAutoCheckSpecificDrives = $true
|
$shouldAutoCheckSpecificDrives = $true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($configContent.USBDriveList -is [hashtable]) { # Fallback for older configs
|
elseif ($configContent.USBDriveList -is [hashtable]) {
|
||||||
|
# Fallback for older configs
|
||||||
if ($configContent.USBDriveList.Keys.Count -gt 0) {
|
if ($configContent.USBDriveList.Keys.Count -gt 0) {
|
||||||
$shouldAutoCheckSpecificDrives = $true
|
$shouldAutoCheckSpecificDrives = $true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user