Ejemplo n.º 1
0
        ///void OnMenuISBClick(object o, RoutedEventArgs args)
        ///{
        ///if (DataContext is Order data)
        ///{
        /// data.Add(new Order());
        ///}

        ///}

        ///void OnMenuISBClick(object o, RoutedEventArgs args)
        ///{

        ///var orderControl = this.FindAncestor<OrderControl>();

        ///if (DataContext is Order data)
        ///{
        ///if(o is Button button)
        ///{

        ///switch (button.Tag)
        ///{

        ///case "CowpokeChili":
        ///var item = new CowpokeChili();
        ///var screen = new CowpokeChiliCustomize();
        ///screen.DataContext = item;
        ///Order.Add(item);
        ///orderControl?.SwapScreen(screen);
        ///break;

        ///}

        ///}

        ///data.Add(new Order());

        ///}

        ////}



        /// <summary>
        /// Adds Angry Chicken to the order list.
        /// </summary>
        private void AddAngryChickenButton_Click(object sender, RoutedEventArgs e)
        {
            var orderControl = this.FindAncestor <OrderControl>();

            if (DataContext is Order order)
            {
                IOrderItem item   = new AngryChicken();
                var        screen = new AngryChickenCustomize();
                screen.DataContext = item;
                order.Add(item);
                orderControl?.SwapScreen(screen);
            }
        }
        /// <summary>
        /// Swaps screen for instructions on items ordered
        /// </summary>
        private void OrderList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var orderControl = this.FindAncestor <OrderControl>();

            foreach (object items in e.AddedItems)
            {
                if (items is AngryChicken)
                {
                    var screen = new AngryChickenCustomize();
                    screen.DataContext = items;
                    orderControl?.SwapScreen(screen);
                }
                else if (items is CowboyCoffee)
                {
                    var screen = new CowboyCoffeeCustomize();
                    screen.DataContext = items;
                    orderControl?.SwapScreen(screen);
                }
                else if (items is CowpokeChili)
                {
                    var screen = new CowpokeChiliCustomize();
                    screen.DataContext = items;
                    orderControl?.SwapScreen(screen);
                }
                else if (items is JerkedSoda)
                {
                    var screen = new JerkedSodaCustomize();
                    screen.DataContext = items;
                    orderControl?.SwapScreen(screen);
                }
                else if (items is DakotaDoubleBurger)
                {
                    var screen = new DakotaDoubleBurgerCustomize();
                    screen.DataContext = items;
                    orderControl?.SwapScreen(screen);
                }
                else if (items is PecosPulledPork)
                {
                    var screen = new PecosPulledPorkCustomize();
                    screen.DataContext = items;
                    orderControl?.SwapScreen(screen);
                }
                else if (items is TexasTea)
                {
                    var screen = new TexasTeaCustomize();
                    screen.DataContext = items;
                    orderControl?.SwapScreen(screen);
                }
                else if (items is TexasTripleBurger)
                {
                    var screen = new TexasTripleBurgerCustomize();
                    screen.DataContext = items;
                    orderControl?.SwapScreen(screen);
                }
                else if (items is TrailBurger)
                {
                    var screen = new TrailBurgerCustomize();
                    screen.DataContext = items;
                    orderControl?.SwapScreen(screen);
                }
                else if (items is Water)
                {
                    var screen = new WaterCustomize();
                    screen.DataContext = items;
                    orderControl?.SwapScreen(screen);
                }
            }
        }