/// <summary> /// Method to customize the entree items on cowboy cafe menu /// Selects appropriate customization screen and displays options according to entree ordered /// </summary> /// <param name="entree">Instance of the entree to be customized</param> private void CustomizeEntree(Entree entree) { if (DataContext is Order myOrder) { //Finds the OrderControl that contains the MenuItemSelectionControl by recursive call that compares parent type to OrderControl var orderControl = this.FindAncestor <OrderControl>(); //Creates variable to hold the customization screen determined by the switch UserControl screen = null; switch (entree) { case AngryChicken ac: screen = new AngryChickenCustomization(); break; case CowpokeChili cc: screen = new CowpokeChiliCustomization(); break; case DakotaDoubleBurger ddb: screen = new DakotaDoubleBurgerCustomization(); break; case PecosPulledPork ppp: screen = new PecosPulledPorkCustomization(); break; case RustlersRibs rr: break; case TexasTripleBurger ttb: screen = new TexasTripleBurgerCustomization(); break; case Trailburger tb: screen = new TrailburgerCustomization(); break; default: break; } //Adds item determined by button to the entree myOrder.Add(entree); //switches screen to correct customization screen if (screen != null) { screen.DataContext = entree; orderControl.SwapScreen(screen); } } }
private void ShowCustomization(IOrderItem item) { var orderControl = this.FindAncestor <OrderControl>(); UserControl screen = null; if (item is Entree e) { switch (e) { case AngryChicken ac: screen = new AngryChickenCustomization(ac); break; case CowpokeChili cc: screen = new CowpokeChiliCustomization(); screen.DataContext = cc; break; case DakotaDoubleBurger ddb: screen = new DakotaDoubleBurgerCustomization(); break; case PecosPulledPork ppp: screen = new PecosPulledPorkCustomization(); break; case RustlersRibs rr: break; case TexasTripleBurger ttb: screen = new TexasTripleBurgerCustomization(); break; case Trailburger tb: screen = new TrailburgerCustomization(); break; default: break; } } else if (item is Side side) { screen = new CustomizationScreens.SizeControl(side); } else if (item is Drink drink) { switch (drink) { case CowboyCoffee cc: screen = new CowboyCoffeeCustomization(); break; case JerkedSoda js: screen = new JerkedSodaCustomization(); break; case TexasTea tt: screen = new TexasTeaCustomization(); break; case Water w: screen = new WaterCustomization(); break; default: break; } } if (screen != null) { screen.DataContext = item; orderControl.CustomizationContainer.Child = screen; } }