########################################################################
# Code Generated By: SAPIEN Technologies, Inc., PrimalForms 2009 v1.1.11.0
# Generated On: 8/5/2011 1:46 PM
# Generated By: Kevin Curran
# Organization: Disorganized
########################################################################
#----------------------------------------------
#region Application Functions
#----------------------------------------------
function OnApplicationLoad {
#Note: This function runs before the form is created
#Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path
#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)
#Important: Form controls cannot be accessed in this function
#TODO: Add snapins and custom code to validate the application load
# Add-PSSnapin SqlServerProviderSnapin100
# Add-PSSnapin SqlServerCmdletSnapin100
return $true #return true for success or false for failure
}
function OnApplicationExit {
#Note: This function runs after the form is closed
#TODO: Add custom code to clean up and unload snapins when the application exits
$script:ExitCode = 0 #Set the exit code for the Packager
}
#endregion
#----------------------------------------------
# Generated Form Function
#----------------------------------------------
function GenerateForm {
#----------------------------------------------
#region Import Assemblies
#----------------------------------------------
[void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
[void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
[void][reflection.assembly]::Load("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
[void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
[void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
#endregion
#----------------------------------------------
#region Generated Form Objects
#----------------------------------------------
[System.Windows.Forms.Application]::EnableVisualStyles()
$form1 = New-Object System.Windows.Forms.Form
$listbox1 = New-Object System.Windows.Forms.ListBox
$combobox1 = New-Object System.Windows.Forms.ComboBox
$button1 = New-Object System.Windows.Forms.Button
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects
#----------------------------------------------
# User Generated Script
#----------------------------------------------
$FormEvent_Load={
#TODO: Initialize Form Controls here
$ServerName="SQL2008"
}
$handler_button1_Click={
#TODO: Place custom script here
$databases= gci SQLServer:\SQL\$ServerName\default\Databases | select name
#$dbtext=foreach ($database in $databases) {$database.name + "`r`n"}
#$textbox1.Text = $dbtext
foreach ($database in $databases)
{
$combobox1.Items.Add($database.name)
$listbox1.Items.Add($database.name)
}
$listbox1
}#end handler_button1_Click
#----------------------------------------------
# Generated Events
#----------------------------------------------
$Form_StateCorrection_Load=
{
#Correct the initial state of the form to prevent the .Net maximized form issue
$form1.WindowState = $InitialFormWindowState
}
#----------------------------------------------
#region Generated Form Code
#----------------------------------------------
#
# form1
#
$form1.Controls.Add($listbox1)
$form1.Controls.Add($combobox1)
$form1.Controls.Add($button1)
$form1.ClientSize = New-Object System.Drawing.Size(409,431)
$form1.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation
$form1.Name = "form1"
$form1.Text = "Primal Form"
$form1.add_Load($FormEvent_Load)
#
# listbox1
#
$listbox1.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation
$listbox1.FormattingEnabled = $True
$listbox1.Location = New-Object System.Drawing.Point(12,43)
$listbox1.Name = "listbox1"
$listbox1.SelectionMode = [System.Windows.Forms.SelectionMode]::MultiSimple
$listbox1.Size = New-Object System.Drawing.Size(222,147)
$listbox1.TabIndex = 2
#
# combobox1
#
$combobox1.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation
$combobox1.FormattingEnabled = $True
$combobox1.Location = New-Object System.Drawing.Point(12,15)
$combobox1.Name = "combobox1"
$combobox1.Size = New-Object System.Drawing.Size(121,21)
$combobox1.TabIndex = 1
#
# button1
#
$button1.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation
$button1.Location = New-Object System.Drawing.Point(264,13)
$button1.Name = "button1"
$button1.Size = New-Object System.Drawing.Size(98,23)
$button1.TabIndex = 0
$button1.Text = "Get Databases"
$button1.UseVisualStyleBackColor = $True
$button1.add_Click($handler_button1_Click)
#endregion Generated Form Code
#----------------------------------------------
#Save the initial state of the form
$InitialFormWindowState = $form1.WindowState
#Init the OnLoad event to correct the initial state of the form
$form1.add_Load($Form_StateCorrection_Load)
#Show the Form
return $form1.ShowDialog()
} #End Function
#Call OnApplicationLoad to initialize
if(OnApplicationLoad -eq $true)
{
#Create the form
GenerateForm | Out-Null
#Perform cleanup
OnApplicationExit
}