public void loadOfflineStocks() { var rootObject = JsonConvert.DeserializeObject <RootObject>(readFromFile("ps3.json")); var stocks = rootObject.Stocks; StockRepository.getInstance().setStocksPs3(stocks); ps3Stocks.ItemsSource = StockRepository.getInstance().StocksPs3; rootObject = JsonConvert.DeserializeObject <RootObject>(readFromFile("xbox.json")); stocks = rootObject.Stocks; StockRepository.getInstance().setStocksXbox(stocks); xboxStocks.ItemsSource = StockRepository.getInstance().StocksXbox; }
// When page is navigated to set data context to selected item in list async protected override void OnNavigatedTo(NavigationEventArgs e) { string selectedIndex = ""; string platform; NavigationContext.QueryString.TryGetValue("platform", out platform); if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex)) { int index = int.Parse(selectedIndex); Stock s = null; if (platform.Equals("ps3")) { s = StockRepository.getInstance().getStockPs3(index); } else { s = StockRepository.getInstance().getStockXbox(index); } Uri uri = new Uri("/stockLogos/stock-" + s.CompanyCode + ".png", UriKind.Relative); ImageSource imgSource = new BitmapImage(uri); StockLogo.Source = imgSource; StockHistory h = s.getHistory(); AreaSeries series = (AreaSeries)this.chart.Series[0]; series.ItemsSource = h; if (s.PriceMovementDirection.Equals("down")) { PriceMovementDirection.Foreground = new SolidColorBrush(Color.FromArgb(255, 204, 0, 0)); PriceMovement.Foreground = new SolidColorBrush(Color.FromArgb(255, 204, 0, 0)); PriceMovementPercent.Foreground = new SolidColorBrush(Color.FromArgb(255, 204, 0, 0)); s.PriceMovementDirection = "6"; } else { PriceMovementDirection.Foreground = new SolidColorBrush(Color.FromArgb(255, 108, 148, 56)); PriceMovement.Foreground = new SolidColorBrush(Color.FromArgb(255, 108, 148, 56)); PriceMovementPercent.Foreground = new SolidColorBrush(Color.FromArgb(255, 108, 148, 56)); s.PriceMovementDirection = "5"; } DataContext = s; //NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative)); } }