lib/events/SqlSchemaForm.ps1

#######################################################################################################################################################
# WARNING: DO NOT EDIT THIS FILE AS IT IS GENERATED AND WILL BE OVERWRITTEN ON THE NEXT UPDATE! #
# #
# Generated via psake on: 2026-08-15T02:20:17.661Z #
# Version: 2026.8.15.59 #
# Copyright Fortigi (C) 2024-2026 #
#######################################################################################################################################################
#requires -Version 7.0

$Script:SqlSchemaFilterTimer = New-Object System.Windows.Threading.DispatcherTimer
$Script:SqlSchemaFilterTimer.Interval = [TimeSpan]::FromMilliseconds(250)
$Script:SqlSchemaFilterTimer.Add_Tick({
        try {
            $Script:SqlSchemaFilterTimer.Stop()
            Update-SqlSchemaTreeFilter
        }
        catch {
            $_.Exception.Message | Write-LogOutput -LogType ERROR -ErrorObject $_
        }
    })

$Script:SqlSchemaForm.Elements.TextBoxSchemaFilter.Add_TextChanged({

        param (
            $EventSender,
            $EventArgs
        )

        try {
            $_ | Show-EventInfo -LogType VERBOSE2

            $Script:SqlSchemaFilterTimer.Stop()
            $Script:SqlSchemaFilterTimer.Start()
        }
        catch {
            $_.Exception.Message | Write-LogOutput -LogType ERROR -ErrorObject $_
        }
    })

$Script:SqlSchemaForm.Elements.TextBoxSchemaFilter.Add_PreviewKeyDown({

        param (
            $EventSender,
            $EventArgs
        )

        try {
            $_ | Show-EventInfo -LogType VERBOSE2

            if ($EventArgs.Key -eq [System.Windows.Input.Key]::Escape) {
                "Escape key intercepted at schema filter level - clearing the filter" | Write-LogOutput -LogType VERBOSE

                $EventArgs.Handled = $true
                $Script:SqlSchemaForm.Elements.TextBoxSchemaFilter.Clear()
            }
            elseif ($EventArgs.Key -in ([System.Windows.Input.Key]::Enter, [System.Windows.Input.Key]::Return)) {
                "Enter/Return key intercepted at schema filter level - applying the filter" | Write-LogOutput -LogType VERBOSE

                $EventArgs.Handled = $true
                $Script:SqlSchemaFilterTimer.Stop()
                Update-SqlSchemaTreeFilter
            }
        }
        catch {
            $_.Exception.Message | Write-LogOutput -LogType ERROR -ErrorObject $_
        }
    })