public override async Task OnNavigatedTo(NavigationEventArgs e) { var recipes = await _recipesService.Load("Data\\Recipes.json"); var ds = new List <string>(); RecipeDataGroup group = null; Recipes = new ObservableCollection <RecipeDataItem>(); foreach (RecipeDataItem recipe in recipes) { Recipes.Add(recipe); if (!ds.Contains(recipe.Group.UniqueId)) { group = recipe.Group; group.Items = new ObservableCollection <RecipeDataItem>(); ds.Add(recipe.Group.UniqueId); _recipeRepository.ItemGroups.Add(group); } _recipeRepository.AssignedUserImages(recipe); if (group != null) { group.Items.Add(recipe); } } }
protected async override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { if (!App.Recipes.IsLoaded) { await App.Recipes.LoadLocalDataAsync(); } if (NavigationContext.QueryString.ContainsKey("groupName")) { string groupName = NavigationContext.QueryString["groupName"]; group = App.Recipes.FindGroupByName(groupName); pivot.DataContext = group; SetView(); } else { string UniqueId = NavigationContext.QueryString["ID"]; group = App.Recipes.FindGroup(UniqueId); pivot.DataContext = group; SetView(); } SetPinBar(); //Update main tile with recently visited group Features.Tile.UpdateMainTile(group); base.OnNavigatedTo(e); }
public RecipeDataItem(String uniqueId, String title, String shortTitle, String imagePath, int preptime, String directions, ObservableCollection<string> ingredients, RecipeDataGroup group) : base(uniqueId, title, shortTitle, imagePath) { _preptime = preptime; _directions = directions; _ingredients = ingredients; _group = group; _userImages = new ObservableCollection<string>(); }
public static void SetGroupTile(RecipeDataGroup group, string navDataSource) { List <Uri> list = new List <Uri>(); foreach (var recipe in group.Items) { list.Add(new Uri(recipe.ImagePath.LocalPath, UriKind.Relative)); } CycleTileData tileData = new CycleTileData() { Title = group.Title, SmallBackgroundImage = new Uri(group.GetImageUri(), UriKind.RelativeOrAbsolute), CycleImages = list }; ShellTile.Create(new Uri(navDataSource, UriKind.Relative), tileData, true); }
public RecipeDataGroup CreateRecipeGroup(JsonObject obj) { RecipeDataGroup group = new RecipeDataGroup(); foreach (var key in obj.Keys) { IJsonValue val; if (!obj.TryGetValue(key, out val)) { continue; } switch (key) { case "key": group.UniqueId = val.GetString(); break; case "title": group.Title = val.GetString(); break; case "shortTitle": group.ShortTitle = val.GetString(); break; case "description": group.Description = val.GetString(); break; case "backgroundImage": group.SetImage(val.GetString()); break; case "groupImage": group.SetGroupImage(val.GetString()); break; } } RecipeRepository.AllGroups.Add(group); return(group); }
public static void UpdateMainTile(RecipeDataGroup group) { //Get application's main tile var mainTile = ShellTile.ActiveTiles.FirstOrDefault(); if (null != mainTile) { IconicTileData tileData = new IconicTileData() { Count = group.RecipesCount, BackgroundColor = Color.FromArgb(255, 195, 61, 39), Title = "Contoso Cookbook", IconImage = new Uri("/Assets/MediumLogo.png", UriKind.RelativeOrAbsolute), SmallIconImage = new Uri("/Assets/SmallLogo.png", UriKind.RelativeOrAbsolute), WideContent1 = "Recent activity:", WideContent2 = "Browsed " + group.Title + " group", WideContent3 = "which contains " + group.RecipesCount + " recipes" }; mainTile.Update(tileData); } }
// Carga la colección de recetas public void LoadRecipes() { IEnumerable <RecipeDataItem> recipes = new ObservableCollection <RecipeDataItem>((this.LocalDataService.Load <RecipeDataItem>("Data\\Recipes.txt").ToList())); List <string> IDs = new List <string>(); RecipeDataGroup group = null; foreach (var recipe in recipes) { if (!IDs.Contains(recipe.Group.UniqueId)) { group = recipe.Group; group.Items = new ObservableCollection <RecipeDataItem>(); IDs.Add(recipe.Group.UniqueId); _recipeRepository.ItemGroups.Add(group); } _recipeRepository.AssignedUserImages(recipe); group.Items.Add(recipe); } }
public static RecipeDataGroup CreateRecipeGroup(JsonObject obj) { RecipeDataGroup group = new RecipeDataGroup(); foreach (var key in obj.Keys) { IJsonValue val; if (!obj.TryGetValue(key, out val)) continue; switch (key) { case "key": group.UniqueId = val.GetString(); break; case "title": group.Title = val.GetString(); break; case "shortTitle": group.ShortTitle = val.GetString(); break; case "description": group.Description = val.GetString(); break; case "backgroundImage": group.SetImage(val.GetString()); break; case "groupImage": group.SetGroupImage(val.GetString()); break; } } RecipeRepository.AllGroups.Add(group); return group; }
public void NavigateToGroupDetailPage(RecipeDataGroup recipeDataGroup) { _selectedRecipeDataGroup = recipeDataGroup; (App.Current.RootVisual as PhoneApplicationFrame).Navigated += NavigateToGroupDetailPageNavigated; App.RootFrame.Navigate(new Uri("/View/GroupDetailPage.xaml", UriKind.Relative)); }
public override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); RecipeGroup = e.Parameter as RecipeDataGroup; }
public void RecipeGroupSelected(string parameter) { _recipeDataGroup = _recipeRepository.ItemGroups.FirstOrDefault(r => r.UniqueId.Equals(parameter)); _navigationService.NavigateTo<GroupDetailView>(_recipeDataGroup); }