Merge branch 'main' into compact

This commit is contained in:
MyDrift
2024-08-19 13:34:33 +02:00
205 changed files with 18709 additions and 21778 deletions

View File

@ -11,7 +11,7 @@ $InitialSessionState.Variables.Add($hashVars)
# Get every private function and add them to the session state
$functions = (Get-ChildItem function:\).where{$_.name -like "*winutil*" -or $_.name -like "*WPF*"}
foreach ($function in $functions){
foreach ($function in $functions) {
$functionDefinition = Get-Content function:\$($function.name)
$functionEntry = New-Object System.Management.Automation.Runspaces.SessionStateFunctionEntry -ArgumentList $($function.name), $functionDefinition
@ -55,12 +55,10 @@ $inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -repla
if ((Get-WinUtilToggleStatus WPFToggleDarkMode) -eq $True) {
if (Invoke-WinUtilGPU -eq $True) {
$ctttheme = 'Matrix'
}
else {
} else {
$ctttheme = 'Dark'
}
}
else {
} else {
$ctttheme = 'Classic'
}
$inputXML = Set-WinUtilUITheme -inputXML $inputXML -themeName $ctttheme
@ -106,7 +104,7 @@ $sync.keys | ForEach-Object {
})
}
if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "Button"){
if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "Button") {
$sync["$psitem"].Add_Click({
[System.Object]$Sender = $args[0]
Invoke-WPFButton $Sender.name
@ -132,7 +130,7 @@ $sync.keys | ForEach-Object {
# Load computer information in the background
Invoke-WPFRunspace -ScriptBlock {
try{
try {
$oldProgressPreference = $ProgressPreference
$ProgressPreference = "SilentlyContinue"
$sync.ConfigLoaded = $False
@ -177,8 +175,7 @@ $commonKeyEvents = {
return
}
if ($_.Key -eq "Escape")
{
if ($_.Key -eq "Escape") {
$sync.SearchBar.SelectAll()
$sync.SearchBar.Text = ""
$sync.SearchBarClearButton.Visibility = "Collapsed"
@ -186,8 +183,7 @@ $commonKeyEvents = {
}
# don't ask, I know what I'm doing, just go...
if (($_.Key -eq "Q" -and $_.KeyboardDevice.Modifiers -eq "Ctrl"))
{
if (($_.Key -eq "Q" -and $_.KeyboardDevice.Modifiers -eq "Ctrl")) {
$this.Close()
}
if ($_.KeyboardDevice.Modifiers -eq "Alt") {
@ -230,12 +226,9 @@ $sync["Form"].Add_MouseLeftButtonDown({
})
$sync["Form"].Add_MouseDoubleClick({
if ($sync["Form"].WindowState -eq [Windows.WindowState]::Normal)
{
if ($sync["Form"].WindowState -eq [Windows.WindowState]::Normal) {
$sync["Form"].WindowState = [Windows.WindowState]::Maximized;
}
else
{
} else {
$sync["Form"].WindowState = [Windows.WindowState]::Normal;
}
})
@ -281,11 +274,11 @@ Add-Type @"
foreach ($proc in (Get-Process).where{ $_.MainWindowTitle -and $_.MainWindowTitle -like "*titus*" }) {
# Check if the process's MainWindowHandle is valid
if ($proc.MainWindowHandle -ne [System.IntPtr]::Zero) {
if ($proc.MainWindowHandle -ne [System.IntPtr]::Zero) {
Write-Debug "MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle) $($proc.MainWindowHandle)"
$windowHandle = $proc.MainWindowHandle
} else {
Write-Warning "Process found, but no MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle)"
} else {
Write-Warning "Process found, but no MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle)"
}
}
@ -326,9 +319,9 @@ Add-Type @"
# maybe this is not the best place to load and execute config file?
# maybe community can help?
if ($PARAM_CONFIG){
if ($PARAM_CONFIG) {
Invoke-WPFImpex -type "import" -Config $PARAM_CONFIG
if ($PARAM_RUN){
if ($PARAM_RUN) {
while ($sync.ProcessRunning) {
Start-Sleep -Seconds 5
}
@ -374,8 +367,7 @@ $allCategories = $checkBoxes.Name | ForEach-Object {$sync.configs.applications.$
$sync["SearchBar"].Add_TextChanged({
if ($sync.SearchBar.Text -ne "") {
$sync.SearchBarClearButton.Visibility = "Visible"
}
else {
} else {
$sync.SearchBarClearButton.Visibility = "Collapsed"
}
@ -402,8 +394,7 @@ $sync["SearchBar"].Add_TextChanged({
if ($textBlock -ne $null -and $textBlock -is [System.Windows.Controls.TextBlock]) {
$textBlock.Visibility = "Visible"
}
}
else {
} else {
$CheckBox.Value.Visibility = "Collapsed"
# Set the corresponding text block visibility
if ($textBlock -ne $null -and $textBlock -is [System.Windows.Controls.TextBlock]) {
@ -467,8 +458,7 @@ $sync["SettingsButton"].Add_Click({
Write-Debug "SettingsButton clicked"
if ($sync["SettingsPopup"].IsOpen) {
$sync["SettingsPopup"].IsOpen = $false
}
else {
} else {
$sync["SettingsPopup"].IsOpen = $true
}
$_.Handled = $false
@ -524,8 +514,7 @@ $sync["SponsorMenuItem"].Add_Click({
# Append the sponsors to the authorInfo
$sponsors | ForEach-Object { $authorInfo += "$_`n" }
}
catch {
} catch {
$authorInfo += "An error occurred while fetching or processing the sponsors: $_`n"
}

View File

@ -45,8 +45,7 @@ $sync.configs = @{}
$sync.ProcessRunning = $false
# If script isn't running as admin, show error message and quit
If (([Security.Principal.WindowsIdentity]::GetCurrent()).Owner.Value -ne "S-1-5-32-544")
{
If (([Security.Principal.WindowsIdentity]::GetCurrent()).Owner.Value -ne "S-1-5-32-544") {
Write-Host "===========================================" -Foregroundcolor Red
Write-Host "-- Scripts must be run as Administrator ---" -Foregroundcolor Red
Write-Host "-- Right-Click Start -> Terminal(Admin) ---" -Foregroundcolor Red