#Generated Form Function function GenerateForm { ######################################################################## # Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.7.0 # Generated On: 08/12/2009 12:11 # Generated By: IT2000 ######################################################################## #region Import the Assemblies [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null #endregion #region Generated Form Objects $form1 = New-Object System.Windows.Forms.Form $Vendor = New-Object System.Windows.Forms.TextBox $label2 = New-Object System.Windows.Forms.Label $label1 = New-Object System.Windows.Forms.Label $Location = New-Object System.Windows.Forms.ComboBox $label5 = New-Object System.Windows.Forms.Label $Quit = New-Object System.Windows.Forms.Button $Create = New-Object System.Windows.Forms.Button $URL = New-Object System.Windows.Forms.TextBox $URLlbl = New-Object System.Windows.Forms.Label $Descriptionlbl = New-Object System.Windows.Forms.Label $Description = New-Object System.Windows.Forms.TextBox $Version = New-Object System.Windows.Forms.TextBox $Versionlbl = New-Object System.Windows.Forms.Label $Namelbl = New-Object System.Windows.Forms.Label $Name = New-Object System.Windows.Forms.TextBox $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState #endregion Generated Form Objects #---------------------------------------------- #Generated Event Script Blocks #---------------------------------------------- #Provide Custom Code for events specified in PrimalForms. $Quit_OnClick= { $form1.close() } $handler_button1_Click= { switch ($Location.SelectedItem) { "Root Icon" { $Loc = 'Inventory.Global' } "DataCenter Level Tab" { $Loc = 'Inventory.Datacenter'} "DataCenter Folder Level Tab" { $Loc = 'Inventory.DatacenterFolder'} "Host Level Tab" { $Loc = 'Inventory.HostSystem'} "Virtual Machine Level Tab" { $Loc = 'Inventory.VirtualMachine'} "Administration Level Tab" { $Loc = 'Inventory.Admin'} "Cluster Level Tab" { $Loc = 'Inventory.Cluster'} "Datastore Level Tab" { $Loc = 'Inventory.Datastore'} "Network Level Tab" { $Loc = 'Inventory.Network'} "Resource Pool Level Tab" { $Loc = 'Inventory.ResourcePool'} "Virtual Machine Folder Level Tab" { $Loc = 'Inventory.VirtualMachineFolder'} "Resource Group Folder Level Tab" { $Loc = 'Inventory.ComputeResourceFolder'} "Template Level Tab" { $Loc = 'Inventory.Template'} } $Output = @" $($Name.Text) $($Description.Text) $($Vendor.Text) $($Name.Text) $($url.text) "@ $PlugPath = $Env:ProgramFiles + "\VMware\Infrastructure\Virtual Infrastructure Client\Plugins\" If (-not (Test-Path $PlugPath)){ $PlugPath = $Env:ProgramFiles + " (x86)\VMware\Infrastructure\Virtual Infrastructure Client\Plugins\" } If (-not (Test-Path $PlugPath)){ [System.Windows.Forms.MessageBox]::Show('Sorry your Virtual Infrastructure Client Folder could not be found, please let Virtu-Al know: contact@virtu-al.net','Error',[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Information) | Out-Null } Else { $FilePath = $PlugPath + $Name.Text if (-not (Test-Path $FilePath)){ md $FilePath } $Filename = $FilePath + "\$($Name.Text).xml" $Output | out-file -filepath $Filename [System.Windows.Forms.MessageBox]::Show("Plugin Created at:`n`n$FilePath `n`nTo remove this plugin delete the folder.",'Plugin Created',[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Information) | Out-Null } } $OnLoadForm_StateCorrection= {#Correct the initial state of the form to prevent the .Net maximized form issue $form1.WindowState = $InitialFormWindowState } #---------------------------------------------- #region Generated Form Code $form1.Text = "PS Local Plugin Creator" $form1.Name = "form1" $form1.DataBindings.DefaultDataSourceUpdateMode = 0 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 246 $System_Drawing_Size.Width = 485 $form1.ClientSize = $System_Drawing_Size $form1.FormBorderStyle = 1 $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 82 $System_Drawing_Point.Y = 84 $Vendor.Location = $System_Drawing_Point $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 20 $System_Drawing_Size.Width = 215 $Vendor.Size = $System_Drawing_Size $Vendor.DataBindings.DefaultDataSourceUpdateMode = 0 $Vendor.Name = "Vendor" $Vendor.Text = "My Company" $Vendor.TabIndex = 14 $form1.Controls.Add($Vendor) $label2.TabIndex = 13 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 16 $System_Drawing_Size.Width = 70 $label2.Size = $System_Drawing_Size $label2.Name = "label2" $label2.Text = "Vendor:" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 87 $label2.Location = $System_Drawing_Point $label2.DataBindings.DefaultDataSourceUpdateMode = 0 $form1.Controls.Add($label2) $label1.TabIndex = 12 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 24 $System_Drawing_Size.Width = 70 $label1.Size = $System_Drawing_Size $label1.Name = "label1" $label1.Text = "Location:" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 176 $label1.Location = $System_Drawing_Point $label1.DataBindings.DefaultDataSourceUpdateMode = 0 $form1.Controls.Add($label1) $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 82 $System_Drawing_Point.Y = 173 $Location.Location = $System_Drawing_Point $Location.DropDownStyle = 2 $Location.DataBindings.DefaultDataSourceUpdateMode = 0 $Location.FormattingEnabled = $True $Location.Name = "Location" $Location.Items.Add("Root Icon")|Out-Null $Location.Items.Add("DataCenter Level Tab")|Out-Null $Location.Items.Add("DataCenter Folder Level Tab")|Out-Null $Location.Items.Add("Host Level Tab")|Out-Null $Location.Items.Add("Virtual Machine Level Tab")|Out-Null $Location.Items.Add("Administration Level Tab")|Out-Null $Location.Items.Add("Cluster Level Tab")|Out-Null $Location.Items.Add("Datastore Level Tab")|Out-Null $Location.Items.Add("Network Level Tab")|Out-Null $Location.Items.Add("Resource Pool Level Tab")|Out-Null $Location.Items.Add("Virtual Machine Folder Level Tab")|Out-Null $Location.Items.Add("Resource Group Folder Level Tab")|Out-Null $Location.Items.Add("Template Level Tab")|Out-Null $Location.SelectedIndex=0 $Location.TabIndex = 11 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 21 $System_Drawing_Size.Width = 215 $Location.Size = $System_Drawing_Size $form1.Controls.Add($Location) $label5.TabIndex = 10 $label5.Font = New-Object System.Drawing.Font("Tahoma",8.25,1,3,1) $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 46 $System_Drawing_Size.Width = 145 $label5.Size = $System_Drawing_Size $label5.TextAlign = 32 $label5.Name = "label5" $label5.Text = "V1.0 Created by Virtu-Al http://virtu-al.net" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 321 $System_Drawing_Point.Y = 24 $label5.Location = $System_Drawing_Point $label5.DataBindings.DefaultDataSourceUpdateMode = 0 $form1.Controls.Add($label5) $Quit.TabIndex = 9 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 23 $System_Drawing_Size.Width = 75 $Quit.Size = $System_Drawing_Size $Quit.Name = "Quit" $Quit.UseVisualStyleBackColor = $True $Quit.Text = "Quit" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 206 $System_Drawing_Point.Y = 211 $Quit.Location = $System_Drawing_Point $Quit.DataBindings.DefaultDataSourceUpdateMode = 0 $Quit.add_Click($Quit_OnClick) $form1.Controls.Add($Quit) $Create.TabIndex = 8 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 23 $System_Drawing_Size.Width = 104 $Create.Size = $System_Drawing_Size $Create.Name = "Create" $Create.UseVisualStyleBackColor = $True $Create.Text = "Create Plugin" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 82 $System_Drawing_Point.Y = 211 $Create.Location = $System_Drawing_Point $Create.DataBindings.DefaultDataSourceUpdateMode = 0 $Create.add_Click($handler_button1_Click) $form1.Controls.Add($Create) $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 82 $System_Drawing_Point.Y = 147 $URL.Location = $System_Drawing_Point $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 20 $System_Drawing_Size.Width = 380 $URL.Size = $System_Drawing_Size $URL.DataBindings.DefaultDataSourceUpdateMode = 0 $URL.Name = "URL" $URL.Text = "file://c:/Temp/MyPage.htm" $URL.TabIndex = 7 $form1.Controls.Add($URL) $URLlbl.TabIndex = 6 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 11 $System_Drawing_Size.Width = 64 $URLlbl.Size = $System_Drawing_Size $URLlbl.Name = "URLlbl" $URLlbl.Text = "URL:" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 150 $URLlbl.Location = $System_Drawing_Point $URLlbl.DataBindings.DefaultDataSourceUpdateMode = 0 $URLlbl.add_Click($handler_label4_Click) $form1.Controls.Add($URLlbl) $Descriptionlbl.TabIndex = 5 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 14 $System_Drawing_Size.Width = 64 $Descriptionlbl.Size = $System_Drawing_Size $Descriptionlbl.Name = "Descriptionlbl" $Descriptionlbl.Text = "Description:" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 121 $Descriptionlbl.Location = $System_Drawing_Point $Descriptionlbl.DataBindings.DefaultDataSourceUpdateMode = 0 $Descriptionlbl.add_Click($handler_label3_Click) $form1.Controls.Add($Descriptionlbl) $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 82 $System_Drawing_Point.Y = 118 $Description.Location = $System_Drawing_Point $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 20 $System_Drawing_Size.Width = 380 $Description.Size = $System_Drawing_Size $Description.DataBindings.DefaultDataSourceUpdateMode = 0 $Description.Name = "Description" $Description.Text = "This is my Plugin" $Description.TabIndex = 4 $form1.Controls.Add($Description) $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 82 $System_Drawing_Point.Y = 53 $Version.Location = $System_Drawing_Point $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 20 $System_Drawing_Size.Width = 215 $Version.Size = $System_Drawing_Size $Version.DataBindings.DefaultDataSourceUpdateMode = 0 $Version.Name = "Version" $Version.Text = "1.0.0" $Version.TabIndex = 3 $form1.Controls.Add($Version) $Versionlbl.TabIndex = 2 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 17 $System_Drawing_Size.Width = 47 $Versionlbl.Size = $System_Drawing_Size $Versionlbl.Name = "Versionlbl" $Versionlbl.Text = "Version:" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 56 $Versionlbl.Location = $System_Drawing_Point $Versionlbl.DataBindings.DefaultDataSourceUpdateMode = 0 $form1.Controls.Add($Versionlbl) $Namelbl.TabIndex = 1 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 23 $System_Drawing_Size.Width = 47 $Namelbl.Size = $System_Drawing_Size $Namelbl.Name = "Namelbl" $Namelbl.Text = "Name:" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 24 $Namelbl.Location = $System_Drawing_Point $Namelbl.DataBindings.DefaultDataSourceUpdateMode = 0 $form1.Controls.Add($Namelbl) $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 82 $System_Drawing_Point.Y = 24 $Name.Location = $System_Drawing_Point $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 20 $System_Drawing_Size.Width = 215 $Name.Size = $System_Drawing_Size $Name.DataBindings.DefaultDataSourceUpdateMode = 0 $Name.Name = "Name" $Name.Text = "My Plugin" $Name.TabIndex = 0 $form1.Controls.Add($Name) #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($OnLoadForm_StateCorrection) #Show the Form $form1.ShowDialog()| Out-Null } #End Function #Call the Function GenerateForm