Docs: Add PowerShell comment-based help to all script modules

Adds standard PowerShell comment-based help blocks (synopsis and description) to all UI and common library script modules (`.psm1`) and the main UI entry point script (`.ps1`).

This improves maintainability and discoverability by documenting the purpose of each script file. Also removes various redundant or commented-out code blocks.
This commit is contained in:
rbalsleyMSFT
2025-07-18 14:52:03 -07:00
parent 7cc7919da4
commit 6df7b16cdf
19 changed files with 234 additions and 146 deletions
@@ -1,5 +1,9 @@
# FFU UI Core Applications Module
# Contains UI-layer logic for the "Bring Your Own Apps" and related features.
<#
.SYNOPSIS
Manages the UI business logic for the "Applications" tab, including "Bring Your Own (BYO) Applications" and "Apps Script Variables".
.DESCRIPTION
This module contains all the functions that power the "Applications" tab in the BuildFFUVM_UI. It handles user interactions for managing custom application lists (BYO Apps), such as adding, removing, reordering, and saving/loading the list from a JSON file (UserAppList.json). It also includes the logic for copying the application source files to the designated staging directory in parallel. Additionally, it manages the UI for creating and removing key-value pairs for the AppsScriptVariables.json file, which allows for custom parameterization of user-provided scripts.
#>
# Function to update the enabled state of the Copy Apps button
function Update-CopyButtonState {
@@ -1,6 +1,9 @@
# FFU UI Core Configuration Module
# Contains functions for loading and saving UI configuration.
<#
.SYNOPSIS
Contains functions for loading and saving UI configuration.
.DESCRIPTION
This module provides the core logic for loading and saving the UI configuration. It includes functions to gather settings from the various UI controls, save them to a JSON file, and load settings from a JSON file to populate the UI. This allows users to persist their build configurations and easily switch between different setups.
#>
function Get-UIConfig {
param(
[Parameter(Mandatory = $true)]
@@ -1,3 +1,10 @@
<#
.SYNOPSIS
Provides functions for discovering, downloading, and processing Dell device drivers.
.DESCRIPTION
This module contains the logic specific to handling Dell drivers for the FFU Builder UI. It includes functions to parse Dell's large XML driver catalog to retrieve a list of supported models (Get-DellDriversModelList). It also provides a parallel-capable task function (Save-DellDriversTask) that finds, downloads, extracts, and optionally compresses all the latest driver packages for a specified Dell model and operating system.
#>
# Function to get the list of Dell models from the catalog using XML streaming
function Get-DellDriversModelList {
[CmdletBinding()]
@@ -1,3 +1,15 @@
<#
.SYNOPSIS
Provides functions to retrieve HP model lists and download corresponding driver packs.
.DESCRIPTION
This module contains the logic specific to handling HP drivers for the FFU Builder UI. It includes functions to:
- Download and parse the HP PlatformList.xml to generate a list of supported HP computer models.
- For a selected model, find the most appropriate driver pack based on the specified Windows release and version, with intelligent fallback logic.
- Download the driver pack, extract all individual driver installers, and then extract the driver files from each installer.
- Optionally, compress the final extracted drivers into a single WIM file for easier deployment.
These functions are designed to be called by the main UI logic, often in parallel, to efficiently manage driver acquisition.
#>
# Function to get the list of HP models from the PlatformList.xml
function Get-HPDriversModelList {
[CmdletBinding()]
@@ -1,3 +1,10 @@
<#
.SYNOPSIS
Provides functions for discovering, downloading, and processing Lenovo drivers.
.DESCRIPTION
This module contains the logic specific to handling Lenovo drivers for the FFU Builder UI. It includes functions to query the Lenovo PSREF (Product Specification Reference) API to find and list available system models based on user search terms. It also provides the core background task for downloading all relevant driver packages for a selected model and Windows release. The download process involves parsing XML catalogs, downloading individual driver executables, silently extracting their contents, and organizing them into a structured folder. The module includes robust error handling, long path mitigation by using temporary extraction locations, and an option to compress the final driver set into a WIM archive.
#>
# Function to get the list of Lenovo models using the PSREF API
function Get-LenovoDriversModelList {
[CmdletBinding()]
@@ -1,3 +1,10 @@
<#
.SYNOPSIS
Provides functions for discovering, downloading, and processing Microsoft Surface device drivers.
.DESCRIPTION
This module contains the logic specific to handling Microsoft Surface drivers for the FFU UI. It includes a function to scrape the official Microsoft support website to build a list of available Surface models and their driver download pages. It also provides a robust, parallel-capable function to download the correct driver package (MSI or ZIP) based on the selected Windows release, extract its contents, and optionally compress them into a WIM archive. The download process includes logic to handle MSI installer mutexes to prevent conflicts during parallel execution.
#>
# Function to get the list of Microsoft Surface models
function Get-MicrosoftDriversModelList {
[CmdletBinding()]
@@ -1,3 +1,10 @@
<#
.SYNOPSIS
Provides functions for managing and downloading hardware drivers in the FFU Builder UI.
.DESCRIPTION
This module contains all the business logic for the 'Drivers' tab in the FFU Builder UI. It handles fetching driver model lists from various manufacturers (Microsoft, Dell, HP, Lenovo), displaying and filtering them in the UI, and managing the selection state. It also includes functions to import and export driver selections to a JSON file (Drivers.json) and to orchestrate the parallel download of selected driver packages using the common parallel processing module.
#>
# Helper function to get models for a selected Make and standardize them
function Get-ModelsForMake {
param(
@@ -1,3 +1,10 @@
<#
.SYNOPSIS
Contains the function for registering all WPF UI event handlers for the FFU Builder application.
.DESCRIPTION
This module is dedicated to managing user interactions within the FFU Builder UI. It contains the Register-EventHandlers function, which connects UI controls defined in the XAML to their corresponding actions in the PowerShell backend. This includes handling button clicks, text input validation, checkbox state changes, and list view interactions across all tabs, effectively wiring up the application's front-end to its core logic.
#>
function Register-EventHandlers {
param([PSCustomObject]$State)
WriteLog "Registering UI event handlers..."
@@ -1,3 +1,18 @@
<#
.SYNOPSIS
Initializes the user interface for the BuildFFUVM_UI application.
.DESCRIPTION
This script module contains functions responsible for initializing the WPF user interface.
It handles several key tasks:
- Caching references to all UI controls for efficient access.
- Populating UI elements like combo boxes with data (e.g., Hyper-V switches).
- Setting default values for all controls based on configuration or predefined settings.
- Dynamically creating and configuring complex UI components, such as sortable/selectable GridView columns and feature selection grids.
This module is critical for setting up the initial state of the application window when it first loads.
#>
function Initialize-UIControls {
param([PSCustomObject]$State)
WriteLog "Initializing UI control references..."
@@ -1,3 +1,10 @@
<#
.SYNOPSIS
Provides a collection of shared helper functions for manipulating WPF UI controls, handling asynchronous updates, and managing common UI interactions.
.DESCRIPTION
This module contains a variety of reusable functions designed to support the FFU Builder UI. It includes utilities for managing ListView controls, such as sorting, reordering items, and handling 'Select All' functionality. It also provides thread-safe mechanisms for updating the UI from background tasks, wrappers for modern and classic file/folder dialogs, and generic functions for clearing UI content. These shared functions help to reduce code duplication and ensure consistent behavior across different parts of the application.
#>
# Function to update priorities sequentially in a ListView
function Update-ListViewPriorities {
param(
@@ -96,9 +103,9 @@ function Update-ListViewItemStatus {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[object]$WindowObject, # Changed type to [object]
[object]$WindowObject,
[Parameter(Mandatory)]
[object]$ListView, # Changed type to [object]
[object]$ListView,
[Parameter(Mandatory)]
[string]$IdentifierProperty,
[Parameter(Mandatory)]
@@ -135,7 +142,7 @@ function Update-ListViewItemStatus {
catch {
WriteLog "Update-ListViewItemStatus: Error updating ListView: $($_.Exception.Message)"
}
} # End of if ($WindowObject -is [System.Windows.Window]...)
}
else {
# Log if called in non-UI mode or with incorrect types (should not happen if Invoke-ParallelProcessing $isUiMode is correct)
WriteLog "Update-ListViewItemStatus: Skipped UI update for $IdentifierValue due to non-UI mode or incorrect object types."
@@ -147,7 +154,7 @@ function Update-OverallProgress {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[object]$WindowObject, # Changed type to [object]
[object]$WindowObject,
[Parameter(Mandatory)]
[int]$CompletedCount,
[Parameter(Mandatory)]
@@ -193,7 +200,7 @@ function Update-OverallProgress {
catch {
WriteLog "Update-OverallProgress: Error updating progress: $($_.Exception.Message)"
}
} # End of if ($WindowObject -is [System.Windows.Window])
}
else {
# Log if called in non-UI mode or with incorrect types
WriteLog "Update-OverallProgress: Skipped UI update ($StatusText) due to non-UI mode or incorrect WindowObject type."
@@ -242,7 +249,6 @@ function Add-SortableColumn {
$checkBoxFactory.AddHandler([System.Windows.Controls.CheckBox]::ClickEvent, [System.Windows.RoutedEventHandler] {
param($eventSourceLocal, $eventArgsLocal)
# Sync logic would be needed here if this column had a header checkbox
})
$gridFactory.AppendChild($checkBoxFactory)
$cellTemplate.VisualTree = $gridFactory
@@ -314,7 +320,7 @@ function Add-SelectableGridViewColumn {
# MODIFICATION: Store the actual ListView object in the header's Tag
$headerTagObject = [PSCustomObject]@{
PropertyName = $IsSelectedPropertyName
ListViewControl = $ListView # Store the object itself
ListViewControl = $ListView
}
$headerCheckBox.Tag = $headerTagObject
@@ -322,7 +328,7 @@ function Add-SelectableGridViewColumn {
param($senderCheckBoxLocal, $eventArgsCheckedLocal)
$tagData = $senderCheckBoxLocal.Tag
$localPropertyName = $tagData.PropertyName
$actualListView = $tagData.ListViewControl # Get the control directly from the tag
$actualListView = $tagData.ListViewControl
$collectionToUpdate = if ($null -ne $actualListView.ItemsSource) { $actualListView.ItemsSource } else { $actualListView.Items }
if ($null -ne $collectionToUpdate) {
@@ -336,7 +342,7 @@ function Add-SelectableGridViewColumn {
if ($senderCheckBoxLocal.IsChecked -eq $false) {
$tagData = $senderCheckBoxLocal.Tag
$localPropertyName = $tagData.PropertyName
$actualListView = $tagData.ListViewControl # Get the control directly from the tag
$actualListView = $tagData.ListViewControl
$collectionToUpdate = if ($null -ne $actualListView.ItemsSource) { $actualListView.ItemsSource } else { $actualListView.Items }
if ($null -ne $collectionToUpdate) {
@@ -366,7 +372,7 @@ function Add-SelectableGridViewColumn {
# MODIFICATION: Store the actual ListView object in the item checkbox's Tag
$tagObject = [PSCustomObject]@{
HeaderCheckboxKeyName = $HeaderCheckBoxKeyName
ListViewControl = $ListView # Store the object itself
ListViewControl = $ListView
}
$checkBoxFactory.SetValue([System.Windows.FrameworkElement]::TagProperty, $tagObject)
@@ -376,7 +382,7 @@ function Add-SelectableGridViewColumn {
$tagData = $itemCheckBox.Tag
$headerCheckboxKeyFromTag = $tagData.HeaderCheckboxKeyName
$targetListView = $tagData.ListViewControl # Get the control directly from the tag
$targetListView = $tagData.ListViewControl
# Get the state from the window tag
$window = [System.Windows.Window]::GetWindow($targetListView)
@@ -1,5 +1,9 @@
# FFU UI Core Windows Settings Logic Module
# Contains UI helper functions, data retrieval, and core processing logic for the Windows Settings tab.
<#
.SYNOPSIS
Manages the business logic for the 'Windows Settings' tab in the FFU Builder UI.
.DESCRIPTION
This module contains all the functions and data required to populate and manage the controls on the 'Windows Settings' tab. It handles dynamic updates for Windows Release, Version, SKU, and Architecture ComboBoxes based on user input, such as specifying an ISO path. It also includes logic for populating available languages, media types, and the grid of optional Windows features.
#>
# --------------------------------------------------------------------------
# SECTION: Module Variables (Static Data)
@@ -170,8 +174,6 @@ $script:ltscGenericSKUs = @( # For LTSC 2019, 2021, 2024
$script:iotLtscSKUs = @(
'IoT Enterprise LTSC',
'IoT Enterprise N LTSC'
# Note: IoT SKUs are often specialized and might have different edition IDs.
# This list is a general representation. Actual ISOs might be needed for specific IoT LTSC editions.
)
# Map Windows Release Values to their corresponding SKU lists
@@ -1,9 +1,9 @@
# FFU UI Core Logic Module - Winget Functionality
# Contains UI-layer logic for the Winget functionality in the "Applications" tab.
# -----------------------------------------------------------------------------
# SECTION: Winget UI Functions (Moved from BuildFFUVM_UI.ps1)
# -----------------------------------------------------------------------------
<#
.SYNOPSIS
Manages all Winget-related functionality for the 'Applications' tab in the FFU Builder UI.
.DESCRIPTION
This module provides the business logic for interacting with Winget from the FFU Builder UI. It includes functions for searching for packages, importing and exporting application lists, checking for and installing necessary Winget components (CLI and PowerShell module), and managing the parallel download of selected applications. It works in conjunction with FFU.Common.Winget for lower-level operations and FFU.Common.Parallel for managing concurrent downloads.
#>
# Function to search for Winget apps
function Search-WingetApps {
+6 -2
View File
@@ -1,5 +1,9 @@
# FFU UI Core Logic Module
# Contains non-UI specific helper functions, data retrieval, and core processing logic.
<#
.SYNOPSIS
Core logic module for the FFU Builder UI, providing helper functions, data retrieval, and UI state management.
.DESCRIPTION
This module serves as the central logic hub for the FFU Builder UI. It contains functions for retrieving system information (like Hyper-V switches and USB drives), providing default application settings, and dynamically managing the visibility and state of various UI controls across different tabs based on user selections. It orchestrates the interactions between different parts of the UI to ensure a consistent and logical user experience.
#>
# --------------------------------------------------------------------------
# SECTION: Module Variables (Static Data & State)