Public/Open-PstGuiFunctionSelector.ps1

function Open-PstGuiFunctionSelector {
    <#
.SYNOPSIS
    Brief summary of function
.DESCRIPTION
    Fuction description
.EXAMPLE
    Give Examples of the function usuage
.NOTES
    Any other notes the user may need to know bout the function
.LINK
    Any Links with addtional information on the use of the function
#>

    begin {
        Write-Debug -Message "Begin '$($MyInvocation.MyCommand.Name)' at '$(Get-Date)'"
        [void][System.Reflection.Assembly]::LoadWithPartialName('PresentationFramework');
        $pstFunctionSelectorXamlPath = $XAML["PstFunctionSelector.xaml"]
    }
    process {
        try {
            [xml]$Xaml = Get-Content -Path $pstFunctionSelectorXamlPath
            $Script:PstFunctionSelectorForm = [Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $Xaml));
            $Xaml.SelectNodes("//*[@Name]") | `
                    ForEach-Object {
                    Set-Variable `
                        -Name ($_.Name) `
                        -Value $Script:PstFunctionSelectorForm.FindName($_.Name) `
                        -Scope Global
                    Write-Debug -Message "Gui Variable created: $($_.Name)"
                };
            #region gbFunctionSelector
            $cmbFunctionSelector.IsEnabled = $true
            $functions = Get-PstPublicFunction
            #endregion gbFunctionSelector
            if ($Script:PstFunctionSelectorForm) {
                # Test-PstGuiFunctionSelectorReadiness
                $Script:PstFunctionSelectorForm.ShowDialog() | Out-Null
            }else {
                Write-Error -Message "sForm is null, can't load form."
            }
            # Write-Output $result
        }
        catch {
            if ($_.Exception -and $_.Exception.Message) {
                Write-Error "An error occurred: $($_.Exception.Message)"
            } else {
                Write-Error "An error occurred, but no additional information is available."
            }
        }
    }
    end {
        if ($?) {
            Write-Debug -Message "End '$($MyInvocation.MyCommand.Name)' at '$(Get-Date)'"
        }
    }
}