using CommunityToolkit.Mvvm.Input;
using XFEEDToolBox.Core.Presentation;
namespace XFEEDToolBox.ViewModels;
public partial class ToolboxViewModel
{
private bool CanExecuteTradePlan() => SelectedStart is not null && AutomaticDestination is not null && SelectedStart.MarketId!=AutomaticDestination.MarketId && !RunActive && !SessionBusy && !NavigationActive
&& (SelectedTradeCandidate is not null||manualTradeConfigured) && !TradeHasExistingCargo
&& !DemoMode && !Environment.GetCommandLineArgs().Contains("--offline-preview");
partial void OnSelectedStartChanged(StationLiveRow? value){NoteManualTradeConfiguration();InvalidateTradeCandidates();NotifyTradePlanningSummary();RefreshTradePlanCommands();}
private void RefreshTradePlanCommands()
{
StartPlanCommand.NotifyCanExecuteChanged();
ExecuteTradePlanCommand.NotifyCanExecuteChanged();
UpdateAndStartAutomaticTradeCommand.NotifyCanExecuteChanged();
}
[RelayCommand(CanExecute = nameof(CanExecuteTradePlan))]
private async Task ExecuteTradePlanAsync(CancellationToken cancellationToken)
{
if (!CanExecuteTradePlan()) return;
if(TradeExecutesFullPlan)
{
ExecutionModeIndex=2;
await StartPlanAsync(cancellationToken);
return;
}
await RunSelectedAutomaticTradeAsync();
}
}
using CommunityToolkit.Mvvm.Input;
using XFEEDToolBox.Core.Presentation;
namespace XFEEDToolBox.ViewModels;
public partial class ToolboxViewModel
{
private bool CanExecuteTradePlan() => SelectedStart is not null && AutomaticDestination is not null && SelectedStart.MarketId!=AutomaticDestination.MarketId && !RunActive && !SessionBusy && !NavigationActive
&& (SelectedTradeCandidate is not null||manualTradeConfigured) && !TradeHasExistingCargo
&& !DemoMode && !Environment.GetCommandLineArgs().Contains("--offline-preview");
partial void OnSelectedStartChanged(StationLiveRow? value){NoteManualTradeConfiguration();InvalidateTradeCandidates();NotifyTradePlanningSummary();RefreshTradePlanCommands();}
private void RefreshTradePlanCommands()
{
StartPlanCommand.NotifyCanExecuteChanged();
ExecuteTradePlanCommand.NotifyCanExecuteChanged();
UpdateAndStartAutomaticTradeCommand.NotifyCanExecuteChanged();
}
[RelayCommand(CanExecute = nameof(CanExecuteTradePlan))]
private async Task ExecuteTradePlanAsync(CancellationToken cancellationToken)
{
if (!CanExecuteTradePlan()) return;
if(TradeExecutesFullPlan)
{
ExecutionModeIndex=2;
await StartPlanAsync(cancellationToken);
return;
}
await RunSelectedAutomaticTradeAsync();
}
}