/// <summary> /// Sets the selected tomato sauce as the tomato sauce and its price of the pizza. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Tomato_Sauce_SelectionChanged(object sender, SelectionChangedEventArgs e) { int index = Tomato_Sauce.SelectedIndex; if (currentPizza != null) { string text = Tomato_Sauce.SelectedValue.ToString();//Items[index].ToString().Split(':')[1].Trim(); tomatoSauce.TryGetValue(text, out float value); currentPizza.SetTomatoSauce(text, value); } else if (currentPizza != null && index != 0) { string tomatoSauce = currentPizza.GetTomatoSauce; bool removed = currentPizza.RemoveIngredient(tomatoSauce); } }
/// <summary> /// Sets the current pizza out from the chosen pizza on the pizza combobox. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PizzaType_SelectionChanged(object sender, SelectionChangedEventArgs e) { ResetIndexes(); sizePricePizza.TryGetValue(sizePizza, out float value); int index = PizzaType.SelectedIndex; if (index == 0) { currentPizza = null; PriceBox.Text = "0 kr"; IngredientsBox.Text = ""; } else { //prePizzaList[index-1]; //minus 1 because there is one more option in the combobox, "None", than there are pizzas. currentPizza = new PizzaPolymorth(PriceBox, IngredientsBox, prePizzaList[index - 1].GetName, prePizzaList[index - 1].GetNumber, prePizzaList[index - 1].GetIngredientsDictionary); //prevents overwriting the "base" pizzas dough.TryGetValue(prePizzaList[index - 1].GetDough, out float valuePrice); currentPizza.SetBasePrice = value; currentPizza.SetDough(prePizzaList[index - 1].GetDough, valuePrice); currentPizza.SetCheese(prePizzaList[index - 1].GetCheese, valuePrice); currentPizza.SetTomatoSauce(prePizzaList[index - 1].GetTomatoSauce, valuePrice); } }