public Shell(Frame frame, WeeklyFoodMenu menu) { this.InitializeComponent(); this.menu = menu; this.SplitViewMain.Content = frame; (SplitViewMain.Content as Frame).Navigate(typeof(MainPage), AllLocationsRadioButton); }
private void CreateLunchMenu(WeeklyFoodMenu menu) { List <Product> products = null; foreach (var outlet in menu.data.outlets) { if (outlet.outlet_id.Equals(REVELATION_ID)) { foreach (var outletMenu in outlet.menu) { if (outletMenu.day.Equals(DateTime.Now.ToString("dddd"))) { products = outletMenu.meals.lunch; for (int i = 0; i < products.Count; i++) { TextBlock productName = new TextBlock(); productName.FontSize = 16; productName.FontWeight = FontWeights.Bold; productName.TextWrapping = TextWrapping.WrapWholeWords; productName.Margin = new Thickness(0, 10, 0, 0); productName.Text = products[i].product_name; TextBlock productDetails = new TextBlock(); productDetails.FontSize = 14; productDetails.TextWrapping = TextWrapping.WrapWholeWords; productDetails.Margin = new Thickness(5, 0, 0, 0); if (products[i].diet_type != null) { productDetails.Text = products[i].diet_type; } else { productDetails.Visibility = Visibility.Collapsed; } StackPanelLunchProducts.Children.Add(productName); StackPanelLunchProducts.Children.Add(productDetails); } break; } } break; } } if (products == null) { StackPanelLunchProducts.Visibility = Visibility.Collapsed; StackPanelLunchEmpty.Visibility = Visibility.Visible; } else { StackPanelLunchProducts.Visibility = Visibility.Visible; StackPanelLunchEmpty.Visibility = Visibility.Collapsed; } }
private async Task getWeeklyFoodMenu() { Uri uri = new Uri("https://api.uwaterloo.ca/v2/foodservices/menu.json?key=" + UWApiKey); HttpClient httpClient = new HttpClient(); HttpResponseMessage response = await httpClient.GetAsync(uri); string jsonString = await response.Content.ReadAsStringAsync(); menu = JsonConvert.DeserializeObject <WeeklyFoodMenu>(jsonString); }
protected override void OnNavigatedTo(NavigationEventArgs e) { WeeklyFoodMenu menu = App.menu; CreateMap(); if (menu.data != null) { CreateLunchMenu(menu); } if (e.Parameter != null) { (e.Parameter as RadioButton).IsChecked = true; } }