Private/RSOP/_RSOPWindowUIEvents.ps1
function _RSOPWindowUIEvents { #region General UI $RSOP.Add_SourceInitialized({ _OnRSOPSourceInitialized }) $RSOP.Add_Activated({ if ($HomeWindow) { $HomeWindow_LoadingLabel.Visibility = 'Hidden' } }) $RSOP.Add_Closing({ if ($HomeWindow -or $ADLookups) { $_.Cancel = $true $RSOP.hide() } else { # $RSOP.close() } }) #endregion $RSOP_UserScopeRadioButton.Add_Checked({ $RSOP_UsernameScopeComboBox.IsEnabled = $true }) $RSOP_UserScopeRadioButton.Add_UnChecked({ $RSOP_UsernameScopeComboBox.IsEnabled = $false }) $RSOP_HTMLRadioButton.Add_Checked({ $RSOP_PromptCredsCheckBox.IsEnabled = $false }) $RSOP_ListingRadioButton.Add_Checked({ $RSOP_PromptCredsCheckBox.IsEnabled = $true }) $RSOP_RunReportButton.Add_Click({ $RSOP.Cursor = [System.Windows.Input.Cursors]::Wait $RSOP_LoadingLabel.Visibility = 'Visible' if ($RSOP_HTMLRadioButton.IsChecked) { $Splat = @{ ReportType = 'HTML' Identity = $RSOP_HostnameComboBox.Text # The saving of settings now validates a trailing \ in the same way so this shouldn't be an issue. Path = if ($STTSettings.ObjectsSettings.ObjectStorageFolder[-1] -eq '\') { $STTSettings.ObjectsSettings.ObjectStorageFolder } else { $STTSettings.ObjectsSettings.ObjectStorageFolder + '\' } } } elseif ($RSOP_ListingRadioButton.IsChecked) { $Splat = @{ ReportType = 'Listing' Identity = $RSOP_HostnameComboBox.Text Path = $STTSettings.ObjectsSettings.ObjectStorageFolder } } if ($Credentials) { Write-Verbose 'Credentials already input.' $Splat += @{ Credential = $Credentials } } if ($RSOP_PromptCredsCheckBox.IsChecked) { $Global:Credentials = Get-Credential -Message 'Credentials for RSOP' -UserName "$ENV:USERDOMAIN\$ENV:USERNAME" $RSOP_CredentialsStatusBarItem.Content = "Stored username: $($Credentials.Username)" $Splat += @{ Credential = $Credentials } } if (Test-Connection -ComputerName $Splat.Identity -Count 1 -Quiet) { _RunRSOPReport @Splat } else { _ShowMessageBox -MessageText "$($Splat.Identity) appears offline." -MessageTitle 'Server offline' -MessageIcon 'Hand' -ButtonType 'OK' } $RSOP.Cursor = $null $RSOP_LoadingLabel.Visibility = 'Hidden' }) } |