1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
using assembly System.Windows.Forms using namespace System.Windows.Forms class Operacion { [Int]$operacion [String]$nombre #Constructor de la clase Operacion($operacion,$nombre) { $this.operacion = $operacion $this.nombre = $nombre } } # Crear array de objetos Operacion $arrayoperaciones = New-Object System.Collections.ArrayList $form = [Form] @{ Text = 'Mi formulario' } $TextBox = [TextBox] @{ Location = New-Object System.Drawing.Size(100,80) } $button = [Button] @{ Text = 'Pulsar' Location = New-Object System.Drawing.Size(100,180) } $button.add_Click{ Write-Host $TextBox.Text $arrayoperaciones.add([Operacion]::new(1,$TextBox.Text)) } $form.Controls.Add($TextBox) $form.Controls.Add($button) $form.ShowDialog() $arrayoperaciones | ConvertTo-Json | Out-File operacion.txt -Append -Encoding default |