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 41 42 43 |
$elementos = Read-Host "Introduzca el número de elmentos del tablero" $buttons_functionslist=@( 1..([Math]::Pow($elementos,2)) ) $posicionesjuego = $buttons_functionslist $buttons_functionbuttoncount = $buttons_functionslist.count $loop,$loop2 = 0 #Formulario $Form = New-Object System.Windows.Forms.Form $Form.Text="Formulario" $Form.Size=New-Object System.Drawing.Size((50*$elementos),(50*$elementos)) $Form.StartPosition="CenterScreen" $valor = 0 while($loop -lt $buttons_functionbuttoncount) { $thisbutton = New-Object System.Windows.Forms.Button [string]$thisbuttonname = $buttons_functionslist[$loop] $thisbutton.name = $thisbuttonname $thisbutton.size = New-Object System.Drawing.Size(30,30) if($loop%$elementos -eq 0) { $valor += 30 $thisbutton.Location = New-Object System.Drawing.Size(15,$valor) $loop2 = 1 } else { $thisbutton.Location = New-Object System.Drawing.Size((($loop2*30)+15),$valor) $loop2 += 1 } $thisbutton.Add_Click({ Write-Host $this.name }) $Form.Controls.Add($thisbutton) $loop += 1 } $Form.ShowDialog() |