Aggiunta opzione "Ricorda Stato" per le aste salvate
È stata introdotta l'opzione "Ricorda Stato" che consente di ripristinare lo stato esatto (attiva, in pausa, ferma) di ogni asta salvata al caricamento. - Aggiunto il `RadioButton` "Ricorda Stato" in `SettingsControl.xaml`. - Gestita la nuova opzione in `MainWindow.EventHandlers.Settings.cs`. - Aggiornata la logica di caricamento in `AuctionManagement.cs` per supportare "Ricorda Stato". - Introdotto il salvataggio automatico dello stato delle aste in `ButtonHandlers.cs` e `Commands.cs`. - Migliorati i log per riflettere il comportamento del sistema. - Aggiunta la proprietà `RememberAuctionStates` in `SettingsManager` con valore predefinito `false`. - Migliorata la leggibilità e manutenibilità del codice. Queste modifiche migliorano la flessibilità e l'esperienza utente, garantendo coerenza dei dati e maggiore chiarezza nei log.
This commit is contained in:
@@ -244,6 +244,10 @@
|
||||
Content="Attive"
|
||||
GroupName="LoadState"
|
||||
ToolTip="Le aste salvate verranno avviate automaticamente all'apertura"/>
|
||||
<RadioButton x:Name="LoadAuctionsRemember"
|
||||
Content="Ricorda Stato"
|
||||
GroupName="LoadState"
|
||||
ToolTip="Ogni asta ripristina lo stato che aveva alla chiusura (attiva/pausa/ferma)"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Stato nuove aste -->
|
||||
@@ -280,8 +284,10 @@
|
||||
• <Bold>Fermata:</Bold> L'asta non viene monitorata fino all'avvio manuale.<LineBreak/>
|
||||
• <Bold>In Pausa:</Bold> L'asta è pronta ma non punta automaticamente (utile per preparare le aste).<LineBreak/>
|
||||
• <Bold>Attiva:</Bold> L'asta viene monitorata e punta automaticamente quando necessario.<LineBreak/>
|
||||
• <Bold>Ricorda Stato:</Bold> Ogni asta ripristina lo stato esatto che aveva alla chiusura (SOVRASCRIVE le altre opzioni).<LineBreak/>
|
||||
<LineBreak/>
|
||||
<Bold>Consiglio:</Bold> Usa "Fermata" per caricare le aste senza avviarle, poi avvia manualmente quelle desiderate.
|
||||
<Bold>Consiglio:</Bold> Usa "Fermata" per caricare le aste senza avviarle, poi avvia manualmente quelle desiderate.<LineBreak/>
|
||||
Usa "Ricorda Stato" per riprendere esattamente da dove avevi lasciato.
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
@@ -40,6 +40,14 @@ namespace AutoBidder
|
||||
UpdateMinBidsIndicator(settings.MinimumRemainingBids);
|
||||
|
||||
// Carica stato iniziale aste
|
||||
// ? NUOVO: Se RememberAuctionStates è attivo, seleziona "Ricorda Stato"
|
||||
if (settings.RememberAuctionStates)
|
||||
{
|
||||
Settings.LoadAuctionsRemember.IsChecked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Altrimenti usa DefaultStartAuctionsOnLoad
|
||||
switch (settings.DefaultStartAuctionsOnLoad)
|
||||
{
|
||||
case "Active":
|
||||
@@ -53,6 +61,7 @@ namespace AutoBidder
|
||||
Settings.LoadAuctionsStopped.IsChecked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (settings.DefaultNewAuctionState)
|
||||
{
|
||||
@@ -231,12 +240,26 @@ namespace AutoBidder
|
||||
}
|
||||
|
||||
// === SEZIONE DEFAULTS: Stati Iniziali Aste ===
|
||||
var loadAuctionsRemember = Settings.FindName("LoadAuctionsRemember") as System.Windows.Controls.RadioButton;
|
||||
var loadAuctionsActive = Settings.FindName("LoadAuctionsActive") as System.Windows.Controls.RadioButton;
|
||||
var loadAuctionsPaused = Settings.FindName("LoadAuctionsPaused") as System.Windows.Controls.RadioButton;
|
||||
|
||||
// ? NUOVO: Gestione "Ricorda Stato"
|
||||
if (loadAuctionsRemember?.IsChecked == true)
|
||||
{
|
||||
// Attiva RememberAuctionStates
|
||||
settings.RememberAuctionStates = true;
|
||||
// DefaultStartAuctionsOnLoad diventa irrilevante, ma lo lasciamo a "Stopped" per compatibilità
|
||||
settings.DefaultStartAuctionsOnLoad = "Stopped";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disattiva RememberAuctionStates e usa DefaultStartAuctionsOnLoad
|
||||
settings.RememberAuctionStates = false;
|
||||
settings.DefaultStartAuctionsOnLoad = loadAuctionsActive?.IsChecked == true ? "Active" :
|
||||
loadAuctionsPaused?.IsChecked == true ? "Paused" :
|
||||
"Stopped";
|
||||
}
|
||||
|
||||
var newAuctionActive = Settings.FindName("NewAuctionActive") as System.Windows.Controls.RadioButton;
|
||||
var newAuctionPaused = Settings.FindName("NewAuctionPaused") as System.Windows.Controls.RadioButton;
|
||||
|
||||
@@ -256,9 +256,8 @@ namespace AutoBidder
|
||||
{
|
||||
try
|
||||
{
|
||||
// ? Carica impostazioni per determinare lo stato iniziale delle aste
|
||||
// ? Carica impostazioni
|
||||
var settings = Utilities.SettingsManager.Load();
|
||||
var loadState = settings.DefaultStartAuctionsOnLoad; // "Active", "Paused", "Stopped"
|
||||
|
||||
// Ottieni username corrente dalla sessione per ripristinare IsMyBid
|
||||
var session = _auctionMonitor.GetSession();
|
||||
@@ -273,7 +272,7 @@ namespace AutoBidder
|
||||
// Decode HTML entities
|
||||
try { auction.Name = System.Net.WebUtility.HtmlDecode(auction.Name ?? string.Empty); } catch { }
|
||||
|
||||
// ? NUOVO: Ripristina IsMyBid per tutte le puntate in RecentBids
|
||||
// ? Ripristina IsMyBid per tutte le puntate in RecentBids
|
||||
if (auction.RecentBids != null && auction.RecentBids.Count > 0 && !string.IsNullOrEmpty(currentUsername))
|
||||
{
|
||||
foreach (var bid in auction.RecentBids)
|
||||
@@ -282,7 +281,16 @@ namespace AutoBidder
|
||||
}
|
||||
}
|
||||
|
||||
// ? Applica stato iniziale configurato dall'utente
|
||||
// ? NUOVO: Gestione stato in base a RememberAuctionStates
|
||||
if (settings.RememberAuctionStates)
|
||||
{
|
||||
// MODO 1: Ripristina lo stato salvato di ogni asta (IsActive e IsPaused vengono dal file salvato)
|
||||
// Non serve fare nulla, lo stato è già quello salvato nel file
|
||||
}
|
||||
else
|
||||
{
|
||||
// MODO 2: Applica DefaultStartAuctionsOnLoad a tutte le aste
|
||||
var loadState = settings.DefaultStartAuctionsOnLoad;
|
||||
switch (loadState)
|
||||
{
|
||||
case "Active":
|
||||
@@ -299,14 +307,14 @@ namespace AutoBidder
|
||||
auction.IsPaused = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_auctionMonitor.AddAuction(auction);
|
||||
var vm = new AuctionViewModel(auction);
|
||||
_auctionViewModels.Add(vm);
|
||||
}
|
||||
|
||||
// ? FIX: Avvia monitoraggio se ci sono aste in stato Active O Paused
|
||||
// (Paused = IsActive=true ma IsPaused=true, quindi vanno monitorate)
|
||||
// ? Avvia monitoraggio se ci sono aste in stato Active O Paused
|
||||
bool hasActiveOrPausedAuctions = auctions.Any(a => a.IsActive);
|
||||
|
||||
if (hasActiveOrPausedAuctions && auctions.Count > 0)
|
||||
@@ -314,6 +322,15 @@ namespace AutoBidder
|
||||
_auctionMonitor.Start();
|
||||
_isAutomationActive = true;
|
||||
|
||||
if (settings.RememberAuctionStates)
|
||||
{
|
||||
var activeCount = auctions.Count(a => a.IsActive && !a.IsPaused);
|
||||
var pausedCount = auctions.Count(a => a.IsActive && a.IsPaused);
|
||||
Log($"[AUTO-START] Monitoraggio avviato: {activeCount} attive, {pausedCount} in pausa (stati ripristinati)", LogLevel.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
var loadState = settings.DefaultStartAuctionsOnLoad;
|
||||
if (loadState == "Active")
|
||||
{
|
||||
Log($"[AUTO-START] Monitoraggio avviato automaticamente per {auctions.Count} aste caricate in stato attivo", LogLevel.Info);
|
||||
@@ -323,6 +340,7 @@ namespace AutoBidder
|
||||
Log($"[AUTO-START] Monitoraggio avviato automaticamente per {auctions.Count} aste caricate in pausa", LogLevel.Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdateTotalCount();
|
||||
UpdateGlobalControlButtons();
|
||||
@@ -330,7 +348,14 @@ namespace AutoBidder
|
||||
// Log sempre mostrato (anche con 0 aste)
|
||||
if (auctions.Count > 0)
|
||||
{
|
||||
Log($"[LOAD] {auctions.Count} aste caricate con stato iniziale: {loadState}", LogLevel.Info);
|
||||
if (settings.RememberAuctionStates)
|
||||
{
|
||||
Log($"[LOAD] {auctions.Count} aste caricate con stati individuali ripristinati", LogLevel.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log($"[LOAD] {auctions.Count} aste caricate con stato iniziale: {settings.DefaultStartAuctionsOnLoad}", LogLevel.Info);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -41,6 +41,8 @@ namespace AutoBidder
|
||||
Log("[START ALL] Tutte le aste avviate/riprese", LogLevel.Info);
|
||||
}
|
||||
|
||||
// ✅ Salva gli stati aggiornati su disco
|
||||
SaveAuctions();
|
||||
UpdateGlobalControlButtons();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -67,6 +69,8 @@ namespace AutoBidder
|
||||
_isAutomationActive = false;
|
||||
}
|
||||
|
||||
// ✅ Salva gli stati aggiornati su disco
|
||||
SaveAuctions();
|
||||
UpdateGlobalControlButtons();
|
||||
|
||||
if (sender != null) // Solo se chiamato dall'utente
|
||||
@@ -88,6 +92,9 @@ namespace AutoBidder
|
||||
{
|
||||
vm.IsPaused = true;
|
||||
}
|
||||
|
||||
// ✅ Salva gli stati aggiornati su disco
|
||||
SaveAuctions();
|
||||
UpdateGlobalControlButtons();
|
||||
|
||||
if (sender != null) // Solo se chiamato dall'utente
|
||||
|
||||
@@ -58,6 +58,8 @@ namespace AutoBidder
|
||||
Log($"[START] Asta avviata: {vm.Name}", LogLevel.Info);
|
||||
}
|
||||
|
||||
// ? Salva gli stati aggiornati su disco
|
||||
SaveAuctions();
|
||||
UpdateGlobalControlButtons();
|
||||
}
|
||||
|
||||
@@ -66,6 +68,9 @@ namespace AutoBidder
|
||||
if (vm == null) return;
|
||||
vm.IsPaused = true;
|
||||
Log($"[PAUSA] Asta in pausa: {vm.Name}", LogLevel.Info);
|
||||
|
||||
// ? Salva gli stati aggiornati su disco
|
||||
SaveAuctions();
|
||||
UpdateGlobalControlButtons();
|
||||
}
|
||||
|
||||
@@ -87,6 +92,8 @@ namespace AutoBidder
|
||||
Log($"[STOP] Asta fermata: {vm.Name}", LogLevel.Info);
|
||||
}
|
||||
|
||||
// ? Salva gli stati aggiornati su disco
|
||||
SaveAuctions();
|
||||
UpdateGlobalControlButtons();
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,13 @@ namespace AutoBidder.Utilities
|
||||
/// </summary>
|
||||
public string DefaultNewAuctionState { get; set; } = "Stopped";
|
||||
|
||||
/// <summary>
|
||||
/// Se TRUE, salva e ripristina lo stato effettivo (attiva/pausa/ferma) di ogni asta.
|
||||
/// Se FALSE, applica DefaultStartAuctionsOnLoad a tutte le aste al caricamento.
|
||||
/// Default: false (usa DefaultStartAuctionsOnLoad)
|
||||
/// </summary>
|
||||
public bool RememberAuctionStates { get; set; } = false;
|
||||
|
||||
// ? NUOVO: LIMITE MINIMO PUNTATE
|
||||
/// <summary>
|
||||
/// Numero minimo di puntate residue da mantenere sull'account.
|
||||
|
||||
Reference in New Issue
Block a user