/// <summary> /// Initializes a new instance of the <see cref="StockInfoViewModel"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="symbol">The symbol.</param> /// <param name="brush">The brush.</param> /// <param name="range">The range.</param> public StockInfoViewModel(StockViewModel parent, StockTickerDetailsViewModel details, Brush brush, int range) { Brush = brush; _parent = parent; RangeFilter = range == 0 ? 3 : range; _details = details; }
/// <summary> /// Called when [refresh details]. /// </summary> /// <param name="data">The data.</param> private void OnRefreshDetails(IDictionary <string, StockTickerDetails> data) { //copy the stock details data to the two repositories of stock data int i = 0; foreach (string key in data.Keys) { StockTickerDetailsViewModel stdvm = new StockTickerDetailsViewModel(data[key]); if (_stockDetailsDictionary.ContainsKey(key)) { _stockDetailsDictionary[key].Update(data[key]); _allStockDetails[i++].Update(data[key]); } else { _stockDetailsDictionary.Add(key, stdvm); _allStockDetails.Add(stdvm); } } //copy the historic data for watched stocks foreach (var sivm in _stocks) { // It is possible a new stock was added while a query was in progress // If so, we can ignore it as it will be picked up on the next query if (data.ContainsKey(sivm.Symbol)) { sivm.Details.Update(data[sivm.Symbol]); } } //trigger updates for stock data RaisePropertyChanged("SelectedStock"); RaisePropertyChanged("AllStocksInfo"); RaisePropertyChanged("Tickers"); RaisePropertyChanged("IsDetailsPopulated"); }
public StockPositionViewModel() { //var td = new StockTickerDetailsViewModel(); //td.Name = "Microsoft"; //td.Symbol = "MSFT"; //td.Open = 50; //td.DailyLow = 50; //td.Bid = 49; //td.Ask = 50; //td.Change = 10; //td.LastTradeAmount = 46; _pricePaid = 50; _quantity = 1; _stockTickerDetailsViewModel = new StockTickerDetailsViewModel(); _stockTickerDetailsViewModel.Name = "Microsoft"; _stockTickerDetailsViewModel.Symbol = "MSFT"; _stockTickerDetailsViewModel.Open = 50; _stockTickerDetailsViewModel.DailyLow = 50; _stockTickerDetailsViewModel.Bid = 49; _stockTickerDetailsViewModel.Ask = 50; _stockTickerDetailsViewModel.Change = 10; _stockTickerDetailsViewModel.LastTradeAmount = 46; }