Exemple #1
0
        /// <summary>
        /// Adds the drink to the order or the combo, as appropriate.
        /// </summary>
        /// <param name="sender">The button that was pressed.</param>
        /// <param name="e">Any arguments about the event.</param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (sender is Button button && DataContext is Order order)
            {
                Drink drink;
                if (button.Name == App.CreateValidIdString(new Sodasaurus().ToString()))
                {
                    // Add Sodasaurus to order
                    drink = new Sodasaurus();
                    ChangeToSodasaurusButtons();
                }
                else if (button.Name == App.CreateValidIdString(new JurassicJava().ToString()))
                {
                    // Add JurassicJava to order
                    drink = new JurassicJava();
                    ChangeToJurassicJavaButtons();
                }
                else if (button.Name == App.CreateValidIdString(new Tyrannotea().ToString()))
                {
                    // Add Tyrannotea to order
                    drink = new Tyrannotea();
                    ChangeToTyrannoteaButtons();
                }
                else    // Water
                {
                    // Add Water to order
                    drink = new Water();
                    ChangeToWaterButtons();
                }

                // Change side to correct size after adding item to order
                RadioButton mediumRadio = SizeGrid.Children[1] as RadioButton;
                RadioButton largeRadio  = SizeGrid.Children[2] as RadioButton;

                if ((bool)mediumRadio.IsChecked)
                {
                    drink.Size = Menu.Size.Medium;
                }
                else if ((bool)largeRadio.IsChecked)
                {
                    drink.Size = Menu.Size.Large;
                }

                if (shouldChangeCombo &&
                    CollectionViewSource.GetDefaultView(order.Items).CurrentItem is CretaceousCombo combo)
                {
                    combo.Drink = drink;
                }
                else
                {
                    // Add the drink to the order
                    order.Items.Add(drink);

                    // Focus on the new drink
                    CollectionViewSource.GetDefaultView(order.Items).MoveCurrentToLast();
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// The constructor for this page. Adds a button for each drink and the radio buttons for the sizes.
        /// </summary>
        public DrinkSelection()
        {
            InitializeComponent();

            List <Menu.Size> sizes = new List <Menu.Size>
            {
                Menu.Size.Small,
                Menu.Size.Medium,
                Menu.Size.Large
            };

            // Adds buttons for each drink to the menu programatically.
            Menu.Menu menu = new Menu.Menu();
            DrinkGrid.RowDefinitions.Add(new RowDefinition());
            int x = 0;

            foreach (Drink drink in menu.AvailableDrinks)
            {
                Button button = new Button
                {
                    Content = new TextBlock
                    {
                        Text          = App.CorrectDrinkAndSideNames(drink.ToString()),
                        TextWrapping  = TextWrapping.Wrap,
                        TextAlignment = TextAlignment.Center
                    },
                    Name = App.CreateValidIdString(drink.ToString())
                };

                DrinkGrid.ColumnDefinitions.Add(new ColumnDefinition());
                button.SetValue(Grid.ColumnProperty, x++);
                button.SetValue(Grid.RowProperty, 0);

                button.Click += new RoutedEventHandler(Button_Click);
                DrinkGrid.Children.Add(button);
            }

            SizeGrid.RowDefinitions.Add(new RowDefinition());
            x = 0;

            foreach (Menu.Size size in sizes)
            {
                RadioButton radioButton = new RadioButton
                {
                    Content   = size.ToString(),
                    Name      = size.ToString(),
                    IsChecked = (size.ToString() == "Small")
                };

                SizeGrid.ColumnDefinitions.Add(new ColumnDefinition());
                radioButton.SetValue(Grid.ColumnProperty, x++);
                radioButton.SetValue(Grid.RowProperty, 0);

                radioButton.Checked += RadioButton_Checked;

                SizeGrid.Children.Add(radioButton);
            }
        }
Exemple #3
0
        // Performs any actions necessary when an entree button is clicked.
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (sender is Button button && DataContext is Order order)
            {
                if (button.Name == App.CreateValidIdString(new Brontowurst().ToString()))
                {
                    order.Items.Add(new Brontowurst());
                    CollectionViewSource.GetDefaultView(order.Items).MoveCurrentToLast();
                }
                else if (button.Name == App.CreateValidIdString(new DinoNuggets().ToString()))
                {
                    order.Items.Add(new DinoNuggets());
                    CollectionViewSource.GetDefaultView(order.Items).MoveCurrentToLast();
                }
                else if (button.Name == App.CreateValidIdString(new PrehistoricPBJ().ToString()))
                {
                    order.Items.Add(new PrehistoricPBJ());
                    CollectionViewSource.GetDefaultView(order.Items).MoveCurrentToLast();
                }
                else if (button.Name == App.CreateValidIdString(new PterodactylWings().ToString()))
                {
                    order.Items.Add(new PterodactylWings());
                    CollectionViewSource.GetDefaultView(order.Items).MoveCurrentToLast();
                }
                else if (button.Name == App.CreateValidIdString(new SteakosaurusBurger().ToString()))
                {
                    order.Items.Add(new SteakosaurusBurger());
                    CollectionViewSource.GetDefaultView(order.Items).MoveCurrentToLast();
                }
                else if (button.Name == App.CreateValidIdString(new TRexKingBurger().ToString()))
                {
                    order.Items.Add(new TRexKingBurger());
                    CollectionViewSource.GetDefaultView(order.Items).MoveCurrentToLast();
                }
                else if (button.Name == App.CreateValidIdString(new VelociWrap().ToString()))
                {
                    order.Items.Add(new VelociWrap());
                    CollectionViewSource.GetDefaultView(order.Items).MoveCurrentToLast();
                }
                else
                {
                    throw new InvalidOperationException("Cannot add any other entree with the buttons on this screen.");
                }

                // Go to customize page if not Pterodactyl Wings.
                if (CollectionViewSource.GetDefaultView(order.Items).CurrentItem is PterodactylWings)
                {
                    NavigationService?.Navigate(new MenuCategorySelection());
                }
                else
                {
                    NavigationService?.Navigate(new CustomizeEntree());
                }
            }
        }
        // Performs any action required by clicking on one of the sides
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (sender is Button button && DataContext is Order order)
            {
                Side side;
                if (button.Name == App.CreateValidIdString(new Fryceritops().ToString()))
                {
                    side = new Fryceritops();
                }
                else if (button.Name == App.CreateValidIdString(new Triceritots().ToString()))
                {
                    side = new Triceritots();
                }
                else if (button.Name == App.CreateValidIdString(new MeteorMacAndCheese().ToString()))
                {
                    side = new MeteorMacAndCheese();
                }
                else    // Mezzorella Sticks
                {
                    side = new MezzorellaSticks();
                }

                // Change side to correct size after adding item to order
                RadioButton mediumRadio = SizeGrid.Children[1] as RadioButton;
                RadioButton largeRadio  = SizeGrid.Children[2] as RadioButton;

                if ((bool)mediumRadio.IsChecked)
                {
                    side.Size = Menu.Size.Medium;
                }
                else if ((bool)largeRadio.IsChecked)
                {
                    side.Size = Menu.Size.Large;
                }

                if (shouldChangeCombo &&
                    CollectionViewSource.GetDefaultView(order.Items).CurrentItem is CretaceousCombo combo)
                {
                    combo.Side = side;
                }
                else
                {
                    // Add the drink to the order
                    order.Items.Add(side);

                    // Focus on the new drink
                    CollectionViewSource.GetDefaultView(order.Items).MoveCurrentToLast();
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// The constructor for this page. Adds a button for each combo.
        /// </summary>
        public ComboSelection()
        {
            InitializeComponent();

            // Adds buttons for each combo to the menu programatically.
            Menu menu = new Menu();
            int  x    = 0;
            int  y    = 0;

            foreach (CretaceousCombo combo in menu.AvailableCombos)
            {
                TextBlock textBlock = new TextBlock
                {
                    Text          = combo.ToString(),
                    TextWrapping  = TextWrapping.WrapWithOverflow,
                    TextAlignment = TextAlignment.Center
                };

                Button button = new Button
                {
                    Content = textBlock,
                    Name    = App.CreateValidIdString(combo.Entree.ToString())
                };

                button.SetValue(Grid.ColumnProperty, x++);
                button.SetValue(Grid.RowProperty, y);

                if (x >= 3)
                {
                    y++;
                    x = 0;
                }

                button.Click += new RoutedEventHandler(Button_Click);
                ComboGrid.Children.Add(button);
            }
        }
        // Preforms any actions necessary when a flavor button is clicked
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Adds buttons for each flavor to the menu programatically.
            List <SodasaurusFlavor> sodasaurusFlavors = new List <SodasaurusFlavor>
            {
                SodasaurusFlavor.Cola,
                SodasaurusFlavor.Orange,
                SodasaurusFlavor.Vanilla,
                SodasaurusFlavor.Chocolate,
                SodasaurusFlavor.RootBeer,
                SodasaurusFlavor.Cherry,
                SodasaurusFlavor.Lime,
                SodasaurusFlavor.Grape
            };

            if (sender is Button button && DataContext is Order order)
            {
                if (CollectionViewSource.GetDefaultView(order.Items).CurrentItem is Sodasaurus soda)
                {
                    if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Cola.ToString()))
                    {
                        // Swaps the flavor: If it already exists then the operation removes it, otherwise,
                        // the operation adds it.
                        soda.Flavor ^= SodasaurusFlavor.Cola;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Orange.ToString()))
                    {
                        soda.Flavor ^= SodasaurusFlavor.Orange;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Vanilla.ToString()))
                    {
                        soda.Flavor ^= SodasaurusFlavor.Vanilla;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Chocolate.ToString()))
                    {
                        soda.Flavor ^= SodasaurusFlavor.Chocolate;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.RootBeer.ToString()))
                    {
                        soda.Flavor ^= SodasaurusFlavor.RootBeer;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Cherry.ToString()))
                    {
                        soda.Flavor ^= SodasaurusFlavor.Cherry;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Lime.ToString()))
                    {
                        soda.Flavor ^= SodasaurusFlavor.Lime;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Grape.ToString()))
                    {
                        soda.Flavor ^= SodasaurusFlavor.Grape;
                    }
                }
                else if (CollectionViewSource.GetDefaultView(order.Items).CurrentItem is CretaceousCombo combo &&
                         combo.Drink is Sodasaurus drink)
                {
                    if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Cola.ToString()))
                    {
                        // Swaps the flavor: If it already exists then the operation removes it, otherwise,
                        // the operation adds it.
                        drink.Flavor ^= SodasaurusFlavor.Cola;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Orange.ToString()))
                    {
                        drink.Flavor ^= SodasaurusFlavor.Orange;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Vanilla.ToString()))
                    {
                        drink.Flavor ^= SodasaurusFlavor.Vanilla;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Chocolate.ToString()))
                    {
                        drink.Flavor ^= SodasaurusFlavor.Chocolate;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.RootBeer.ToString()))
                    {
                        drink.Flavor ^= SodasaurusFlavor.RootBeer;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Cherry.ToString()))
                    {
                        drink.Flavor ^= SodasaurusFlavor.Cherry;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Lime.ToString()))
                    {
                        drink.Flavor ^= SodasaurusFlavor.Lime;
                    }
                    else if (button.Name == App.CreateValidIdString(SodasaurusFlavor.Grape.ToString()))
                    {
                        drink.Flavor ^= SodasaurusFlavor.Grape;
                    }
                }
            }

            UpdateFlavorButtons();
        }
        // Adds buttons for each flavor to the menu programatically.
        private void UpdateFlavorButtons()
        {
            while (FlavorGrid.Children.Count > 0)
            {
                FlavorGrid.Children.RemoveAt(0);
            }

            List <SodasaurusFlavor> sodasaurusFlavors = new List <SodasaurusFlavor>
            {
                SodasaurusFlavor.Cola,
                SodasaurusFlavor.Orange,
                SodasaurusFlavor.Vanilla,
                SodasaurusFlavor.Chocolate,
                SodasaurusFlavor.RootBeer,
                SodasaurusFlavor.Cherry,
                SodasaurusFlavor.Lime,
                SodasaurusFlavor.Grape
            };
            int x = 0;
            int y = 0;

            foreach (SodasaurusFlavor flavor in sodasaurusFlavors)
            {
                TextBlock textBlock = new TextBlock
                {
                    Text          = flavor.ToString(),
                    TextWrapping  = TextWrapping.WrapWithOverflow,
                    TextAlignment = TextAlignment.Center
                };

                Button button = new Button
                {
                    Content = textBlock,
                    Name    = App.CreateValidIdString(flavor.ToString())
                };

                button.SetValue(Grid.ColumnProperty, x++);
                button.SetValue(Grid.RowProperty, y);

                if (x >= 3)
                {
                    y++;
                    x = 0;
                }

                if (DataContext is Order order)
                {
                    if (CollectionViewSource.GetDefaultView(order.Items).CurrentItem is Sodasaurus soda &&
                        soda.Flavor.HasFlag(flavor))
                    {
                        button.Background = Brushes.LightGreen;
                    }
                    else if (CollectionViewSource.GetDefaultView(order.Items).CurrentItem is CretaceousCombo combo &&
                             combo.Drink is Sodasaurus drink && drink.Flavor.HasFlag(flavor))
                    {
                        button.Background = Brushes.LightGreen;
                    }
                }

                button.Click += new RoutedEventHandler(Button_Click);
                FlavorGrid.Children.Add(button);
            }