示例#1
0
        /// <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;
                    }
                    }
                }
            }
        }