function showCut($owner) { $form = New-Object System.Windows.Forms.Form $form.Owner = $owner $form.icon = $icon $form.Text = "Cortar" $form.Width = 445 $form.Height = 315 $form.AutoSize = $true $form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterParent $form.MaximizeBox = $false $form.Font = "Microsoft Sans Serif, 9.35" $form.FormBorderStyle = 'FixedDialog' $label_ori = New-Object System.Windows.Forms.Label $label_ori.Text = "Archivo:" $label_ori.AutoSize = $true $label_ori.Location = New-Object System.Drawing.Point(20, 23) $text_ori = New-Object System.Windows.Forms.TextBox $text_ori.Text = $sel_ori $text_ori.Width = 255 $text_ori.Location = New-Object System.Drawing.Point(75, 20) $text_ori.add_DoubleClick({ $text_ori.SelectAll(); }) $btn_ori = New-Object System.Windows.Forms.Button $btn_ori.Text = "Examinar" $btn_ori.AutoSize = $true $btn_ori.Location = New-Object System.Drawing.Point(335, 18) $btn_ori.Add_Click({ $res = selectFile -path "" -formats "Videos y Audios (*.*)|*.*" if ($res -ne $null) { $text_ori.Text = $res $text_name.Text = (Get-Item -LiteralPath $res).Basename + " - Corte" + (Get-Item -LiteralPath $res).Extension $text_start.Text = "00:00:00" $text_end.Text = getFileDuration -in $text_ori.Text } }) $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({ removeInvalidChars -textbox $text_name }) $text_name.add_DoubleClick({ $text_name.SelectAll(); }) $text_name.Add_KeyDown({ if ($_.KeyCode -eq "Enter") { $btn_exec.PerformClick() } }) $check_encode = New-Object System.Windows.Forms.Checkbox $check_encode.Location = New-Object System.Drawing.Point(75, 127) $check_encode.AutoSize = $true $check_encode.Text = "Recodificar" $check_encode.Checked = $false $group_box = New-Object System.Windows.Forms.GroupBox $group_box.Location = '20,153' $group_box.Width = 390 $group_box.Height = 57 $label_start = New-Object System.Windows.Forms.Label $label_start.Text = "Inicio:" $label_start.AutoSize = $true $label_start.Location = New-Object System.Drawing.Point(15, 22) $text_start = New-Object System.Windows.Forms.TextBox $text_start.Text = "00:00:00" $text_start.Width = 80 $text_start.TextAlign = "Center" $text_start.Location = New-Object System.Drawing.Point(60, 20) $text_start.Add_KeyDown({ if ($_.KeyCode -eq "Enter") { $text_end.Focus() } }) $label_end = New-Object System.Windows.Forms.Label $label_end.Text = "Fin:" $label_end.AutoSize = $true $label_end.Location = New-Object System.Drawing.Point(160, 22) $text_end = New-Object System.Windows.Forms.TextBox $text_end.Text = "00:00:00" $text_end.Width = 80 $text_end.TextAlign = "Center" $text_end.Location = New-Object System.Drawing.Point(188, 20) $text_end.Add_KeyDown({ if ($_.KeyCode -eq "Enter") { $btn_exec.PerformClick() } }) $btn_test = New-Object System.Windows.Forms.Button $btn_test.Text = "Probar" $btn_test.Location = New-Object System.Drawing.Point(285, 17) $btn_test.Width = 90 $btn_test.Height = 28 $btn_test.Add_Click({ play -in $text_ori.Text -start $text_start.Text -end $text_end.Text }) $form.Controls.Add($group_box) $group_box.Controls.AddRange(@($label_start, $text_start, $label_end, $text_end, $btn_test)) $btn_exec = New-Object System.Windows.Forms.Button $btn_exec.Text = "Cortar" $btn_exec.Location = New-Object System.Drawing.Point(140, 230) $btn_exec.Width = 150 $btn_exec.Height = 30 $btn_exec.Add_Click({ try { $prevCode = startAlwaysOn cut -in $text_ori.Text -out "$($text_dest.Text)\$($text_name.Text)" -start $text_start.Text -end $text_end.Text -encode $check_encode.Checked } finally { endAlwaysOn -code $prevCode } }) $form.Controls.Add($label_ori) $form.Controls.Add($text_ori) $form.Controls.Add($btn_ori) $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_encode) $form.Controls.Add($btn_exec) $text_ori.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() }