/// <summary> /// Adds Item to the order /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnAddBakedBeansButtonClicked(object sender, RoutedEventArgs e) { var orderControl = this.FindAncestor <OrderControl>(); if (DataContext is Order data) // checks if you can cast it and if assigns it to data { var entree = new BakedBeans(); var screen = new CustomizeSide(); AddItemAndOpenCustomizationScreen(entree, screen); } }
/// <summary> /// Adds Pan de Campo to order list when corresponding button is pushed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnPanDeCampoAdded(object sender, RoutedEventArgs e) { var orderControl = this.FindAncestor <OrderControl>(); if (DataContext is Order data) { var side = new PanDeCampo(); var screen = new CustomizeSide(); AddItemAndOpenCustomizationScreen(side, screen); } }
/// <summary> /// sets new DragonbornWaffleFries object as DataContext of the customization screen /// binds form controls to object properties /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void CustomizeSize(object sender, RoutedEventArgs e) { DragonbornWaffleFries d = new DragonbornWaffleFries(); var customizeScreen = new CustomizeSide(); //set DataContext customizeScreen.DataContext = d; //databinding //size //switch screen selectionBorder.Child = customizeScreen; }
void OnAddBakedBeansButtonClicked(object sender, RoutedEventArgs e) { //o.Add(new BakedBeans()); orderControl = this.FindAncestor <OrderControl>(); if (DataContext is Order order) { var side = new BakedBeans(); var screen = new CustomizeSide(); screen.DataContext = side; order.Add(side); orderControl.SwapScreen(screen); } }
public void OnAddSideButtonClicked(object sender, RoutedEventArgs e) { var orderControl = this.FindAncestor <OrderControl>(); if (DataContext is Order order) { if (sender is Button button) { switch (button.Tag) { case "BakedBeans": var bakedBeans = new BakedBeans(); var screen = new CustomizeSide(bakedBeans, DataContext); screen.DataContext = bakedBeans; order.Add(bakedBeans); orderControl.SwapScreen(screen); break; case "ChiliCheeseFries": var chiliCheeseFries = new ChiliCheeseFries(); screen = new CustomizeSide(chiliCheeseFries, DataContext); screen.DataContext = chiliCheeseFries; order.Add(chiliCheeseFries); orderControl.SwapScreen(screen); break; case "CornDodgers": var cornDodgers = new CornDodgers(); screen = new CustomizeSide(cornDodgers, DataContext); screen.DataContext = cornDodgers; order.Add(cornDodgers); orderControl.SwapScreen(screen); break; case "PanDeCampo": var panDeCampo = new PanDeCampo(); screen = new CustomizeSide(panDeCampo, DataContext); screen.DataContext = panDeCampo; order.Add(panDeCampo); orderControl.SwapScreen(screen); break; } } } }
/// <summary> /// This method adds sides to the list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addSideToList(object sender, RoutedEventArgs e) { //Ensure the DataContext is an Order and not NULL if (DataContext is Order order) { if (sender is Button) { IOrderItem item; FrameworkElement screen = null; var orderControl = this.FindAncestor <OrderControl>(); //Cast sender to button Button b = (Button)sender; //Filter which button was pressed based on name switch (b.Name) { case "AddBakedBeans": item = new BakedBeans(); break; case "AddChiliCheeseFries": item = new ChiliCheeseFries(); break; case "AddCornDogs": item = new CornDodgers(); break; case "AddPanDeCampo": item = new PanDeCampo(); break; default: throw new NotImplementedException("Unknown side button clicked"); } screen = new CustomizeSide(DataContext); screen.DataContext = item; item.Screen = screen; order.Add(item); orderControl.SwapScreen(screen); } } }
void OnAddChiliCheeseFriesButtonClicked(object sender, RoutedEventArgs e) { //OrderListView.Items.Add(new ChiliCheeseFries()); //o.Add(new ChiliCheeseFries()); /*if (DataContext is Order order) * { * order.Add(new ChiliCheeseFries()); * }*/ orderControl = this.FindAncestor <OrderControl>(); if (DataContext is Order order) { var side = new ChiliCheeseFries(); var screen = new CustomizeSide(); screen.DataContext = side; order.Add(side); orderControl.SwapScreen(screen); } }
/// <summary> /// Eventhandler that opens a customization screen for the selected item in the /// OrderSummaryControl's ListBox. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnListItemSelection(object sender, RoutedEventArgs e) { if (sender is ListBox lb) { IOrderItem selected = lb.SelectedItem as IOrderItem; //this.DataContext = sender as IOrderItem; if (selected is Entree) { SwapScreen(new CustomizeEntree(selected)); } else if (selected is Drink) { SwapScreen(new CustomizeDrink(selected)); } else if (selected is Side) { var sideCustomizer = new CustomizeSide(selected); sideCustomizer.DataContext = selected; SwapScreen(sideCustomizer); } } }
public void OnItemButtonClicked(object sender, RoutedEventArgs e) { var orderControl = this.FindAncestor <OrderControl>(); if (DataContext is Order order) { if (sender is Button button) { switch (button.Tag) { case "CowpokeChili": var chiliEntree = new CowpokeChili(); var chiliScreen = new CustomizeCowpokeChili(); chiliScreen.DataContext = chiliEntree; order.Add(chiliEntree); orderControl.SwapScreen(chiliScreen); break; case "PecosPulledPork": var porkEntree = new PecosPulledPork(); var porkScreen = new CustomizePecosPulledPork(); porkScreen.DataContext = porkEntree; order.Add(porkEntree); orderControl.SwapScreen(porkScreen); break; case "Trailburger": var trailentree = new TrailBurger(); var trailscreen = new CustomizeTrailburger(); trailscreen.DataContext = trailentree; order.Add(trailentree); orderControl.SwapScreen(trailscreen); break; case "DakotaDouble": var dakotaentree = new DakotaDoubleBurger(); var dakotascreen = new CustomizeDakotaDouble(); dakotascreen.DataContext = dakotaentree; order.Add(dakotaentree); orderControl.SwapScreen(dakotascreen); break; case "TexasTriple": var texasentree = new TexasTripleBurger(); var texasscreen = new CustomizeTexasTriple(); texasscreen.DataContext = texasentree; order.Add(texasentree); orderControl.SwapScreen(texasscreen); break; case "AngryChicken": var entree = new AngryChicken(); var screen = new CustomizeAngryChicken(); screen.DataContext = entree; order.Add(entree); orderControl.SwapScreen(screen); break; case "ChiliCheeseFries": var chilientree = new ChiliCheeseFries(); var chiliscreen = new CustomizeSide(); chiliscreen.DataContext = chilientree; order.Add(chilientree); orderControl.SwapScreen(chiliscreen); break; case "CornDodgers": var dogerentree = new CornDodgers(); var dogerscreen = new CustomizeSide(); dogerscreen.DataContext = dogerentree; order.Add(dogerentree); orderControl.SwapScreen(dogerscreen); break; case "PanDeCampo": var panentree = new PanDeCampo(); var panscreen = new CustomizeSide(); panscreen.DataContext = panentree; order.Add(panentree); orderControl.SwapScreen(panscreen); break; case "BakedBeans": var Beansentree = new BakedBeans(); var Beansscreen = new CustomizeSide(); Beansscreen.DataContext = Beansentree; order.Add(Beansentree); orderControl.SwapScreen(Beansscreen); break; case "JerkedSoda": var sodaentree = new JerkedSoda(); var sodascreen = new CustomizeJerkedSoda(); sodascreen.DataContext = sodaentree; order.Add(sodaentree); orderControl.SwapScreen(sodascreen); break; case "TexasTea": var teaentree = new TexasTea(); var teascreen = new CustomizeTexasTea(); teascreen.DataContext = teaentree; order.Add(teaentree); orderControl.SwapScreen(teascreen); break; case "CowboyCoffee": var coffeeentree = new CowboyCoffee(); var coffeescreen = new CustomizeCowboyCoffee(); coffeescreen.DataContext = coffeeentree; order.Add(coffeeentree); orderControl.SwapScreen(coffeescreen); break; case "Water": var waterentree = new Water(); var waterscreen = new CustomizeWater(); waterscreen.DataContext = waterentree; order.Add(waterentree); orderControl.SwapScreen(waterscreen); break; } } } }
public void OnItemSelectionChanged(object sender, SelectionChangedEventArgs e, OrderControl oc, Order o) { var item = e.AddedItems[0]; if (e.AddedItems[0] is CowpokeChili) { var screen = new CustomizeEntree("Cowpoke Chili"); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is AngryChicken) { var screen = new CustomizeEntree("Angry Chicken"); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is DakotaDoubleBurger) { var screen = new CustomizeEntree("Dakota Double Burger"); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is PecosPulledPork) { var screen = new CustomizeEntree("Pecos Pulled Pork"); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is RustlersRibs) { var screen = new CustomizeEntree("Rustler Ribs"); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is TexasTripleBurger) { var screen = new CustomizeEntree("Texas Triple Burger"); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is TrailBurger) { var screen = new CustomizeEntree("Trail Burger"); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is CowboyCoffee) { var screen = new CustomizeDrink("Cowboy Coffee", e.AddedItems[0], o); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is JerkedSoda) { var screen = new CustomizeDrink("Jerked Soda", e.AddedItems[0], o); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is TexasTea) { var screen = new CustomizeDrink("Texas Tea", e.AddedItems[0], o); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is Water) { var screen = new CustomizeDrink("Water", e.AddedItems[0], o); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is BakedBeans) { var screen = new CustomizeSide(e.AddedItems[0], o); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is ChiliCheeseFries) { var screen = new CustomizeSide(e.AddedItems[0], o); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is CornDodgers) { var screen = new CustomizeSide(e.AddedItems[0], o); screen.DataContext = item; oc.SwapScreen(screen); } if (e.AddedItems[0] is PanDeCampo) { var screen = new CustomizeSide(e.AddedItems[0], o); screen.DataContext = item; oc.SwapScreen(screen); } }
public void SwitchScreen(object sender, RoutedEventArgs e) { if (sender is ListBox box) { if (box.SelectedItem is IOrderItem item) { box.SelectedItem = null; if (item is AngryChicken chicken) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeAngryChicken(); screen.DataContext = chicken; order.SwapScreen(screen); } else if (item is BakedBeans bean) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeSide(); screen.DataContext = bean; order.SwapScreen(screen); } else if (item is ChiliCheeseFries fries) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeSide(); screen.DataContext = fries; order.SwapScreen(screen); } else if (item is CornDodgers corn) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeSide(); screen.DataContext = corn; order.SwapScreen(screen); } else if (item is CowboyCoffee coffee) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeCowboyCoffee(); screen.DataContext = coffee; order.SwapScreen(screen); } else if (item is CowpokeChili chili) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeCowpokeChili(); screen.DataContext = chili; order.SwapScreen(screen); } else if (item is DakotaDoubleBurger dakota) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeDakotaDouble(); screen.DataContext = dakota; order.SwapScreen(screen); } else if (item is JerkedSoda soda) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeJerkedSoda(); screen.DataContext = soda; order.SwapScreen(screen); } else if (item is PanDeCampo pan) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeSide(); screen.DataContext = pan; order.SwapScreen(screen); } else if (item is PecosPulledPork pork) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizePecosPulledPork(); screen.DataContext = pork; order.SwapScreen(screen); } else if (item is TexasTea tea) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeTexasTea(); screen.DataContext = tea; order.SwapScreen(screen); } else if (item is TexasTripleBurger tex) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeTexasTriple(); screen.DataContext = tex; order.SwapScreen(screen); } else if (item is TrailBurger burger) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeTrailburger(); screen.DataContext = burger; order.SwapScreen(screen); } else if (item is Water water) { order = this.FindAncestor <OrderControl>(); var screen = new CustomizeWater(); screen.DataContext = water; order.SwapScreen(screen); } } } }
/// <summary> /// Generalized event handler for button IOrderItem button clicks /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnIOrderItemButtonClicked(object sender, RoutedEventArgs e) { var orderControl = this.FindAncestor <OrderControl>(); if (DataContext is Order CurrentOrder) { if (sender is Button button) { switch (button.Tag) { case "CowpokeChili": { var item = new CowpokeChili(); var screen = new CustomizeEntree(item as IOrderItem); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "AngryChicken": { var item = new AngryChicken(); var screen = new CustomizeEntree(item as IOrderItem); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "DakotaDoubleBurger": { var item = new DakotaDoubleBurger(); var screen = new CustomizeEntree(item as IOrderItem); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "PecosPulledPork": { var item = new PecosPulledPork(); var screen = new CustomizeEntree(item as IOrderItem); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "RustlersRibs": { var item = new RustlersRibs(); CurrentOrder.Add(item); break; } case "TexasTripleBurger": { var item = new TexasTripleBurger(); var screen = new CustomizeEntree(item as IOrderItem); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "TrailBurger": { var item = new TrailBurger(); var screen = new CustomizeEntree(item as IOrderItem); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "BakedBeans": { var item = new BakedBeans(); var screen = new CustomizeSide(item); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "ChiliCheeseFries": { var item = new ChiliCheeseFries(); var screen = new CustomizeSide(item); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "CornDodgers": { var item = new CornDodgers(); var screen = new CustomizeSide(item); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "PanDeCampo": { var item = new PanDeCampo(); var screen = new CustomizeSide(item); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "CowboyCoffee": { var item = new CowboyCoffee(); var screen = new CustomizeDrink(item); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "JerkedSoda": { var item = new JerkedSoda(); var screen = new CustomizeDrink(item); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "TexasTea": { var item = new TexasTea(); var screen = new CustomizeDrink(item); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } case "Water": { var item = new Water(); var screen = new CustomizeDrink(item); CurrentOrder.Add(item); orderControl.SwapScreen(screen); break; } } } } }
/// <summary> /// Allows user to access customiztion through the list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (DataContext is Order order) { if (sender is ListView list) { if (list.SelectedValue is IOrderItem item) { var orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An Ancestor was not found"); } var screen = new FrameworkElement(); switch (item) { case AngryChicken chicken: screen = new CustomizeAngryChicken(); break; case CowpokeChili chili: screen = new CustomizeCowpokeChili(); break; case TrailBurger burger: screen = new CustomizeTrailBurger(); break; case DakotaDoubleBurger burger: screen = new CustomizeDakotaDoubleBurger(); break; case PecosPulledPork Pork: screen = new CustomizePekosPulledPork(); break; case Water water: screen = new CustomizeWater(); break; case JerkedSoda soda: screen = new CustomizeJerkedSoda(); break; case TexasTea tea: screen = new CustomizeTexasTea(); break; case CowboyCoffee coffee: screen = new CustomizeCowboyCoffee(); break; case TexasTripleBurger burger: screen = new CustomizeTexasTripleBurger(); break; case Side side: screen = new CustomizeSide(); break; } screen.DataContext = item; orderControl.SwapScreen(screen); } } } }
/// <summary> /// When an item from the order summary is selected, the screen switches to the corresponding customization screen /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnSelectItem(object sender, RoutedEventArgs e) { if (DataContext is Order order) { if (sender is ListBox lb) { if (lb.SelectedItem != null) { var item = lb.SelectedItem; FrameworkElement screen; switch (item.ToString()) { case "Trail Burger": screen = new CustomizeTrailBurger(); break; case "Dakota Double Burger": screen = new CustomizeDakotaDoubleBurger(); break; case "Texas Triple Burger": screen = new CustomizeTexasTripleBurger(); break; case "Angry Chicken": screen = new CustomizeAngryChicken(); break; case "Cowpoke Chili": screen = new CustomizeCowpokeChili(); break; case "Pecos Pulled Pork": screen = new CustomizePecosPulledPork(); break; default: screen = null; break; } if (item is Side) { screen = new CustomizeSide(); } if (item is CowboyCoffee) { screen = new CustomizeCowboyCoffee(); } if (item is JerkedSoda) { screen = new CustomizeJerkedSoda(); } if (item is TexasTea) { screen = new CustomizeTexasTea(); } if (item is Water) { screen = new CustomizeWater(); } if (screen != null) { var orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { throw new Exception("An ancestor of Ordercontrol expected to not be null"); } screen.DataContext = item; orderControl.SwapScreen(screen); } lb.SelectedIndex = -1; } } } }
/// <summary> /// Adds item /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void itemSelected(object sender, SelectionChangedEventArgs args) { var orderControl = this.FindAncestor <OrderControl>(); if (orderControl == null) { return; } foreach (object o in args.AddedItems) { if (o is AngryChicken) { var screen = new CustomizeAngryChicken(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is BakedBeans) { var screen = new CustomizeSide(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is ChiliCheeseFries) { var screen = new CustomizeChiliCheeseFries(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is CornDodgers) { var screen = new CustomizeSide(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is CowboyCoffee) { var screen = new CustomizeCowboyCoffee(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is CowpokeChili) { var screen = new CustomizeCowpokeChili(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is DakotaDoubleBurger) { var screen = new CustomizeDakotaDoubleBurger(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is JerkedSoda) { var screen = new CustomizeJerkedSoda(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is PanDeCampo) { var screen = new CustomizeSide(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is PecosPulledPork) { var screen = new CustomizePecosPulledPork(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is TexasTea) { var screen = new CustomizeTexasTea(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is TexasTripleBurger) { var screen = new CustomizeTexasTripleBurger(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is TrailBurger) { var screen = new CustomizeTrailBurger(); screen.DataContext = o; orderControl.SwapScreen(screen); } else if (o is Water) { var screen = new CustomizeWater(); screen.DataContext = o; orderControl.SwapScreen(screen); } } }
void OnListBoxItemSelected(object sender, SelectionChangedEventArgs args) { if(sender is ListBox lb) { if(lb.SelectedItem is IOrderItem orderItem) { if(orderItem is AngryChicken ac) { var screen = new CustomizeAngryChicken(); screen.DataContext = ac; orderControl = this.FindAncestor<OrderControl>(); orderControl.SwapScreen(screen); } else if (orderItem is CowboyCoffee c) { var screen = new CustomizeCowboyCoffee(); screen.DataContext = c; screen.SetButton(); orderControl = this.FindAncestor<OrderControl>(); orderControl.SwapScreen(screen); } else if (orderItem is CowpokeChili chili) { var screen = new CustomizeCowpokeChili(); screen.DataContext = chili; orderControl = this.FindAncestor<OrderControl>(); orderControl.SwapScreen(screen); } else if (orderItem is DakotaDoubleBurger db) { var screen = new CustomizeDakotaDoubleBurger(); screen.DataContext = db; orderControl = this.FindAncestor<OrderControl>(); orderControl.SwapScreen(screen); } else if (orderItem is JerkedSoda soda) { var screen = new CustomizeJerkedSoda(); screen.DataContext = soda; screen.SetButton(); screen.SetFlavorButton(); orderControl = this.FindAncestor<OrderControl>(); orderControl.SwapScreen(screen); } else if (orderItem is PecosPulledPork pork) { var screen = new CustomizePecosPulledPork(); screen.DataContext = pork; orderControl = this.FindAncestor<OrderControl>(); orderControl.SwapScreen(screen); } else if (orderItem is Side s) { var screen = new CustomizeSide(); screen.DataContext = s; screen.SetButton(); //sets the correct radio button to be checked orderControl = this.FindAncestor<OrderControl>(); orderControl.SwapScreen(screen); } else if (orderItem is TexasTea t) { var screen = new CustomizeTexasTea(); screen.DataContext = t; screen.SetButton(); orderControl = this.FindAncestor<OrderControl>(); orderControl.SwapScreen(screen); } else if (orderItem is TexasTripleBurger triple) { var screen = new CustomizeTexasTripleBurger(); screen.DataContext = triple; orderControl = this.FindAncestor<OrderControl>(); orderControl.SwapScreen(screen); } else if (orderItem is TrailBurger tb) { var screen = new CustomizeTrailBurger(); screen.DataContext = tb; orderControl = this.FindAncestor<OrderControl>(); orderControl.SwapScreen(screen); } else if (orderItem is Water w) { var screen = new CustomizeWater(); screen.DataContext = w; screen.SetButton(); orderControl = this.FindAncestor<OrderControl>(); orderControl.SwapScreen(screen); } } } }