diff --git a/App.xaml.cs b/App.xaml.cs index e7e69c9..2440eb5 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -31,53 +31,61 @@ namespace GTPCorrgir { base.OnStartup(e); - stopwatch.Start(); - if (System.Windows.Clipboard.ContainsText()) { GTP.TextoACorregir = System.Windows.Clipboard.GetText(); } - // Muestra notificación inicial y comienza el cronómetro en el hilo de la UI - ShowCustomNotification("Espera", $"Corrigiendo texto con .{Opciones.Instance.nombreDeLLM()} .."); - IniciarCronometro(); - - - // Ejecuta la tarea de corrección en un hilo secundario - Task.Run(async () => + if (Opciones.Instance.modo == Opciones.modoDeUso.Corregir) { - try + + stopwatch.Start(); + + // Muestra notificación inicial y comienza el cronómetro en el hilo de la UI + ShowCustomNotification("Espera", $"Corrigiendo texto con .{Opciones.Instance.nombreDeLLM()} .."); + IniciarCronometro(); + + + // Ejecuta la tarea de corrección en un hilo secundario + Task.Run(async () => { - await GTP.CorregirTexto(); - } - catch (Exception ex) - { - Console.WriteLine("Error durante la corrección de texto: " + ex.Message); - } - finally - { - Dispatcher.Invoke(async () => // Nota el 'async' aquí para permitir 'await' + try { - CorreccionFinalizada = true; - DetenerCronometro(); - if (GTP.TextoCorregido != null) + await GTP.CorregirTexto(); + } + catch (Exception ex) + { + Console.WriteLine("Error durante la corrección de texto: " + ex.Message); + } + finally + { + Dispatcher.Invoke(async () => // Nota el 'async' aquí para permitir 'await' { - System.Windows.Clipboard.SetText(GTP.TextoCorregido); - ShowCustomNotification("Se puede pegar", $"Corrección en : {Math.Round(stopwatch.ElapsedMilliseconds / 1000.0, 1)} s"); + CorreccionFinalizada = true; + DetenerCronometro(); + if (GTP.TextoCorregido != null) + { + System.Windows.Clipboard.SetText(GTP.TextoCorregido); + ShowCustomNotification("Se puede pegar", $"Corrección en : {Math.Round(stopwatch.ElapsedMilliseconds / 1000.0, 1)} s"); - var resultadoWindow = new VentanaResultado(GTP.TextoCorregido); - resultadoWindow.Show(); + var resultadoWindow = new VentanaResultado(GTP.TextoCorregido); + resultadoWindow.Show(); - await Task.Delay(5000); // Asíncrono espera 5 segundos - } - else - { - MostrarNotificacion("Error", "No se pudo corregir el texto."); - Application.Current.Shutdown(); - } - }); - } - }); + await Task.Delay(5000); // Asíncrono espera 5 segundos + } + else + { + MostrarNotificacion("Error", "No se pudo corregir el texto."); + Application.Current.Shutdown(); + } + }); + } + }); + } else if (Opciones.Instance.modo == Opciones.modoDeUso.Chat) + { + var chatWindows = new Chat(GTP); + chatWindows.Show(); + } } diff --git a/Chat.xaml b/Chat.xaml new file mode 100644 index 0000000..562f9cd --- /dev/null +++ b/Chat.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +