Feat: UI/UX y Procesos

This commit is contained in:
2026-02-09 19:00:18 -03:00
parent 7222728591
commit f6d8b34520
13 changed files with 925 additions and 359 deletions

View File

@@ -1,7 +1,9 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using WhatsappPromo.Core.Models;
using WhatsappPromo.Core.Services;
@@ -28,7 +30,6 @@ namespace WhatsappPromo.Worker.Controllers
[HttpPost]
public async Task<IActionResult> UpdateConfig([FromBody] SystemConfig config)
{
// Validar ruta
if (!string.IsNullOrEmpty(config.DownloadPath))
{
try
@@ -62,5 +63,64 @@ namespace WhatsappPromo.Worker.Controllers
await _configService.UpdateConfigAsync(config);
return Ok(new { status = "Stopping" });
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
private static extern bool SetForegroundWindow(IntPtr hWnd);
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
private const uint SWP_NOSIZE = 0x0001;
private const uint SWP_NOMOVE = 0x0002;
private const uint SWP_SHOWWINDOW = 0x0040;
[HttpGet("browse")]
public IActionResult Browse()
{
string? selectedPath = null;
var thread = new Thread(() =>
{
using (var dummyForm = new Form())
{
dummyForm.TopMost = true;
// El form debe ser "real" para que Windows lo respete
dummyForm.Width = 1; dummyForm.Height = 1;
dummyForm.Opacity = 0.05;
dummyForm.ShowInTaskbar = false;
dummyForm.FormBorderStyle = FormBorderStyle.None;
dummyForm.StartPosition = FormStartPosition.CenterScreen;
dummyForm.Show();
// Forzamos la posición al frente de todo
SetWindowPos(dummyForm.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
SetForegroundWindow(dummyForm.Handle);
dummyForm.Activate();
dummyForm.Focus();
using (var fbd = new FolderBrowserDialog())
{
fbd.Description = "Selecciona la carpeta para descargas de WhatsApp";
fbd.UseDescriptionForTitle = true;
fbd.ShowNewFolderButton = true;
if (fbd.ShowDialog(dummyForm) == DialogResult.OK)
{
selectedPath = fbd.SelectedPath;
}
}
dummyForm.Close();
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
return Ok(new { path = selectedPath });
}
}
}