/// <summary> /// Does the actual setting of the sizes /// </summary> /// <param name="scc">The size screen associated with the order item</param> /// <param name="s">The size it needs to be set to</param> private void setSize(SizeChangingCustomization scc, Size s) { switch (s) { case Size.Small: scc.SizeRadioButtonSmall.IsChecked = true; break; case Size.Medium: scc.SizeRadioButtonMedium.IsChecked = true; break; case Size.Large: scc.SizeRadioButtonLarge.IsChecked = true; break; default: throw new NotImplementedException("Should never be reached"); } }
/// <summary> /// This method adds sides to the list by converting the /// sender object to a button and filtering on the name of the button /// that was pressed /// </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 data) { //Ensure the sender is on of buttons if (sender is Button) { IOrderItem item; FrameworkElement screen = new SizeChangingCustomization(); var orderControl = this.FindAncestor <OrderControl>(); //Filter which button was pressed based on name switch (((Button)sender).Name) { //Baked Beans case "BakedBeansButton": item = new BakedBeans(); break; //Chili Cheese Fries case "ChiliCheeseFriesButton": item = new ChiliCheeseFries(); break; //Corn Dodgers case "CornDodgersButton": item = new CornDodgers(); break; //Pan De Campo case "PanDeCampoButton": item = new PanDeCampo(); break; //This should never be reached unless we add more sides and forget to add the case statements ;P default: throw new NotImplementedException("Unknown side button clicked"); } //Set the datacontext of the screen to the item and set the items screen property equal to the screen screen.DataContext = item; item.Screen = screen; //Add the item to the order and swap the screen data.Add(item); orderControl?.SwapScreen(screen); } } }