public void LearnRecipe(Recipe recipe) { if (!Recipes.Any(r => r.ID == recipe.ID)) { Recipes.Add(recipe); } }
// Gets all recipes from the database and adds them to the observable collection private void Init() { var enumarator = App.RecipeDbcontroller.GetRecipe(); if (enumarator == null) { App.RecipeDbcontroller.SaveRecipe(new Recipe { RecipeName = "Moussaka", Serves = 6, PrepTime = "30", CookTime = "2 Hours", MealType = "Dinner" }); enumarator = App.RecipeDbcontroller.GetRecipe(); } foreach (Recipe r in enumarator) { //cleans database of all empty records if (r.RecipeName == null || r.CookTime == null) { App.RecipeDbcontroller.DeleteRecipe(r.RecipeID); } else { Recipes.Add(r); } } }
private async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Recipes.Clear(); var items = await DataStore.GetItemsAsync(); foreach (var item in items) { Recipes.Add(item); Console.WriteLine(item.Title); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
async Task ExecuteLoadRecipesCommand() { if (IsBusy) { return; } IsBusy = true; try { Recipes.Clear(); var recipes = await DataStore.GetAllRecipesAsync(true); foreach (var recipe in recipes) { Recipes.Add(recipe); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
/// Handles the response of the GetRecipeMetaData call to ChilliConnect. /// Loads the returned objects to a list of Recipe definitions and notifies listeners /// private void RenderRecipeList(GetMetadataDefinitionsResponse response) { Recipes.Clear(); foreach (MetadataDefinition metadataItem in response.Items) { var recipeName = metadataItem.Name; var recipeKey = metadataItem.Key; var itemCustomData = metadataItem.CustomData; var minLvlRange = itemCustomData.AsDictionary().GetInt("AttributesMin"); var maxLvlRange = itemCustomData.AsDictionary().GetInt("AttributesMax"); var coinCost = itemCustomData.AsDictionary().GetInt("Cost"); var recipe = new Recipe(); recipe.RecipeName = recipeName; recipe.RecipeKey = recipeKey; recipe.LevelRangeMin = minLvlRange; recipe.LevelRangeMax = maxLvlRange; recipe.CoinCost = coinCost; Recipes.Add(recipe); } ; OnRecipeListPopulate(Recipes); }
public RecipesVM() { this.Recipes = new ObservableCollection <SearchResultRecipeVM>(); #if DEBUG Recipe newRecipe = new Recipe("The kale dish", ""); newRecipe.CookTime = "25 min"; newRecipe.AddIngredient(new FoodItem("Kale", "")); newRecipe.AddIngredient(new FoodItem("Potatoes", "")); newRecipe.AddIngredient(new FoodItem("Bacon", "")); Recipes.Add(new SearchResultRecipeVM(newRecipe)); newRecipe = new Recipe("Lamb Biryani", ""); newRecipe.CookTime = "45 min"; newRecipe.AddIngredient(new FoodItem("Lamb", "")); newRecipe.AddIngredient(new FoodItem("Potatoes", "")); newRecipe.AddIngredient(new FoodItem("Peas", "")); newRecipe.AddIngredient(new FoodItem("Spices", "")); newRecipe.AddIngredient(new FoodItem("Rice", "")); Recipes.Add(new SearchResultRecipeVM(newRecipe)); newRecipe = new Recipe("Mushroom risotti", ""); newRecipe.CookTime = "45 min"; newRecipe.AddIngredient(new FoodItem("Risotto rice", "")); newRecipe.AddIngredient(new FoodItem("Parmesan", "")); newRecipe.AddIngredient(new FoodItem("Spinach", "")); Recipes.Add(new SearchResultRecipeVM(newRecipe)); #endif }
private void SaveRecipeUpdate(RecipeViewModel x) { EditingRecipe = null; // new food item if (x.Id == null) { x.Id = Guid.NewGuid().ToString(); Recipes.Add(x); } else { // Update existing food item var meal = Recipes.FirstOrDefault(y => y.Id == x.Id); if (meal == null) { Recipes.Add(x); } else { meal.Clone(x); // We save when we change the collection, so this is the only place we need to call save SaveRecipes(); } } }
public void getPatientHistory() { try { if (TypeSelected == ShowData.מידע_עדכני) { Recipes.Clear(); foreach (Recipe item in AddDoctorVisitM.getPatientHistory(Patient.PatientId, true)) { Recipes.Add(item); } } if (TypeSelected == ShowData.כל_המידע) { Recipes.Clear(); foreach (Recipe item in AddDoctorVisitM.getPatientHistory(Patient.PatientId)) { Recipes.Add(item); } } } catch (Exception e) { (App.Current as App).navigation.MainWindows.comments.Text = e.Message.ToString(); } }
public void ExecuteLoadRecipesCollection() { List <Guid> gui = new List <Guid>(); IEnumerable <Recipe> recipes = new List <Recipe>(); gui = App.SessionUser.RecipesUsed; List <Guid> guiTemp = new List <Guid>(gui); foreach (Guid i in guiTemp) { if (App.LiteDB.GetRecipesByRecipeID(i) == null) { gui.Remove(i); } } App.SessionUser.RecipesUsed = gui; App.LiteDB.UpdateUser(App.SessionUser); recipes = App.LiteDB.GetRecipesBySessionCollection(); for (int i = 0; i < recipes.Count(); i++) { Recipes.Add(recipes.ElementAt(i)); } }
public int Combine() { var runningTotal = 0; foreach (var elf in AllElves) { runningTotal += ElfDict[elf]; } var ret = 0; foreach (var i in runningTotal.ToString().AsNumbers()) { Recipes.Add(i); ret++; TotalRecipes++; } foreach (var e in AllElves) { var currRecipe = ElfDict[e]; var distanceToMove = currRecipe + 1; var newRecipeIndex = moveForward(distanceToMove, e); e.CurrIndex = newRecipeIndex; ElfDict[e] = Recipes[e.CurrIndex]; } return(ret); }
void CreateRadomRecipes() { Recipes.Clear(); foreach (var name in names) { var NewRecipe = new Recipe(name); var value = new Random().Next(3); string img = value == 0 ? "default.jpg" : $"{value}.jpg"; NewRecipe.Thumbnail = img; Recipes.Add(NewRecipe); RecipeDetailsController.CreateRandomDetails(_storageService, NewRecipe); _storageService.Delete(NewRecipe.ID); FileStream thumbnail = File.OpenRead($"Resources/Images/Thumbnails/{NewRecipe.Thumbnail}"); thumbnail.Position = 0; _storageService.UploadPicture(thumbnail, NewRecipe.ID, NewRecipe.Thumbnail); thumbnail.Close(); } Stream recipe = new MemoryStream(); XmlSerializer serializer = new XmlSerializer(typeof(List <Recipe>)); serializer.Serialize(recipe, Recipes); recipe.Position = 0; _storageService.UploadRecipe(recipe); recipe.Dispose(); }
private async Task LoadRecipes(String stringRequest) { try { AI.IsRunning = true; var request = await App.http.GetAsync(stringRequest, Source.Token); if (request.IsSuccessStatusCode) { var apiRequest = JsonConvert.DeserializeObject <Request>(await request.Content.ReadAsStringAsync()); foreach (var item in apiRequest.hits) { Recipes.Add(item.recipe); } } else { await DisplayAlert("API error", $"Code: {request.StatusCode}\nMessage: {JsonConvert.DeserializeObject(await request.Content.ReadAsStringAsync())}", "Ok"); } } catch (Exception ex) { } //ActivityIndicator AI.IsRunning = false; }
public async Task ExecutePerformSearchCommand(string search, Category category = null, string sorter = null) { if (IsBusy) { return; } IsBusy = true; try { Recipes.Clear(); IEnumerable <Recipe> recipes; if (category != null) { recipes = await DataStore.GetItemsByTagByCategoryAsync(search, category.CategoryId, sorter); } else { recipes = await DataStore.GetItemsByTagsAsync(search, sorter); } foreach (var recipe in recipes) { Recipes.Add(recipe); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private void MakeRecipes() { ObservableCollection <IMaterial> materialsPasta = new ObservableCollection <IMaterial> { new Material { ID = 0, Name = "パスタ" }, new Material { ID = 1, Name = "トマト" } }; ObservableCollection <IMaterial> materialRisotto = new ObservableCollection <IMaterial> { new Material { ID = 2, Name = "お米" }, new Material { ID = 3, Name = "ベーコン" } }; Recipe recipe = new Recipe { ID = 1, Name = "パスタ", Materials = materialsPasta }; Recipe recipe1 = new Recipe { ID = 2, Name = "リゾット", Materials = materialRisotto }; Recipes.Add(recipe); Recipes.Add(recipe1); }
private Task CreateSpecificType(CookBookFile file, CancellationToken token) { switch (file.Extension) { case PetitTournantFacade.RecipeExtension: { Recipe r = new Recipe(file, token); Recipes.Add(file.FullName, r); return(r.Initialization); } case PetitTournantFacade.KnowledgeExtension: { Knowledge k = new Knowledge(file, token); Knowledge.Add(file.FullName, k); return(k.Initialization); } case MetaExtension: { if (this.MF != null) { throw new Exception("More then one metafile is present."); } this.MF = new MetaFile(file, token); return(this.MF.Initialization); } default: { AllOtherFiles.Add(file.FullName, file); return(null); } } }
private async Task GetRecipesAsync() { if (IsBusy) { return; } IsBusy = true; try { string jsonRecipes = await Client.GetStringAsync("http://www.croustipeze.com/ressources/recipesdata.json"); Recipe[] recipes = JsonConvert.DeserializeObject <Recipe[]>(jsonRecipes, Converter.Settings); Recipes.Clear(); foreach (var recipe in recipes) { Recipes.Add(recipe); } } catch (Exception ex) { Debug.WriteLine($"Unable to get recipes: {ex.Message}"); await Application.Current.MainPage.DisplayAlert("Error!", ex.Message, "OK"); } finally { IsBusy = false; } }
public void ReLoadDefinitions() { Definitions.Where(n => !Recipes.Any(o => o.RecipeID == n.RecipeID)).ToList().ForEach(x => { Recipes.Add(x); }); }
public void AddRecipe(Recipe recipe) { if (Recipes.Contains(recipe)) { return; } Recipes.Add(recipe); }
public void Initialize() { XElement xml = XElement.Parse(File.ReadAllText(@"scripts\recipes.xml")); XElement ex = xml.Element("list"); if (ex != null) { foreach (XElement m in ex.Elements()) { if (m.Name != "recipe") { continue; } L2Recipe rec = new L2Recipe { RecipeId = int.Parse(m.Attribute("id").Value), Mk = m.Attribute("mk").Value, Level = int.Parse(m.Attribute("level").Value), ItemId = int.Parse(m.Attribute("itemId").Value), Iscommonrecipe = int.Parse(m.Attribute("common").Value) }; foreach (XElement stp in m.Elements()) { switch (stp.Name.LocalName) { case "material": { rec.MpConsume = int.Parse(stp.Attribute("mp").Value); rec.Materials = stp.Elements().Where(items => items.Name == "item").Select(items => new RecipeItemEntry(int.Parse(items.Attribute("id").Value), int.Parse(items.Attribute("count").Value))).ToList(); } break; case "product": { rec.SuccessRate = int.Parse(stp.Attribute("rate").Value); rec.Products = stp.Elements().Where(items => items.Name == "item").Select(items => new RecipeItemEntry(int.Parse(items.Attribute("id").Value), int.Parse(items.Attribute("count").Value))).ToList(); } break; case "fee": { rec.NpcFee = stp.Elements().Where(items => items.Name == "item").Select(items => new RecipeItemEntry(int.Parse(items.Attribute("id").Value), int.Parse(items.Attribute("count").Value))).ToList(); } break; } } Recipes.Add(rec.RecipeId, rec); } } Log.Info($"RecipeTable: loaded {Recipes.Count} recipes."); }
private void AddRecipe(Recipe recipe) { if (!Recipes.ContainsKey(recipe.SpellId)) { Recipes.Add(recipe.SpellId, recipe); recipe.InitIngredients(); recipe.InitTools(); } }
private async Task ExecuteInit() { List <Models.Recipe.Recipe> entries = await RecipeRepository.GetRecipes(); Recipes.Clear(); entries.ForEach(r => Recipes.Add(r)); Initialized = true; }
private void BindRecipes() { Recipes.Clear(); foreach (var item in _recipeService.Recipes(Query)) { Recipes.Add(item); } }
private void AfterNewRecipeAdded(NewRecipeAddedEventArgs obj) { Recipe newRecipe = obj.NewRecipe; if (Recipes != null && !Recipes.Contains(newRecipe)) { Recipes.Add(newRecipe); } }
private void FillRecipeNames() { _recipeList = _ctxDB.Recipes.ToList().FindAll(x => x.UserId == UserId); Recipes.Clear(); for (int i = 0; i < _recipeList.Count(); i++) { Recipes.Add(_recipeList[i].RecipeName.ToString()); } }
public void AddRecipe(Recipe recipe) { if (Recipes.ContainsKey(recipe.ID)) { return; } Recipes.Add(recipe.ID, recipe); recipe.InitIngredients(); recipe.InitTools(); }
public void ExecuteLoadRecipesUser() { List <Recipe> recipes = new List <Recipe>(); recipes = App.LiteDB.GetRecipesBySessionID(); foreach (Recipe r in recipes) { Recipes.Add(r); } }
public void ExecuteLoadRecipesSearch(List <string> ingredientNames) { IEnumerable <Recipe> recipes = new List <Recipe>(); recipes = App.LiteDB.GetRecipesByIngredientName(ingredientNames); foreach (Recipe r in recipes) { Recipes.Add(r); } }
public void AddRecipe(int score) { Recipes.Add(score); TotalRecipes++; var elf = new Elf(score); elf.CurrIndex = Recipes.Count - 1; ElfDict[elf] = score; AllElves.Add(elf); }
public void LoadRecipes() { var @params = SelectedIngredients.Select(i => i.Id).ToList(); var recipesList = Api.WczytajPrzepisyZeSkladnikow(@params); Recipes.Clear(); foreach (var r in recipesList) { Recipes.Add(r); } }
public void AddRecipe(Recipe recipe) { if (!Recipes.Contains(recipe)) { Recipes.Add(recipe); BusinessLayer.AddRecipe(recipe); Soups = new ObservableCollection <Recipe>(Recipes.Where(r => r.Type.Name == "Leves")); MainCourses = new ObservableCollection <Recipe>(Recipes.Where(r => r.Type.Name == "Főétel")); Desserts = new ObservableCollection <Recipe>(Recipes.Where(r => r.Type.Name == "Desszert")); } }
/// <summary> /// Handles the container set slot. /// </summary> /// <param name="message">The message.</param> protected virtual void HandleContainerSetSlot(McpeContainerSetSlot message) { lock (Inventory) { if (HealthManager.IsDead) return; ItemStack itemStack = message.item.Value; if (GameMode != GameMode.Creative) { if (!VerifyItemStack(itemStack)) { Log.Error($"Kicked {Username} for inventory hacking."); Disconnect("Error #324. Please report this error."); return; } } Log.Info($"Player {Username} set inventory item on window 0x{message.windowId:X2} with slot: {message.slot} HOTBAR: {message.unknown} Item ID: {itemStack.Id} Item Count: {itemStack.Count} Meta: {itemStack.Metadata}: DatagramSequenceNumber: {message.DatagramSequenceNumber}, ReliableMessageNumber: {message.ReliableMessageNumber}, OrderingIndex: {message.OrderingIndex}"); // on all set container content, check if we have active inventory // and update that inventory. // Inventory manager makes sure other players with the same inventory open will // also get the update. if (_openInventory != null) { if (_openInventory.WindowsId == message.windowId) { if (_openInventory.Type == 4) { Recipes recipes = new Recipes(); recipes.Add(new EnchantingRecipe()); McpeCraftingData crafting = new McpeCraftingData {recipes = recipes}; SendPackage(crafting); } // block inventories of various kinds (chests, furnace, etc) _openInventory.SetSlot(this, (byte) message.slot, itemStack); return; } } switch (message.windowId) { case 0: Inventory.Slots[message.slot] = itemStack; break; case 0x79: Inventory.Slots[message.slot] = itemStack; break; case 0x78: var armorItem = itemStack.Item; switch (message.slot) { case 0: Inventory.Helmet = armorItem; break; case 1: Inventory.Chest = armorItem; break; case 2: Inventory.Leggings = armorItem; break; case 3: Inventory.Boots = armorItem; break; } McpePlayerArmorEquipment armorEquipment = McpePlayerArmorEquipment.CreateObject(); armorEquipment.entityId = EntityId; armorEquipment.helmet = new MetadataSlot(new ItemStack(Inventory.Helmet, 1)); armorEquipment.chestplate = new MetadataSlot(new ItemStack(Inventory.Chest, 1)); armorEquipment.leggings = new MetadataSlot(new ItemStack(Inventory.Leggings, 1)); armorEquipment.boots = new MetadataSlot(new ItemStack(Inventory.Boots, 1)); Level.RelayBroadcast(this, armorEquipment); break; case 0x7A: //Inventory.ItemHotbar[message.unknown] = message.slot/* + PlayerInventory.HotbarSize*/; break; } } }