Esempio n. 1
0
        private void NewBox_Click(object sender, RoutedEventArgs e)
        {
            if (stopPortions)
            {
                return;
            }

            CheckBoxWithId box = (CheckBoxWithId)sender;

            ComboBoxWithId portions = this.portions[box.Position];

            if ((bool)box.IsChecked)
            {
                if (!model.Children.Contains(allModel.Children[box.Position]))
                {
                    model.Children.Add(allModel.Children[box.Position]);
                }

                portions.Visibility = Visibility.Visible;
            }
            else
            {
                if (model.Children.Contains(allModel.Children[box.Position]))
                {
                    model.Children.Remove(allModel.Children[box.Position]);
                }

                portions.Visibility = Visibility.Hidden;
            }

            ItemChecked(this, new ItemCheckedEventArgs <ItemModelBase>());
        }
Esempio n. 2
0
        private void Portions_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (stopPortions)
            {
                return;
            }

            ComboBoxWithId combo = (ComboBoxWithId)sender;

            IngredientModel ingredient = (IngredientModel)model.Children.Where(ing => ing.Id == combo.Id).Single();

            ingredient.Portions = combo.SelectedIndex + 1;

            PortionChosen(this, new PortionChosenEventArgs());
        }
Esempio n. 3
0
        public CheckList()
        {
            allModel = new IngredientsModel();

            int position = 0;

            foreach (IngredientModel ingredientModel in allModel.Children)
            {
                CheckBoxWithId newBox = new CheckBoxWithId(ingredientModel.Id, position)
                {
                    Content = ingredientModel.Description
                };
                newBox.Width  = 255;
                newBox.Click += NewBox_Click;
                boxes.Add(newBox.Id, newBox);

                ComboBoxWithId portions = new ComboBoxWithId(newBox.Id, position);
                portions.Text       = ingredientModel.Portions.ToString();
                portions.FontWeight = FontWeights.Bold;
                portions.Visibility = Visibility.Hidden;
                portions.Items.Add(new TextBlock()
                {
                    Text = "1"
                });
                portions.Items.Add(new TextBlock()
                {
                    Text = "2"
                });
                portions.Items.Add(new TextBlock()
                {
                    Text = "3"
                });
                portions.SelectedIndex     = 0;
                portions.SelectionChanged += Portions_SelectionChanged;
                this.portions.Add(portions);

                StackPanel panel = new StackPanel();
                panel.Orientation = Orientation.Horizontal;

                panel.Children.Add(newBox);
                panel.Children.Add(portions);

                this.AddChild(panel);

                ++position;
            }
        }