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 StockDepthInfoViewModel(StockAgent stockAgent, IDialogService dialogService, StockInfoViewModel stockInfoViewModel) { _stockAgent = stockAgent; _dialogService = dialogService; _stockInfoViewModel = stockInfoViewModel; Messenger.Default.Register <GenericMessage <bool> >(this, UpdateStockDepthInfo, b => { lock (this) { if (b.Content && (_updateBuyStockDepthInfo == null || _updateSellStockDepthInfo == null)) { _cts = new CancellationTokenSource(); _updateBuyStockDepthInfo = UpdateBuy(_cts.Token); _updateSellStockDepthInfo = UpdateSell(_cts.Token); } else if (!b.Content && _cts != null && (_updateBuyStockDepthInfo != null || _updateSellStockDepthInfo != null)) { _cts.Cancel(); _updateBuyStockDepthInfo = null; _updateSellStockDepthInfo = null; BuyStockDepthInfoList.Clear(); SellStockDepthInfoList.Clear(); } } }); }
public UserStockInfoViewModel(StockAgent stockAgent, IDialogService dialogService, StockInfoViewModel stockInfoViewModel) { _stockAgent = stockAgent; _dialogService = dialogService; _stockInfoViewModel = stockInfoViewModel; Messenger.Default.Register <GenericMessage <bool> >(this, UpdateUserStockInfo, b => { lock (this) { if (b.Content && _updateUserStockInfo == null) { _cts = new CancellationTokenSource(); _updateUserStockInfo = Update(_cts.Token); } else if (!b.Content && _cts != null && _updateUserStockInfo != null) { _cts.Cancel(); _updateUserStockInfo = null; } } }); }