function showDownload($owner) { $form = New-Object System.Windows.Forms.Form $form.Owner = $owner $form.icon = $icon $form.Text = "Descargar" $form.Width = 445 $form.Height = 270 $form.AutoSize = $true $form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterParent $form.MaximizeBox = $false $form.Font = "Microsoft Sans Serif, 9.35" $form.FormBorderStyle = 'FixedDialog' $label_url = New-Object System.Windows.Forms.Label $label_url.Text = "URL:" $label_url.AutoSize = $true $label_url.Location = New-Object System.Drawing.Point(20, 23) $text_url = New-Object System.Windows.Forms.TextBox $text_url.Width = 335 $text_url.Location = New-Object System.Drawing.Point(75, 20) $text_url.add_TextChanged({ $text_name.Text = getTitle -url $text_url.Text }) $text_url.add_DoubleClick({ $text_url.SelectAll(); }) $label_dest = New-Object System.Windows.Forms.Label $label_dest.Text = "Destino:" $label_dest.AutoSize = $true $label_dest.Location = New-Object System.Drawing.Point(20, 58) $text_dest = New-Object System.Windows.Forms.TextBox $text_dest.Text = $def_dest_dir $text_dest.Width = 255 $text_dest.Location = New-Object System.Drawing.Point(75, 55) $text_dest.add_DoubleClick({ $text_dest.SelectAll(); }) $btn_dest = New-Object System.Windows.Forms.Button $btn_dest.Text = "Examinar" $btn_dest.AutoSize = $true $btn_dest.Location = New-Object System.Drawing.Point(335, 53) $btn_dest.Add_Click({ $dest = selectFolder -path $def_dest_dir if ($dest) { $text_dest.Text = $dest } }) $label_name = New-Object System.Windows.Forms.Label $label_name.Text = "Nombre:" $label_name.AutoSize = $true $label_name.Location = New-Object System.Drawing.Point(20, 93) $text_name = New-Object System.Windows.Forms.TextBox $text_name.Text = "" $text_name.Width = 333 $text_name.Location = New-Object System.Drawing.Point(75, 91) $text_name.add_TextChanged({ $text_name.Text = removeInvalidCharsString -name $text_name.Text }) $text_name.add_DoubleClick({ $text_name.SelectAll(); }) $text_name.Add_KeyDown({ if ($_.KeyCode -eq "Enter") { $btn_exec.PerformClick() } }) $check_audio = New-Object System.Windows.Forms.Checkbox $check_audio.Location = New-Object System.Drawing.Point(25, 125) $check_audio.AutoSize = $true $check_audio.Text = "Solo audio" $check_audio.Checked = $false $check_shut = New-Object System.Windows.Forms.Checkbox $check_shut.Location = New-Object System.Drawing.Point(25, 155) $check_shut.AutoSize = $true $check_shut.Text = "Apagar al finalizar" $check_shut.Checked = $false $btn_exec = New-Object System.Windows.Forms.Button $btn_exec.Text = "Descargar" $btn_exec.Location = New-Object System.Drawing.Point(140, 185) $btn_exec.Width = 150 $btn_exec.Height = 30 $btn_exec.Add_Click({ try { $prevCode = startAlwaysOn download -url $text_url.Text -out "$($text_dest.Text)\$($text_name.Text)" -audio $check_audio.Checked } finally { endAlwaysOn -code $prevCode } if ($check_shut.Checked) { shutdown -s } }) $form.Controls.Add($label_url) $form.Controls.Add($text_url) $form.Controls.Add($label_dest) $form.Controls.Add($text_dest) $form.Controls.Add($btn_dest) $form.Controls.Add($label_name) $form.Controls.Add($text_name) $form.Controls.Add($check_audio) $form.Controls.Add($check_shut) $form.Controls.Add($btn_exec) $text_url.Select() $form.Add_Closing({ $owner.Location = getRelativeLocation -parent $owner -child $form $form.Hide() $owner.Show() }) [PSAppID]::SetAppIdForWindow($form.handle, "$($metadata.package).$app_name") $form.Add_LocationChanged({ $global:win_loc = $form.Location }) $form.Add_Resize({ $global:win_size = $form.Size }) $form.ShowDialog() }