コード例 #1
0
        /// <summary>
        /// The constructor for this page. Adds a button for each drink and the radio buttons for the sizes.
        /// </summary>
        public DrinkSelection()
        {
            InitializeComponent();

            List <Menu.Size> sizes = new List <Menu.Size>
            {
                Menu.Size.Small,
                Menu.Size.Medium,
                Menu.Size.Large
            };

            // Adds buttons for each drink to the menu programatically.
            Menu.Menu menu = new Menu.Menu();
            DrinkGrid.RowDefinitions.Add(new RowDefinition());
            int x = 0;

            foreach (Drink drink in menu.AvailableDrinks)
            {
                Button button = new Button
                {
                    Content = new TextBlock
                    {
                        Text          = App.CorrectDrinkAndSideNames(drink.ToString()),
                        TextWrapping  = TextWrapping.Wrap,
                        TextAlignment = TextAlignment.Center
                    },
                    Name = App.CreateValidIdString(drink.ToString())
                };

                DrinkGrid.ColumnDefinitions.Add(new ColumnDefinition());
                button.SetValue(Grid.ColumnProperty, x++);
                button.SetValue(Grid.RowProperty, 0);

                button.Click += new RoutedEventHandler(Button_Click);
                DrinkGrid.Children.Add(button);
            }

            SizeGrid.RowDefinitions.Add(new RowDefinition());
            x = 0;

            foreach (Menu.Size size in sizes)
            {
                RadioButton radioButton = new RadioButton
                {
                    Content   = size.ToString(),
                    Name      = size.ToString(),
                    IsChecked = (size.ToString() == "Small")
                };

                SizeGrid.ColumnDefinitions.Add(new ColumnDefinition());
                radioButton.SetValue(Grid.ColumnProperty, x++);
                radioButton.SetValue(Grid.RowProperty, 0);

                radioButton.Checked += RadioButton_Checked;

                SizeGrid.Children.Add(radioButton);
            }
        }
コード例 #2
0
        private void UpdateDrinkAndSideButtons(CretaceousCombo combo)
        {
            // Change text of button for Sides
            TextBlock sideText = SideButton.Content as TextBlock;

            sideText.Text = "Side: " + App.CorrectDrinkAndSideNames(combo.Side.ToString());

            // Change text of button for Drinks
            TextBlock drinkText = DrinkButton.Content as TextBlock;

            drinkText.Text = "Drink: " + App.CorrectDrinkAndSideNames(combo.Drink.ToString());
        }