public TradeGridViewModel(StockInfoViewModel stockInfoViewModel, IDialogService dialogService, StockAgent stockAgent, UserStockInfoViewModel userStockInfoViewModel, UserMoneyInfo userMoneyInfo) { _stockInfoViewModel = stockInfoViewModel; _dialogService = dialogService; _stockAgent = stockAgent; _userStockInfoViewModel = userStockInfoViewModel; _userMoneyInfo = userMoneyInfo; Messenger.Default.Register <GenericMessage <double?> >(this, UpdateSingleText, d => { if (d.Content == null) { BuyCbbSelectedIndex = -1; SellCbbSelectedIndex = -1; } else { if (BuyCbbSelectedIndex == 0) { BuySingleText = ((double)d.Content).ToString("F2"); } if (SellCbbSelectedIndex == 0) { SellSingleText = ((double)d.Content).ToString("F2"); } } }); }
public AccountButtonViewModel(MainWindowModel mainWindowModel, StockAgent stockAgent, IDialogService dialogService, UserMoneyInfo userMoneyInfo, IFrameNavigationService frameNavigationService) { _mainWindowModel = mainWindowModel; _stockAgent = stockAgent; _dialogService = dialogService; _userMoneyInfo = userMoneyInfo; _frameNavigationService = frameNavigationService; Messenger.Default.Register <GenericMessage <bool> >(this, UpdateUserMoneyInfo, b => { lock (this) { if (b.Content && _updateUserMoneyInfo == null) { _cts = new CancellationTokenSource(); _updateUserMoneyInfo = Update(_cts.Token); } else if (!b.Content && _cts != null && _updateUserMoneyInfo != null) { _cts.Cancel(); _updateUserMoneyInfo = null; } } }); }