UI/_OptionsUIEvents.ps1
function _OptionsUIEvents { $Options.Add_SourceInitialized({ _OnOptionsSourceInitialized }) $Options.Add_Closing({ if ($HomeWindow) { $_.Cancel = $true $Options.hide() } else { $Options.close() } }) $Options_EntraIDCheckBox.Add_Click({ if ($Options_EntraIDCheckBox.IsChecked) { $Options_EntraTenantTextBox.IsEnabled = $true $Options_EntraConnectServerTextBox.IsEnabled = $true } else { $Options_EntraTenantTextBox.IsEnabled = $false $Options_EntraConnectServerTextBox.IsEnabled = $false } }) $Options_SCCMIntegrationCheckBox.Add_Click({ if ($Options_SCCMIntegrationCheckBox.IsChecked) { $Options_SCCMServerTextBox.IsEnabled = $true $Options_SCCMCollectionComboBox.IsEnabled = $true } else { $Options_SCCMServerTextBox.IsEnabled = $false $Options_SCCMCollectionComboBox.IsEnabled = $false } }) $Options_SaveSettingsButton.Add_Click({ _SaveSettings -Path "$env:APPDATA\LoganShell\" }) $Options_SelectFolderButton.Add_Click({ $FolderBrowserDialog = New-Object System.Windows.Forms.FolderBrowserDialog $FolderBrowserDialog.RootFolder = 'MyComputer' $FolderBrowserDialog.Description = 'Select default storage location' $Output = $FolderBrowserDialog.ShowDialog() if ($Output -eq 'OK') { $Options_ObjectCacheTextBox.Text = $FolderBrowserDialog.SelectedPath } }) $Options_ClearDataButton.Add_Click({ $PathToClean = $Options_ObjectCacheTextBox.Text $MessageOutput = _ShowMessageBox -MessageText "Are you sure you want to delete all items in $PathToClean" -MessageIcon Question -ButtonType YesNo -MessageTitle 'Delete all stored files' switch ($MessageOutput) { 'Yes' { $Options.Cursor = [System.Windows.Input.Cursors]::Wait # This excludes the settings file in case the location it is still appdata. Get-ChildItem -Path $PathToClean -Recurse -Exclude 'Settings.json' | Remove-Item -Force -Recurse $Options_SavingTextBlock.Text = 'Items deleted.' $Options.Cursor = $null } 'No' { # Go on about your day } } }) } |