예제 #1
0
        /// <summary>
        /// Swaps to the customization screen of the chosen item.
        /// </summary>
        /// <param name="sender">The button that was clicked</param>
        /// <param name="e">The event arguments.</param>
        private void CustomizeItemClicked(object sender, RoutedEventArgs e)
        {
            if (sender is Button b)
            {
                if (DataContext is Combo combo)
                {
                    IMenuScreen menu = this.GetParent <ItemCustomization>();
                    if (menu == null)
                    {
                        menu = this.GetParent <ItemModification>();
                    }

                    ItemModification modifier = new ItemModification();

                    IOrderItem item = combo.Entree;
                    if ((string)b.Tag == "1")
                    {
                        item = combo.Drink;
                    }
                    else if ((string)b.Tag == "2")
                    {
                        item = combo.Side;
                    }

                    CustomizationScreen screen = Helper.GetCustomizationScreen(item, out string text);
                    modifier.customizeItemLabel.Text = text;

                    screen.DataContext = item;
                    modifier.customizationContainer.Child = screen;
                    modifier.ReturnScreen = menu as UserControl;

                    menu.OrderComponent.ChangeScreen(modifier);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Returns to the menu selection screen without adding the item.
        /// </summary>
        /// <param name="sender">The button that was pressed.</param>
        /// <param name="e">The event arguments associated with the press.</param>
        private void CancelClicked(object sender, RoutedEventArgs e)
        {
            CustomizationScreen customization = customizationContainer.Child as CustomizationScreen;

            if (customization == null)
            {
                throw new InvalidOperationException("Cannot add the item when no customization has been set.");
            }

            if (DataContext is Order order)
            {
                order.Remove(customization.OrderedItem);
            }

            OrderComponent.ChangeScreen(new MenuSelectionScreen());
        }
예제 #3
0
        /// <summary>
        /// Adds the customized item to the order and returns to the menu selection screen.
        /// </summary>
        /// <param name="sender">The button that was pressed.</param>
        /// <param name="e">The event arguments associated with the press.</param>
        /// <exception cref="System.InvalidOperationException">Thrown if there is no actual customization component.</exception>
        private void AddItemClicked(object sender, RoutedEventArgs e)
        {
            CustomizationScreen customization = customizationContainer.Child as CustomizationScreen;

            OrderComponent.ChangeScreen(new MenuSelectionScreen());
        }