public void AddStockToWatchList(List <string> symbols) { foreach (var symbol in symbols) { if (ContainsStockTicker(symbol)) { continue; } // check if the symbol is actually valid and known stock if (IsValidStockSymbol(symbol)) { // If we have more stocks than brushes, lets find the next brush to use var brush = GetStockNextFillBrush(); var outline = GetStockNextOutlineBrush(); var range = _stocks.Count > 0 ? _stocks[0].RangeFilter : 1; var stock = new StockInfoViewModel(this, symbol, brush, outline, range); //Get the data for the stock. RefreshData(stock); //Add the stock to the other stocks. _stocks.Add(stock); DebugManager.Log("StockViewModel.AddedStock: " + symbol); } } OnPropertyChanged("Tickers"); if (SelectedStock == null && _stocks.Count > 0) { this.SelectedStock = _stocks.Last(); } }
/// <summary> /// Refreshes the data. /// </summary> public void RefreshData(StockInfoViewModel stock) { #if SILVERLIGHT StockService.RequestStockHistoryAsync(stock.Symbol); #else StockService.RequestStockHistoryAsync(stock.Symbol, OnRefreshData); #endif //StockService.RequestStockHistory(stock.Symbol, OnRefreshData, DateTime.Now.AddYears(-100)); }
/// <summary> /// Adds the stock to watch list. /// </summary> /// <param name="symbol">The symbol.</param> public void AddStockToWatchList(string symbol) { if (ContainsStockTicker(symbol)) { return; } // check if the symbol is actually valid and known stock if (!IsValidStockSymbol(symbol)) { return; } // If we have more stocks than brushes, lets find the next brush to use var brush = GetStockNextFillBrush(); var outline = GetStockNextOutlineBrush(); var range = _stocks.Count > 0 ? _stocks[0].RangeFilter : _stockDisplayRange; var stock = new StockInfoViewModel(this, symbol, brush, outline, range); //Get the data for the stock. RefreshData(stock); //Add the stock to the other stocks. _stocks.Add(stock); DebugManager.Log("StockViewModel.AddedStock: " + symbol); OnPropertyChanged("NewTicker"); OnPropertyChanged("Tickers"); UserLastStockSymbol = symbol; // If this is the first stock, lets automatically select it. if (_stocks.Count == 1 || SelectedStock == null) { this.SelectedStock = _stocks.First(); } }