Beispiel #1
0
        private async void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            List <Topping> Toppings = new List <Topping>();

            foreach (CheckBox topping in this.Toppings)
            {
                if ((bool)topping.IsChecked)
                {
                    Toppings.Add(new Topping(topping.Content.ToString(), float.Parse(topping.Tag.ToString()), 1));
                }
            }

            Pizza pizza = new Pizza(globalProperties.SelectedPizzaName, (cbxSize.SelectedItem as ComboBoxItem).Content.ToString(),
                                    (cbxDough.SelectedItem as ComboBoxItem).Content.ToString(), (cbxSauce.SelectedItem as ComboBoxItem).Content.ToString(),
                                    (cbxCheese.SelectedItem as ComboBoxItem).Content.ToString(), Toppings);

            var dlg = new ConfirmItemDialog(pizza.PricedString());

            MainPage.ReplaceDialog(dlg, sender);

            try
            {
                var result = await dlg.ShowAsync();

                if (result == ContentDialogResult.Primary)
                {
                    Cart.Items.Add(pizza);
                    ContentFrame.Navigate(typeof(PizzaPage));
                }
            }
            catch (Exception) { /*The dialog didn't open, probably because another dialog is already open.*/ }
        }
        private async void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            List <string> Sauces = new List <string>();
            int           Pieces = Convert.ToInt32(
                (cbxPieces.SelectedItem as ComboBoxItem).Tag.ToString());

            foreach (CheckBox sauce in this.Sauces)
            {
                if ((bool)sauce.IsChecked)
                {
                    Sauces.Add(sauce.Content.ToString());
                }
            }

            if (Sauces.Count == 0)
            {
                await new MessageDialog("Please select at least one sauce.", "Unable to place item").ShowAsync();
                return;
            }
            else if (Pieces == 20 && Sauces.Count == 1)
            {
                await new MessageDialog("Please select at least two sauce for 20 Chicken Bites.", "Unable to place item").ShowAsync();
                return;
            }

            ChickenBite bites = new ChickenBite(Pieces, Sauces);

            var dlg = new ConfirmItemDialog(bites.PricedString());

            MainPage.ReplaceDialog(dlg, sender);

            try
            {
                var result = await dlg.ShowAsync();

                if (result == ContentDialogResult.Primary)
                {
                    Cart.Items.Add(bites);
                    ContentFrame.Navigate(typeof(ChickenBitesPage));
                }
            }
            catch (Exception) { /*The dialog didn't open, probably because another dialog is already open.*/ }
        }