RSOP/_RSOPWindowUIEvents.ps1
function _RSOPWindowUIEvents { #region General UI $RSOP.Add_SourceInitialized({ _OnRSOPSourceInitialized }) $RSOP.Add_Loaded({ # _OnADLookupsLoaded }) $RSOP.Add_Activated({ $HomeWindow_LoadingLabel.Visibility = 'Hidden' }) $RSOP.Add_Closing({ if ($HomeWindow) { $_.Cancel = $true $RSOP.hide() } else { $RSOP.close() } }) $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({ if ($RSOP_HTMLRadioButton.IsChecked) { $Splat = @{ ReportType = 'HTML' Identity = $RSOP_HostnameComboBox.Text # TODO this should be a path from a UI Path = $STTSettings.ObjectsSettings.ObjectStorageFolder } } elseif ($RSOP_ListingRadioButton.IsChecked) { $Splat = @{ ReportType = 'Listing' Identity = $RSOP_HostnameComboBox.Text # TODO this should be a path from a UI Path = $STTSettings.ObjectsSettings.ObjectStorageFolder } } $RSOP.Cursor = [System.Windows.Input.Cursors]::Wait 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 }) } |