void UpdateWatchList(StockData[] watchListData) { int count = 0; int isRise = 0; oldWatchListData = new ObservableCollection <CompanyTradingDataViewModel>(watchLisBindingData as IEnumerable <CompanyTradingDataViewModel>); oldWatchListData = new ObservableCollection <CompanyTradingDataViewModel>(); foreach (CompanyTradingDataViewModel item in watchLisBindingData) { oldWatchListData.Add(new CompanyTradingDataViewModel(item.TradingData, item.CompanyName, item.Rise, item.TotalRise)); } watchLisBindingData.BeginUpdate(); foreach (StockData dt in watchListData) { if (companies.Count <= (dt.CompanyID)) { continue; } CompanyTradingData ctd = new CompanyTradingData(dt, companies[dt.CompanyID]); if (watchLisBindingData.Count < companies.Count) { watchLisBindingData.Add(new CompanyTradingDataViewModel(ctd, ctd.CompanyName, isRise, 1)); } else { SetWatchListBindingData(count, ctd); count++; } } watchLisBindingData.EndUpdate(); if (watchListChanged != null) { watchListChanged(this, EventArgs.Empty); } }
void SetTransactionGridBindingData(List <TransactionData> transactions) { transactionGridBindingData.Clear(); transactionGridBindingData.BeginUpdate(); foreach (TransactionData tdvm in transactions) { transactionGridBindingData.Add(tdvm); } transactionGridBindingData.EndUpdate(); CurrentPriceIndex = model.CurrentPriceIndex; RaiseCurrentPriceIndexChanged(); }