Refactoring e nuove funzionalità per AutoBidder v4.0
* Aggiornamento alla versione 4.0.0 * Refactoring architetturale: introdotte partial classes e UserControls modulari per migliorare manutenibilità e leggibilità. * Aggiunti nuovi UserControls: `AuctionMonitorControl`, `BrowserControl`, `SettingsControl`, `StatisticsControl`. * Introdotto supporto per WebView2 per il browser integrato. * Migliorata gestione delle aste: aggiunta/rimozione tramite URL o ID, configurazione predefinita. * Nuove funzionalità di esportazione: supporto CSV, JSON, XML con opzioni configurabili. * Logging avanzato: codifica colore per severità e auto-scroll. * Tema scuro moderno e miglioramenti UI/UX: sidebar di navigazione, griglie virtualizzate, icone emoji. * Persistenza dati: salvataggio automatico di aste e impostazioni in file JSON. * Documentazione aggiornata: `README.md`, `CHANGELOG.md` e nuovi file di supporto. * Miglioramenti alla sicurezza: cookie di sessione salvati in modo sicuro con DPAPI. * Preparazione per future estensioni: placeholder per funzionalità avanzate e struttura modulare.
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using AutoBidder.Utilities;
|
||||
|
||||
namespace AutoBidder
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings and configuration event handlers
|
||||
/// </summary>
|
||||
public partial class MainWindow
|
||||
{
|
||||
private void SaveCookieButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var cookie = SettingsCookieTextBox.Text?.Trim();
|
||||
if (string.IsNullOrEmpty(cookie))
|
||||
{
|
||||
MessageBox.Show(this, "Inserisci un cookie valido", "Errore", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
_auctionMonitor.InitializeSessionWithCookie(cookie, string.Empty);
|
||||
var success = _auctionMonitor.UpdateUserInfoAsync().GetAwaiter().GetResult();
|
||||
var session = _auctionMonitor.GetSession();
|
||||
|
||||
if (success && session != null)
|
||||
{
|
||||
Services.SessionManager.SaveSession(session);
|
||||
SetUserBanner(session.Username ?? string.Empty, session.RemainingBids);
|
||||
UsernameText.Text = session.Username ?? string.Empty;
|
||||
StartButton.IsEnabled = true;
|
||||
Log($"[OK] Sessione salvata per: {session.Username}");
|
||||
MessageBox.Show(this, $"Cookie valido!\nUtente: {session.Username}\nPuntate disponibili: {session.RemainingBids}", "Sessione Salvata", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log($"[WARN] Cookie non valido o scaduto", LogLevel.Warn);
|
||||
MessageBox.Show(this, "Cookie non valido o scaduto.\nVerifica che il cookie sia corretto.", "Errore Cookie", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log($"[ERRORE] Salvataggio cookie: {ex.Message}", LogLevel.Error);
|
||||
MessageBox.Show(this, "Errore durante salvataggio cookie: " + ex.Message, "Errore", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ImportCookieFromBrowserButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (EmbeddedWebView?.CoreWebView2 == null)
|
||||
{
|
||||
MessageBox.Show(this, "Browser non inizializzato", "Errore", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var cookies = EmbeddedWebView.CoreWebView2.CookieManager.GetCookiesAsync("https://it.bidoo.com").GetAwaiter().GetResult();
|
||||
var stattrb = cookies.FirstOrDefault(c => c.Name == "__stattrb");
|
||||
|
||||
if (stattrb != null)
|
||||
{
|
||||
SettingsCookieTextBox.Text = stattrb.Value;
|
||||
Log("[OK] Cookie importato dal browser");
|
||||
MessageBox.Show(this, "Cookie importato con successo!\nClicca 'Salva Cookie' per confermare.", "Importa Cookie", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("[WARN] Cookie __stattrb non trovato nel browser", LogLevel.Warn);
|
||||
MessageBox.Show(this, "Cookie __stattrb non trovato.\nAssicurati di aver effettuato il login su bidoo.com nella scheda Browser.", "Cookie Non Trovato", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log($"[ERRORE] Importazione cookie: {ex.Message}", LogLevel.Error);
|
||||
MessageBox.Show(this, "Errore durante importazione cookie: " + ex.Message, "Errore", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelCookieButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SettingsCookieTextBox.Text = string.Empty;
|
||||
}
|
||||
|
||||
private void SaveSettingsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var lastExt = ExtJson.IsChecked == true ? ".json" : ExtXml.IsChecked == true ? ".xml" : ".csv";
|
||||
var scope = "All";
|
||||
var cbClosed = this.FindName("ExportClosedToolbar") as System.Windows.Controls.CheckBox;
|
||||
var cbUnknown = this.FindName("ExportUnknownToolbar") as System.Windows.Controls.CheckBox;
|
||||
var cbOpen = this.FindName("ExportOpenToolbar") as System.Windows.Controls.CheckBox;
|
||||
|
||||
if (cbClosed != null && cbClosed.IsChecked == true) scope = "Closed";
|
||||
else if (cbUnknown != null && cbUnknown.IsChecked == true) scope = "Unknown";
|
||||
else if (cbOpen != null && cbOpen.IsChecked == true) scope = "Open";
|
||||
|
||||
var s = new AppSettings()
|
||||
{
|
||||
ExportPath = ExportPathTextBox.Text,
|
||||
LastExportExt = lastExt,
|
||||
ExportScope = scope,
|
||||
IncludeOnlyUsedBids = IncludeUsedBids.IsChecked == true,
|
||||
IncludeLogs = IncludeLogs.IsChecked == true,
|
||||
IncludeUserBids = IncludeUserBids.IsChecked == true
|
||||
};
|
||||
|
||||
SettingsManager.Save(s);
|
||||
ExportPreferences.SaveLastExportExtension(s.LastExportExt);
|
||||
MessageBox.Show(this, "Impostazioni salvate.", "Salva", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(this, "Errore salvataggio impostazioni: " + ex.Message, "Errore", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelSettingsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LoadExportSettings();
|
||||
}
|
||||
|
||||
private void SaveDefaultsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show(this, "Funzionalità non ancora implementata", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
private void CancelDefaultsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show(this, "Funzionalità non ancora implementata", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user