UI/_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_EnableSCCMMenuItem.Add_Click({ switch ($HomeWindow_EnableSCCMMenuItem.IsChecked) { # TODO might need to also set these in a function that can be called here and when the other windows load. $true { $ADLookups_UpdateSCCMDevicesMenuItem.IsEnabled = $true $ADLookups_OptionsTabSCCMServerTextBox.Text = '' $ADLookups_OptionTabSCCMCollectionComboBox.IsEnabled = $true $ADLookups_OptionsTabSCCMServerTextBox.IsEnabled = $true $MessageSplat = @{ MessageText = "SCCM was enabled. Input the SCCM server's name on the Options tab in ADLookups and click Save Settings." MessageIcon = 'Asterisk' ButtonType = 'OK' MessageTitle = 'Input SCCM Server' } _ShowMessageBox @MessageSplat } $false { $ADLookups_UpdateSCCMDevicesMenuItem.IsEnabled = $false $ADLookups_OptionsTabSCCMServerTextBox.Text = 'Disabled in settings.' $ADLookups_OptionsTabSCCMServerTextBox.IsEnabled = $false $ADLookups_OptionTabSCCMCollectionComboBox.IsEnabled = $false } Default { } } _SaveSettings -Path "$env:APPDATA\LoganShell\" }) $HomeWindow_EnableExchangeMenuItem.Add_Click({ switch ($HomeWindow_EnableExchangeMenuItem.IsChecked) { $true { $ADLookups_ExchangeTabMailboxTypeTextBox.IsEnabled = $true $ADLookups_ExchangeTabMailboxTypeTextBox.Text = '' $MessageSplat = @{ MessageText = 'Exchange lookup was enabled.' MessageIcon = 'Asterisk' ButtonType = 'OK' MessageTitle = 'Exchange enabled' } _ShowMessageBox @MessageSplat } $false { $ADLookups_ExchangeTabMailboxTypeTextBox.IsEnabled = $false $ADLookups_ExchangeTabMailboxTypeTextBox.Text = 'Disabled in settings.' } Default { } } _SaveSettings -Path "$env:APPDATA\LoganShell\" }) $HomeWindow_DarkThemeMenuItem.Add_Click({ $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait _SaveSettings -Path "$env:APPDATA\LoganShell\" $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' $GenericDataGrid.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_IntuneButton.Add_Click({ $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Wait $HomeWindow_LoadingLabel.Visibility = 'Visible' _IntuneDeviceDetails $HomeWindow_LoadingLabel.Visibility = 'Hidden' $HomeWindow.Cursor = $null }) $HomeWindow_IntuneButton.Add_MouseEnter({ $HomeWindow.Cursor = [System.Windows.Input.Cursors]::Hand $HomeWindow_DescriptionRichTextBox.Text = 'Opens a window that allows querying for all information for an Intune device.' }) $HomeWindow_IntuneButton.Add_MouseLeave({ $HomeWindow.Cursor = $null $HomeWindow_DescriptionRichTextBox.Text = '' }) #endregion } |