Private/HomeWindow/_HomeWindowUIEvents.ps1

function _HomeWindowUIEvents {
    #region General UI
    $HomeWindow.Add_SourceInitialized({
            _OnHomeWindowSourceInitialized
        })
    $HomeWindow_ExitMenuItem.Add_Click({
            $HomeWindow.close()
        })
    $HomeWindow_AboutMenuItem.Add_Click({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait
            _ShowAbout
            $HomeWindow.Cursor = $null
        })

    $HomeWindow_OptionsMenuItem.Add_Click({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait
            $HomeWindow_LoadingLabel.Visibility = 'Visible'
            $Options.ShowDialog()
            $HomeWindow_LoadingLabel.Visibility = 'Hidden'
            $HomeWindow.Cursor = $null
        })

    $HomeWindow_HelpButton.Add_Click({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait
            $HomeWindow_LoadingLabel.Visibility = 'Visible'
            $CmdletHelp.ShowDialog()
            $HomeWindow_LoadingLabel.Visibility = 'Hidden'
            $HomeWindow.Cursor = $null
        })

    $HomeWindow_PassphraseMenuItem.Add_Click({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait
            $HomeWindow_LoadingLabel.Visibility = 'Visible'
            $Passphrases.ShowDialog()
            $HomeWindow_LoadingLabel.Visibility = 'Hidden'
            $HomeWindow.Cursor = $null
        })

    $HomeWindow_EntraSyncMenuItem.Add_Click({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait
            if ($STTSettings.EntraSettings.EntraConnectServer) {
                $ComputerName = $STTSettings.EntraSettings.EntraConnectServer
                $Output = Invoke-Command -ComputerName $ComputerName -ScriptBlock { Start-ADSyncSyncCycle -PolicyType Delta }
                $MessageSplat = @{
                    MessageTitle = 'Delta Sync Status'
                    ButtonType   = 'OK'
                    MessageIcon  = 'None'
                }
                if ($Output.Result -eq 'Success') {
                    $MessageSplat += @{
                        MessageText = 'Sync Successful!'
                    }
                }
                else {
                    $Text = "Sync Failed`n`n$($Output | Out-String)"
                    $MessageSplat += @{
                        MessageText = $Text
                    }
                }
            }
            else {
                $MessageSplat = @{
                    MessageTitle = 'Entra Connect Server not provided'
                    MessageText  = 'Sync not possible. Provide server name in the options.'
                    ButtonType   = 'OK'
                    MessageIcon  = 'Warning'
                }
            }
            _ShowMessageBox @MessageSplat
            $HomeWindow.Cursor = $null
        })
    $HomeWindow_ADSyncMenuItem.Add_Click({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait
            # repadmin /syncall /APeD
            $HomeWindow.Cursor = $null
        })
    #endregion

    #region Objects
    $HomeWindow_ExitButton.Add_Click({
            $HomeWindow.close()
        })

    $HomeWindow_BannerButton.Add_Click({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait
            _UpdateSCCMDevices -ForceLookup
            $HomeWindow.Cursor = $null
        })

    $HomeWindow_ADLookupsButton.Add_Click({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait
            $HomeWindow_LoadingLabel.Visibility = 'Visible'
            $ADLookups.ShowDialog()
            $HomeWindow_LoadingLabel.Visibility = 'Hidden'
            $HomeWindow.Cursor = $null
        })

    $HomeWindow_ADLookupsButton.Add_MouseEnter({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Hand
            $HomeWindow_DescriptionRichTextBox.Text = 'Used for querying AD users, computers, groups, and contacts.'
        })

    $HomeWindow_ADLookupsButton.Add_MouseLeave({
            $HomeWindow.Cursor = $null
            $HomeWindow_DescriptionRichTextBox.Text = ''
        })

    $HomeWindow_RSOPButton.Add_Click({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait
            $HomeWindow_LoadingLabel.Visibility = 'Visible'
            $RSOP.ShowDialog()
            $HomeWindow_LoadingLabel.Visibility = 'Hidden'
            $HomeWindow.Cursor = $null
        })

    $HomeWindow_RSOPButton.Add_MouseEnter({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Hand
            $HomeWindow_DescriptionRichTextBox.Text = 'Generate a gpresult for a specific server or user on a server and open it in the default web browser.'
        })

    $HomeWindow_RSOPButton.Add_MouseLeave({
            $HomeWindow.Cursor = $null
            $HomeWindow_DescriptionRichTextBox.Text = ''
        })

    $HomeWindow_SCCMDeploymentButton.Add_Click({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait
            $HomeWindow_LoadingLabel.Visibility = 'Visible'
            $SCCMDeployments.ShowDialog()
            $HomeWindow_LoadingLabel.Visibility = 'Hidden'
            $HomeWindow.Cursor = $null
        })

    $HomeWindow_SCCMDeploymentButton.Add_MouseEnter({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Hand
            $HomeWindow_DescriptionRichTextBox.Text = 'Get the results of one or more SCCM deployments and view or export results.'
        })

    $HomeWindow_SCCMDeploymentButton.Add_MouseLeave({
            $HomeWindow.Cursor = $null
            $HomeWindow_DescriptionRichTextBox.Text = ''
        })

    $HomeWindow_SoftwareButton.Add_Click({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait
            $HomeWindow_LoadingLabel.Visibility = 'Visible'
            $ComputerStats.ShowDialog()
            $HomeWindow_LoadingLabel.Visibility = 'Hidden'
            $HomeWindow.Cursor = $null
        })

    $HomeWindow_SoftwareButton.Add_MouseEnter({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Hand
            $HomeWindow_DescriptionRichTextBox.Text = 'Grid view for installed software and updates from WSUS.'
        })

    $HomeWindow_SoftwareButton.Add_MouseLeave({
            $HomeWindow.Cursor = $null
            $HomeWindow_DescriptionRichTextBox.Text = ''
        })

    $HomeWindow_WhatsUpGoldButton.Add_Click({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait
            $HomeWindow_LoadingLabel.Visibility = 'Visible'
            if ($WUGCredential) {
                $WhatsUpGold.ShowDialog()
            }
            else {
                $MessageSplat = @{
                    MessageText  = "Be sure you've provided credentials in the options window for Whats Up Gold."
                    MessageIcon  = 'Hand'
                    ButtonType   = 'OK'
                    MessageTitle = 'Error'
                }
                _ShowMessageBox @MessageSplat

                if ($HomeWindow) {
                    $WhatsUpGold.hide()
                }
                else {
                    $WhatsUpGold.close()
                }
            }
            $HomeWindow_LoadingLabel.Visibility = 'Hidden'
            $HomeWindow.Cursor = $null
        })

    $HomeWindow_WhatsUpGoldButton.Add_MouseEnter({
            $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Hand
            $HomeWindow_DescriptionRichTextBox.Text = 'Helps with quickly checking the status of devices in Whats Up Gold.'
        })

    $HomeWindow_WhatsUpGoldButton.Add_MouseLeave({
            $HomeWindow.Cursor = $null
            $HomeWindow_DescriptionRichTextBox.Text = ''
        })
    #endregion
}