SCCMDeployments/_SCCMDeploymentsUIEvents.ps1

function _SCCMDeploymentsUIEvents {
    #region General UI
    $SCCMDeployments.Add_SourceInitialized({

        })

    $SCCMDeployments.Add_Closing({
            if ($HomeWindow) {
                $_.Cancel = $true
                $SCCMDeployments.hide()
            }
            else {
                $SCCMDeployments.close()
            }
        })
    #endregion

    #region UI objects
    $SCCMDeployments_PopulateDeploymentsButton.Add_Click({
            $SCCMDeployments.Cursor = [System.Windows.Input.Cursors]::Wait
            _PopulateDeployments
            $SCCMDeployments.Cursor = $null
        })

    $SCCMDeployments_ShowStatsButton.Add_Click({
            # TODO make this a function for here and the keydown on Enter
            $SCCMDeployments.Cursor = [System.Windows.Input.Cursors]::Wait
            $Output = _GetSCCMDeploymentStatistics -Deployment $SCCMDeployments_DeploymentsComboBox.Text
            $OutputObject = @()
            foreach ($Object in $Output) {
                $OutputObject += $Object
            }
            $SCCMDeployments_StatsDataGrid.ItemsSource = $OutputObject
            $SCCMDeployments.Cursor = $null
        })

    $SCCMDeployments_DeploymentsComboBox.Add_KeyDown({
            if ($_.Key -eq 'Enter') {
                $SCCMDeployments.Cursor = [System.Windows.Input.Cursors]::Wait
                $Output = _GetSCCMDeploymentStatistics -Deployment $SCCMDeployments_DeploymentsComboBox.Text
                $OutputObject = @()
                foreach ($Object in $Output) {
                    $OutputObject += $Object
                }
                $SCCMDeployments_StatsDataGrid.ItemsSource = $OutputObject
                $SCCMDeployments.Cursor = $null
            }
        })
    #endregion
}