예제 #1
0
        /// <summary>
        /// Handles what happens when a combo button is clicked.
        /// </summary>
        /// <param name="sender">The object being clicked.</param>
        /// <param name="args">The RoutedEventArgs.</param>
        private void ComboClick(object sender, RoutedEventArgs e)
        {
            Entree entree     = new SteakosaurusBurger();
            string entreeName = (string)((Button)sender).Tag;

            switch (entreeName)
            {
            case "Brontowurst":
                entree = new Brontowurst();
                break;

            case "Steakosaurus":
                entree = new SteakosaurusBurger();
                break;

            case "T-Rex":
                entree = new TRexKingBurger();
                break;

            case "Prehistoric":
                entree = new PrehistoricPBJ();
                break;

            case "Pterodactyl":
                entree = new PterodactylWings();
                break;

            case "Veloci-Wrap":
                entree = new VelociWrap();
                break;

            case "Dino-Nuggets":
                entree = new DinoNuggets();
                break;
            }

            if (DataContext is Order order)
            {
                order.Add(new CretaceousCombo(entree));
                CollectionViewSource.GetDefaultView(order.Items).MoveCurrentToLast();

                CustomizeCombo page = new CustomizeCombo();
                page.SetCombo((CretaceousCombo)order.Items.Last <IOrderItem>());
                NavigationService.Navigate(page);
            }
        }
예제 #2
0
        /// <summary>
        /// Determines what happens when the selected object is changed.
        /// </summary>
        /// <param name="sender">The ListBox that is being updated.</param>
        /// <param name="e">The SelectionChagedEventArgs of the selection change.</param>
        public void SelectionChange(object sender, SelectionChangedEventArgs e)
        {
            ListBox buff = sender as ListBox;

            if (selectedItem != null)
            {
                if (uxListBox != buff)
                {
                    uxListBox.SelectedItem = null;
                }
            }

            uxListBox = buff;

            if (e.AddedItems.Count > 0)
            {
                selectedItem = e.AddedItems[0] as IOrderItem;
            }

            if (selectedItem != lastSelectedItem)
            {
                if (selectedItem is Entree entree)
                {
                    //Console.WriteLine("Selected an entree");
                    CustomizeEntree page = new CustomizeEntree();
                    page.InitPage(entree, new MenuCategorySelection());
                    page.SetEditedEntree(entree);
                    MainWindow window = Window.GetWindow(this) as MainWindow;
                    window.GetCurrentPage().NavigationService.Navigate(page);
                }
                else if (selectedItem is Side side)
                {
                    //Console.WriteLine("Selected a side");
                    SideSelection page = new SideSelection();
                    page.SetEditedSide(side, new MenuCategorySelection());
                    MainWindow window = Window.GetWindow(this) as MainWindow;
                    window.GetCurrentPage().NavigationService.Navigate(page);
                }
                else if (selectedItem is Drink drink)
                {
                    //Console.WriteLine("Selected a drink");
                    DrinkSelection page = new DrinkSelection();
                    page.SetReturnPage(new MenuCategorySelection());
                    page.SetEditedDrink(drink);
                    MainWindow window = Window.GetWindow(this) as MainWindow;
                    window.GetCurrentPage().NavigationService.Navigate(page);
                }
                else if (selectedItem is CretaceousCombo combo)
                {
                    //Console.WriteLine("Selected a combo");
                    CustomizeCombo page = new CustomizeCombo();
                    page.SetReturnPage(new MenuCategorySelection());
                    Console.WriteLine("Combo size: " + combo.Size);
                    page.SetCombo(combo);
                    MainWindow window = Window.GetWindow(this) as MainWindow;
                    window.GetCurrentPage().NavigationService.Navigate(page);
                }
            }

            lastSelectedItem = selectedItem;
        }