Ajout d'un README.md avec le descriptif et les instructions L'ancien README.md s'appelle désormais CHANGELOG.md Activation du pavé numérique par défaut pour les installations sans assistance Nouveau design pour la fenêtre de déploiement. Ajout de paramètre pour pouvoir procéder à une installation totalement automatisée Ajout de paramètre pour copier au choix sources, drivers ou les deux sur C:\DeployVenter avant leur usage par DISM.
63 lines
3.4 KiB
PowerShell
63 lines
3.4 KiB
PowerShell
Set-StrictMode -Version 2.0
|
|
|
|
function ConvertFrom-ThemeColor {
|
|
param([Parameter(Mandatory=$true)][string]$Value)
|
|
$hex = $Value.Trim().TrimStart('#')
|
|
if ($hex -notmatch '^[0-9A-Fa-f]{6}$') {
|
|
throw "Invalid color in theme: '$Value'. Use #RRGGBB."
|
|
}
|
|
return [System.Drawing.Color]::FromArgb(
|
|
[Convert]::ToInt32($hex.Substring(0,2),16),
|
|
[Convert]::ToInt32($hex.Substring(2,2),16),
|
|
[Convert]::ToInt32($hex.Substring(4,2),16)
|
|
)
|
|
}
|
|
|
|
function Get-DeployCenterThemeNames {
|
|
param([Parameter(Mandatory=$true)][string]$ThemesRoot)
|
|
$names = @()
|
|
foreach ($file in (Get-ChildItem -LiteralPath $ThemesRoot -Filter '*.psd1' -File -ErrorAction SilentlyContinue)) {
|
|
if ($file.BaseName -match '^[A-Za-z0-9_-]+$') { $names += $file.BaseName }
|
|
}
|
|
return @($names | Sort-Object -Unique)
|
|
}
|
|
|
|
function Import-DeployCenterTheme {
|
|
param(
|
|
[Parameter(Mandatory=$true)][string]$ThemesRoot,
|
|
[Parameter(Mandatory=$true)][string]$ThemeName
|
|
)
|
|
if ($ThemeName -notmatch '^[A-Za-z0-9_-]+$') { throw "Invalid theme name: $ThemeName" }
|
|
$path = Join-Path $ThemesRoot ($ThemeName + '.psd1')
|
|
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { throw "Theme not found: $ThemeName" }
|
|
$data = Import-PowerShellDataFile -LiteralPath $path
|
|
$required = @('Background','Panel','PanelAlt','Text','Secondary','Accent','Success','Border','Danger')
|
|
foreach ($key in $required) {
|
|
if (-not $data.ContainsKey($key)) { throw "Theme '$ThemeName' does not contain key '$key'." }
|
|
}
|
|
$theme = @{}
|
|
foreach ($key in $required) { $theme[$key] = ConvertFrom-ThemeColor -Value ([string]$data[$key]) }
|
|
foreach ($key in @('TableHeader','TableRowEven','TableRowOdd')) {
|
|
if ($data.ContainsKey($key)) { $theme[$key] = ConvertFrom-ThemeColor -Value ([string]$data[$key]) }
|
|
else { $theme[$key] = $theme.PanelAlt }
|
|
}
|
|
$buttonDefaults = @{
|
|
Button = @{ Background=$theme.PanelAlt; Foreground=$theme.Text; Border=$theme.Border; HoverBackground=$theme.Panel; PressedBackground=$theme.Border; DisabledBackground=$theme.Panel; DisabledForeground=$theme.Secondary }
|
|
PrimaryButton = @{ Background=$theme.Accent; Foreground=[System.Drawing.Color]::White; Border=$theme.Accent; HoverBackground=$theme.Accent; PressedBackground=$theme.Accent; DisabledBackground=$theme.PanelAlt; DisabledForeground=$theme.Secondary }
|
|
DangerButton = @{ Background=$theme.Danger; Foreground=[System.Drawing.Color]::White; Border=$theme.Danger; HoverBackground=$theme.Danger; PressedBackground=$theme.Danger; DisabledBackground=$theme.PanelAlt; DisabledForeground=$theme.Secondary }
|
|
}
|
|
foreach ($role in @('Button','PrimaryButton','DangerButton')) {
|
|
$theme[$role] = @{}
|
|
$provided = $data[$role]
|
|
foreach ($property in @('Background','Foreground','Border','HoverBackground','PressedBackground','DisabledBackground','DisabledForeground')) {
|
|
$raw = $null
|
|
if ($provided -is [System.Collections.IDictionary] -and $provided.Contains($property)) { $raw = [string]$provided[$property] }
|
|
if ([string]::IsNullOrWhiteSpace($raw)) { $theme[$role][$property] = $buttonDefaults[$role][$property] }
|
|
else { $theme[$role][$property] = ConvertFrom-ThemeColor -Value $raw }
|
|
}
|
|
}
|
|
return $theme
|
|
}
|
|
|
|
Export-ModuleMember -Function ConvertFrom-ThemeColor, Get-DeployCenterThemeNames, Import-DeployCenterTheme
|