f017ec0364
* Aggiunto `BooleanToOpacityConverter` per gestire opacità dinamica. * Introdotto nuovo sistema di timing con `BidBeforeDeadlineMs`. * Aggiunta opzione `CheckAuctionOpenBeforeBid` per maggiore sicurezza. * Implementato polling adattivo (10ms-1000ms) e cooldown di 800ms. * Migliorata gestione pulsanti globali con supporto `AUTO-START`/`AUTO-STOP`. * Fix per il tasto `Canc` e focus automatico sul `DataGrid`. * Fix per avvio singola asta senza necessità di "Avvia Tutti". * Aggiornati formati CSV/JSON/XML con nuovi campi. * Migliorata gestione cookie con endpoint unico `buy_bids.php`. * Miglioramenti UI/UX: tooltip, formattazione prezzi, feedback visivo. * Aggiornata documentazione e changelog per la versione 4.0.0.
112 lines
3.7 KiB
C#
112 lines
3.7 KiB
C#
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using AutoBidder.Utilities;
|
|
using AutoBidder.ViewModels;
|
|
|
|
namespace AutoBidder
|
|
{
|
|
/// <summary>
|
|
/// Command implementations for MainWindow
|
|
/// </summary>
|
|
public partial class MainWindow
|
|
{
|
|
private void InitializeCommands()
|
|
{
|
|
StartAllCommand = new RelayCommand(_ => ExecuteStartAll());
|
|
StopAllCommand = new RelayCommand(_ => ExecuteStopAll());
|
|
PauseAllCommand = new RelayCommand(_ => ExecutePauseAll());
|
|
|
|
GridStartCommand = new RelayCommand(param => ExecuteGridStart(param as AuctionViewModel));
|
|
GridPauseCommand = new RelayCommand(param => ExecuteGridPause(param as AuctionViewModel));
|
|
GridStopCommand = new RelayCommand(param => ExecuteGridStop(param as AuctionViewModel));
|
|
GridBidCommand = new RelayCommand(async param => await ExecuteGridBidAsync(param as AuctionViewModel));
|
|
}
|
|
|
|
private void ExecuteStartAll()
|
|
{
|
|
StartButton_Click(null, null);
|
|
}
|
|
|
|
private void ExecuteStopAll()
|
|
{
|
|
StopButton_Click(null, null);
|
|
}
|
|
|
|
private void ExecutePauseAll()
|
|
{
|
|
PauseAllButton_Click(null, null);
|
|
}
|
|
|
|
private void ExecuteGridStart(AuctionViewModel? vm)
|
|
{
|
|
if (vm == null) return;
|
|
|
|
// Attiva l'asta
|
|
vm.IsActive = true;
|
|
vm.IsPaused = false;
|
|
|
|
// Se il monitoraggio globale non è attivo, avvialo automaticamente
|
|
if (!_isAutomationActive)
|
|
{
|
|
_auctionMonitor.Start();
|
|
_isAutomationActive = true;
|
|
Log($"[AUTO-START] Monitoraggio avviato automaticamente per asta: {vm.Name}", LogLevel.Info);
|
|
}
|
|
else
|
|
{
|
|
Log($"[START] Asta avviata: {vm.Name}", LogLevel.Info);
|
|
}
|
|
|
|
UpdateGlobalControlButtons();
|
|
}
|
|
|
|
private void ExecuteGridPause(AuctionViewModel? vm)
|
|
{
|
|
if (vm == null) return;
|
|
vm.IsPaused = true;
|
|
Log($"[PAUSA] Asta in pausa: {vm.Name}", LogLevel.Info);
|
|
UpdateGlobalControlButtons();
|
|
}
|
|
|
|
private void ExecuteGridStop(AuctionViewModel? vm)
|
|
{
|
|
if (vm == null) return;
|
|
vm.IsActive = false;
|
|
|
|
// Se tutte le aste sono fermate, ferma anche il monitoraggio globale
|
|
bool hasActiveAuctions = _auctionViewModels.Any(a => a.IsActive);
|
|
if (!hasActiveAuctions && _isAutomationActive)
|
|
{
|
|
_auctionMonitor.Stop();
|
|
_isAutomationActive = false;
|
|
Log($"[AUTO-STOP] Monitoraggio fermato: nessuna asta attiva", LogLevel.Info);
|
|
}
|
|
else
|
|
{
|
|
Log($"[STOP] Asta fermata: {vm.Name}", LogLevel.Info);
|
|
}
|
|
|
|
UpdateGlobalControlButtons();
|
|
}
|
|
|
|
private async Task ExecuteGridBidAsync(AuctionViewModel? vm)
|
|
{
|
|
if (vm == null) return;
|
|
try
|
|
{
|
|
Log($"[BID] Puntata manuale richiesta su: {vm.Name}", LogLevel.Info);
|
|
var result = await _auctionMonitor.PlaceManualBidAsync(vm.AuctionInfo);
|
|
if (result.Success)
|
|
Log($"[OK] Puntata manuale su {vm.Name}: {result.LatencyMs}ms", LogLevel.Success);
|
|
else
|
|
Log($"[FAIL] Puntata manuale su {vm.Name}: {result.Error}", LogLevel.Error);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
Log($"[ERRORE] Puntata manuale: {ex.Message}", LogLevel.Error);
|
|
}
|
|
}
|
|
}
|
|
}
|