コード例 #1
0
        /// <summary>
        /// Sets the selected cheese as the cheese and its price of the pizza.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Cheese_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index = Cheese.SelectedIndex;

            if (currentPizza != null && index != 0)
            {
                string text = Cheese.SelectedValue.ToString();
                cheese.TryGetValue(text, out float value);
                currentPizza.SetCheese(text, value);
            }
            else if (currentPizza != null && index != 0)
            {
                //find the cheese and remove it, same should be done with the tomato_Sauce
                string cheese  = currentPizza.GetCheese;
                bool   removed = currentPizza.RemoveIngredient(cheese);
            }
        }
コード例 #2
0
        /// <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);
            }
        }