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"
|
Content="Attive"
|
||||||
GroupName="LoadState"
|
GroupName="LoadState"
|
||||||
ToolTip="Le aste salvate verranno avviate automaticamente all'apertura"/>
|
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>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Stato nuove aste -->
|
<!-- Stato nuove aste -->
|
||||||
@@ -280,8 +284,10 @@
|
|||||||
• <Bold>Fermata:</Bold> L'asta non viene monitorata fino all'avvio manuale.<LineBreak/>
|
• <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>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>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/>
|
<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>
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ namespace AutoBidder
|
|||||||
UpdateMinBidsIndicator(settings.MinimumRemainingBids);
|
UpdateMinBidsIndicator(settings.MinimumRemainingBids);
|
||||||
|
|
||||||
// Carica stato iniziale aste
|
// 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)
|
switch (settings.DefaultStartAuctionsOnLoad)
|
||||||
{
|
{
|
||||||
case "Active":
|
case "Active":
|
||||||
@@ -53,6 +61,7 @@ namespace AutoBidder
|
|||||||
Settings.LoadAuctionsStopped.IsChecked = true;
|
Settings.LoadAuctionsStopped.IsChecked = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (settings.DefaultNewAuctionState)
|
switch (settings.DefaultNewAuctionState)
|
||||||
{
|
{
|
||||||
@@ -231,12 +240,26 @@ namespace AutoBidder
|
|||||||
}
|
}
|
||||||
|
|
||||||
// === SEZIONE DEFAULTS: Stati Iniziali Aste ===
|
// === 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 loadAuctionsActive = Settings.FindName("LoadAuctionsActive") as System.Windows.Controls.RadioButton;
|
||||||
var loadAuctionsPaused = Settings.FindName("LoadAuctionsPaused") 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" :
|
settings.DefaultStartAuctionsOnLoad = loadAuctionsActive?.IsChecked == true ? "Active" :
|
||||||
loadAuctionsPaused?.IsChecked == true ? "Paused" :
|
loadAuctionsPaused?.IsChecked == true ? "Paused" :
|
||||||
"Stopped";
|
"Stopped";
|
||||||
|
}
|
||||||
|
|
||||||
var newAuctionActive = Settings.FindName("NewAuctionActive") as System.Windows.Controls.RadioButton;
|
var newAuctionActive = Settings.FindName("NewAuctionActive") as System.Windows.Controls.RadioButton;
|
||||||
var newAuctionPaused = Settings.FindName("NewAuctionPaused") as System.Windows.Controls.RadioButton;
|
var newAuctionPaused = Settings.FindName("NewAuctionPaused") as System.Windows.Controls.RadioButton;
|
||||||
|
|||||||
@@ -256,11 +256,10 @@ namespace AutoBidder
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// ? Carica impostazioni per determinare lo stato iniziale delle aste
|
// ? Carica impostazioni
|
||||||
var settings = Utilities.SettingsManager.Load();
|
var settings = Utilities.SettingsManager.Load();
|
||||||
var loadState = settings.DefaultStartAuctionsOnLoad; // "Active", "Paused", "Stopped"
|
|
||||||
|
|
||||||
// Ottieni username corrente dalla sessione per riprist inare IsMyBid
|
// Ottieni username corrente dalla sessione per ripristinare IsMyBid
|
||||||
var session = _auctionMonitor.GetSession();
|
var session = _auctionMonitor.GetSession();
|
||||||
var currentUsername = session?.Username ?? string.Empty;
|
var currentUsername = session?.Username ?? string.Empty;
|
||||||
|
|
||||||
@@ -273,7 +272,7 @@ namespace AutoBidder
|
|||||||
// Decode HTML entities
|
// Decode HTML entities
|
||||||
try { auction.Name = System.Net.WebUtility.HtmlDecode(auction.Name ?? string.Empty); } catch { }
|
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))
|
if (auction.RecentBids != null && auction.RecentBids.Count > 0 && !string.IsNullOrEmpty(currentUsername))
|
||||||
{
|
{
|
||||||
foreach (var bid in auction.RecentBids)
|
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)
|
switch (loadState)
|
||||||
{
|
{
|
||||||
case "Active":
|
case "Active":
|
||||||
@@ -299,14 +307,14 @@ namespace AutoBidder
|
|||||||
auction.IsPaused = false;
|
auction.IsPaused = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_auctionMonitor.AddAuction(auction);
|
_auctionMonitor.AddAuction(auction);
|
||||||
var vm = new AuctionViewModel(auction);
|
var vm = new AuctionViewModel(auction);
|
||||||
_auctionViewModels.Add(vm);
|
_auctionViewModels.Add(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ? FIX: Avvia monitoraggio se ci sono aste in stato Active O Paused
|
// ? Avvia monitoraggio se ci sono aste in stato Active O Paused
|
||||||
// (Paused = IsActive=true ma IsPaused=true, quindi vanno monitorate)
|
|
||||||
bool hasActiveOrPausedAuctions = auctions.Any(a => a.IsActive);
|
bool hasActiveOrPausedAuctions = auctions.Any(a => a.IsActive);
|
||||||
|
|
||||||
if (hasActiveOrPausedAuctions && auctions.Count > 0)
|
if (hasActiveOrPausedAuctions && auctions.Count > 0)
|
||||||
@@ -314,6 +322,15 @@ namespace AutoBidder
|
|||||||
_auctionMonitor.Start();
|
_auctionMonitor.Start();
|
||||||
_isAutomationActive = true;
|
_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")
|
if (loadState == "Active")
|
||||||
{
|
{
|
||||||
Log($"[AUTO-START] Monitoraggio avviato automaticamente per {auctions.Count} aste caricate in stato attivo", LogLevel.Info);
|
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);
|
Log($"[AUTO-START] Monitoraggio avviato automaticamente per {auctions.Count} aste caricate in pausa", LogLevel.Info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UpdateTotalCount();
|
UpdateTotalCount();
|
||||||
UpdateGlobalControlButtons();
|
UpdateGlobalControlButtons();
|
||||||
@@ -330,7 +348,14 @@ namespace AutoBidder
|
|||||||
// Log sempre mostrato (anche con 0 aste)
|
// Log sempre mostrato (anche con 0 aste)
|
||||||
if (auctions.Count > 0)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ namespace AutoBidder
|
|||||||
Log("[START ALL] Tutte le aste avviate/riprese", LogLevel.Info);
|
Log("[START ALL] Tutte le aste avviate/riprese", LogLevel.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ✅ Salva gli stati aggiornati su disco
|
||||||
|
SaveAuctions();
|
||||||
UpdateGlobalControlButtons();
|
UpdateGlobalControlButtons();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -67,6 +69,8 @@ namespace AutoBidder
|
|||||||
_isAutomationActive = false;
|
_isAutomationActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ✅ Salva gli stati aggiornati su disco
|
||||||
|
SaveAuctions();
|
||||||
UpdateGlobalControlButtons();
|
UpdateGlobalControlButtons();
|
||||||
|
|
||||||
if (sender != null) // Solo se chiamato dall'utente
|
if (sender != null) // Solo se chiamato dall'utente
|
||||||
@@ -88,6 +92,9 @@ namespace AutoBidder
|
|||||||
{
|
{
|
||||||
vm.IsPaused = true;
|
vm.IsPaused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ✅ Salva gli stati aggiornati su disco
|
||||||
|
SaveAuctions();
|
||||||
UpdateGlobalControlButtons();
|
UpdateGlobalControlButtons();
|
||||||
|
|
||||||
if (sender != null) // Solo se chiamato dall'utente
|
if (sender != null) // Solo se chiamato dall'utente
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ namespace AutoBidder
|
|||||||
Log($"[START] Asta avviata: {vm.Name}", LogLevel.Info);
|
Log($"[START] Asta avviata: {vm.Name}", LogLevel.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ? Salva gli stati aggiornati su disco
|
||||||
|
SaveAuctions();
|
||||||
UpdateGlobalControlButtons();
|
UpdateGlobalControlButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +68,9 @@ namespace AutoBidder
|
|||||||
if (vm == null) return;
|
if (vm == null) return;
|
||||||
vm.IsPaused = true;
|
vm.IsPaused = true;
|
||||||
Log($"[PAUSA] Asta in pausa: {vm.Name}", LogLevel.Info);
|
Log($"[PAUSA] Asta in pausa: {vm.Name}", LogLevel.Info);
|
||||||
|
|
||||||
|
// ? Salva gli stati aggiornati su disco
|
||||||
|
SaveAuctions();
|
||||||
UpdateGlobalControlButtons();
|
UpdateGlobalControlButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +92,8 @@ namespace AutoBidder
|
|||||||
Log($"[STOP] Asta fermata: {vm.Name}", LogLevel.Info);
|
Log($"[STOP] Asta fermata: {vm.Name}", LogLevel.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ? Salva gli stati aggiornati su disco
|
||||||
|
SaveAuctions();
|
||||||
UpdateGlobalControlButtons();
|
UpdateGlobalControlButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,13 @@ namespace AutoBidder.Utilities
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string DefaultNewAuctionState { get; set; } = "Stopped";
|
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
|
// ? NUOVO: LIMITE MINIMO PUNTATE
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Numero minimo di puntate residue da mantenere sull'account.
|
/// Numero minimo di puntate residue da mantenere sull'account.
|
||||||
|
|||||||
Reference in New Issue
Block a user