/// <summary> /// Sets the selected dough as the dough and its price of the pizza. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Dough_SelectionChanged(object sender, SelectionChangedEventArgs e) { //consider allowing the non-custom pizzas to have their dough and such changed. A foreach loop with a breaak for the ingridents list checking against the different doughs should work if (currentPizza != null) { int index = Dough.SelectedIndex; string text = Dough.SelectedValue.ToString(); dough.TryGetValue(text, out float value); currentPizza.SetDough(text, value); } }
/// <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); } }