/// <summary> /// Add Texas Tea /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Texas_Tea(object sender, RoutedEventArgs e) { var drinks = new TexasTea(); var screen = new CustomizedTexasTea(); AddItemAndOpenCustomizationScreen(drinks, screen); }
/// <summary> /// adds texas tea to the order /// </summary> /// <param name="sender">the texas tea</param> /// <param name="e">information associated with the button</param> void OnAddTexasTeaButtonClicked(object sender, RoutedEventArgs e) { var orderControl = this.FindAncestor <OrderControl>(); if (DataContext is Order order) { var drink = new TexasTea(); var screen = new CustomizedTexasTea(DataContext); screen.DataContext = drink; order.Add(drink); orderControl?.SwapScreen(screen); //OnItemAddButtonClicked(sender, e); //order.Add(new TexasTea()); } }
/// <summary> /// handles the event that an added item needs to be chagned /// </summary> /// <param name="sender">the listbox item being edited</param> /// <param name="e">information associated with the item sent</param> void ItemChanged(object sender, EventArgs e) { FrameworkElement screen = null; var orderControl = this.FindAncestor <OrderControl>(); if (DataContext is Order order) { if (sender is ListBox lb) { if (lb.SelectedItem is IOrderItem item) { if (item is AngryChicken) { screen = new CustomizedAngryChicken(); screen.DataContext = item; orderControl?.SwapScreen(screen); } else if (item is CowpokeChili) { screen = new CustomizedCowpokeChili(); screen.DataContext = item; orderControl?.SwapScreen(screen); } else if (item is TrailBurger) { screen = new CustomizedTrailBurger(); screen.DataContext = item; orderControl?.SwapScreen(screen); } else if (item is DakotaDoubleBurger) { screen = new CustomizedDakotaDoubleBurger(); screen.DataContext = item; orderControl?.SwapScreen(screen); } else if (item is TexasTripleBurger) { screen = new CustomizedTexasTripleBurger(); screen.DataContext = item; orderControl?.SwapScreen(screen); } else if (item is PecosPulledPork) { screen = new CustomizedPecosPulledPork(); screen.DataContext = item; orderControl?.SwapScreen(screen); } else if (item is BakedBeans || item is ChiliCheeseFries || item is CornDodgers || item is PanDeCampo) { screen = new CustomizedSide(DataContext); screen.DataContext = item; orderControl?.SwapScreen(screen); } else if (item is CowboyCoffee) { screen = new CustomizedCowboyCoffee(DataContext); screen.DataContext = item; orderControl?.SwapScreen(screen); } else if (item is JerkedSoda) { screen = new CustomizedJerkSoda(DataContext); screen.DataContext = item; orderControl?.SwapScreen(screen); } else if (item is TexasTea) { screen = new CustomizedTexasTea(DataContext); screen.DataContext = item; orderControl?.SwapScreen(screen); } else if (item is Water) { screen = new CustomizedWater(DataContext); screen.DataContext = item; orderControl?.SwapScreen(screen); } } } } }
/// <summary> /// Goes to the screen of item clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { FrameworkElement screen; OrderControl orderControl = null; // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Entrees --------------------------------------------------------------------- if (orderList.SelectedItem is IOrderItem item) { if (item is AngryChicken angryChicken) { screen = new CustomizedAngryChicken(angryChicken); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = angryChicken; orderControl.SwapScreen(screen); } } else if (orderList.SelectedItem is CowpokeChili cowpokeChili) { screen = new CustomizedCowpokeChili(cowpokeChili); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = cowpokeChili; orderControl.SwapScreen(screen); } } else if (orderList.SelectedItem is DakotaDoubleBurger dakotaDouble) { screen = new CustomizedDakotaDoubleBurger(dakotaDouble); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = dakotaDouble; orderControl.SwapScreen(screen); } } else if (orderList.SelectedItem is PecosPulledPork pecosPulledPork) { screen = new CustomizedPecosPulledPork(pecosPulledPork); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = pecosPulledPork; orderControl.SwapScreen(screen); } } else if (orderList.SelectedItem is TexasTripleBurger texasTriple) { screen = new CustomizedTexasTripleBurger(texasTriple); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = texasTriple; orderControl.SwapScreen(screen); } } else if (orderList.SelectedItem is TrailBurger trailBurger) { screen = new CustomizedTrailBurger(trailBurger); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = trailBurger; orderControl.SwapScreen(screen); } } // Sides --------------------------------------------------------------------- else if (orderList.SelectedItem is BakedBeans bakedBeans) { screen = new CustomizedBakedBeans(bakedBeans); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = bakedBeans; orderControl.SwapScreen(screen); } } else if (orderList.SelectedItem is ChiliCheeseFries chiliCheeseFries) { screen = new CustomizedChiliCheeseFries(chiliCheeseFries); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = chiliCheeseFries; orderControl.SwapScreen(screen); } } else if (orderList.SelectedItem is CornDodgers cornDodgers) { screen = new CustomizedCornDodgers(cornDodgers); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = cornDodgers; orderControl.SwapScreen(screen); } } else if (orderList.SelectedItem is PanDeCampo panDeCampo) { screen = new CustomizedPanDeCampo(panDeCampo); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = panDeCampo; orderControl.SwapScreen(screen); } } // Drinks --------------------------------------------------------------------- else if (orderList.SelectedItem is CowboyCoffee cowboyCoffee) { screen = new CustomizedCowboyCoffee(cowboyCoffee); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = cowboyCoffee; orderControl.SwapScreen(screen); } } else if (orderList.SelectedItem is JerkedSoda jerkedSoda) { screen = new CustomizedJerkedSoda(jerkedSoda); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = jerkedSoda; orderControl.SwapScreen(screen); } } else if (orderList.SelectedItem is TexasTea texasTea) { screen = new CustomizedTexasTea(texasTea); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = texasTea; orderControl.SwapScreen(screen); } } else if (orderList.SelectedItem is Water water) { screen = new CustomizedWater(water); if (screen != null) { // Need ancestor to load customization screen orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of OrderControl expected"); } // Add item to customization screen screen.DataContext = water; orderControl.SwapScreen(screen); } } // All else --------------------------------------------------------------------- else { // Add item to customization screen orderControl?.SwapScreen(new MenuItemSelectionControl()); } orderList.SelectedItem = null; } }