mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-03 03:23:31 -05:00
Optimize UI Load performance
This commit is contained in:
@ -45,7 +45,7 @@ class GenericException : Exception {
|
||||
[string]$additionalData
|
||||
GenericException($Message) : base($Message) {}
|
||||
}
|
||||
|
||||
log_time_taken "Main.ps1 class setup line 48"
|
||||
|
||||
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
|
||||
|
||||
@ -77,7 +77,7 @@ if (-NOT ($readerOperationSuccessful)) {
|
||||
[System.GC]::Collect()
|
||||
exit 1
|
||||
}
|
||||
|
||||
log_time_taken "Main.ps1 xaml loaded"
|
||||
# Setup the Window to follow listen for windows Theme Change events and update the winutil theme
|
||||
# throttle logic needed, because windows seems to send more than one theme change event per change
|
||||
$lastThemeChangeTime = [datetime]::MinValue
|
||||
@ -105,20 +105,21 @@ $sync.Form.Add_Loaded({
|
||||
return 0
|
||||
})
|
||||
})
|
||||
|
||||
log_time_taken "Main.ps1 theme change event setup"
|
||||
Invoke-WinutilThemeChange -init $true
|
||||
# Load the configuration files
|
||||
|
||||
$noimage = "https://images.emojiterra.com/google/noto-emoji/unicode-15/color/512px/1f4e6.png"
|
||||
$noimage = [Windows.Media.Imaging.BitmapImage]::new([Uri]::new($noimage))
|
||||
|
||||
log_time_taken "Main.ps1 downloaded default image"
|
||||
$sync.configs.applicationsHashtable = @{}
|
||||
$sync.configs.applications.PSObject.Properties | ForEach-Object {
|
||||
$sync.configs.applicationsHashtable[$_.Name] = $_.Value
|
||||
}
|
||||
|
||||
log_time_taken "Main.ps1 loaded applications"
|
||||
# Now call the function with the final merged config
|
||||
Invoke-WPFUIElements -configVariable $sync.configs.appnavigation -targetGridName "appscategory" -columncount 1
|
||||
log_time_taken "Main.ps1 loaded appnavigation"
|
||||
# Add logic to handle click to the ToggleView Button on the Install Tab
|
||||
$sync.WPFToggleView.Add_Click({
|
||||
$sync.CompactView = -not $sync.CompactView
|
||||
@ -128,9 +129,11 @@ $sync.WPFToggleView.Add_Click({
|
||||
}
|
||||
})
|
||||
Invoke-WPFUIApps -Apps $sync.configs.applicationsHashtable -targetGridName "appspanel"
|
||||
|
||||
log_time_taken "Main.ps1 loaded appspanel"
|
||||
Invoke-WPFUIElements -configVariable $sync.configs.tweaks -targetGridName "tweakspanel" -columncount 2
|
||||
log_time_taken "Main.ps1 loaded tweakspanel"
|
||||
Invoke-WPFUIElements -configVariable $sync.configs.feature -targetGridName "featurespanel" -columncount 2
|
||||
log_time_taken "Main.ps1 loaded featurespanel"
|
||||
# Future implementation: Add Windows Version to updates panel
|
||||
#Invoke-WPFUIElements -configVariable $sync.configs.updates -targetGridName "updatespanel" -columncount 1
|
||||
|
||||
@ -580,6 +583,6 @@ $sync["SponsorMenuItem"].Add_Click({
|
||||
})
|
||||
|
||||
|
||||
|
||||
log_time_taken "Main.ps1 before ShowDialog"
|
||||
$sync["Form"].ShowDialog() | out-null
|
||||
Stop-Transcript
|
||||
|
@ -12,6 +12,16 @@ param (
|
||||
[switch]$Run
|
||||
)
|
||||
|
||||
function log_time_taken {
|
||||
param (
|
||||
[string]$description
|
||||
)
|
||||
$current_time = Get-Date
|
||||
$time_taken = $current_time - $sync.start_time
|
||||
Write-Output "[$time_taken] $description" >> $sync.log
|
||||
$sync.start_time = $current_time
|
||||
}
|
||||
|
||||
# Set DebugPreference based on the -Debug switch
|
||||
if ($Debug) {
|
||||
$DebugPreference = "Continue"
|
||||
@ -34,6 +44,8 @@ Add-Type -AssemblyName System.Windows.Forms
|
||||
|
||||
# Variable to sync between runspaces
|
||||
$sync = [Hashtable]::Synchronized(@{})
|
||||
$sync.log = "$ENV:USERPROFILE\Desktop\winutil.log"
|
||||
$sync.start_time = Get-Date
|
||||
$sync.PSScriptRoot = $PSScriptRoot
|
||||
$sync.version = "#{replaceme}"
|
||||
$sync.configs = @{}
|
||||
@ -88,3 +100,5 @@ Start-Transcript -Path "$logdir\winutil_$dateTime.log" -Append -NoClobber | Out-
|
||||
# Set PowerShell window title
|
||||
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Admin)"
|
||||
clear-host
|
||||
Write-Output "" > $sync.log
|
||||
log_time_taken "Start.ps1 finished"
|
Reference in New Issue
Block a user