コード例 #1
0
        public void GenerateProjectListUI(ProjectList newProjectList)
        {
            string listName     = newProjectList.getName();
            string listPriority = newProjectList.getListPriority();

            MainStackPanel.Children.Add(new Separator()
            {
                Width = 20, Visibility = Visibility.Hidden
            });

            StackPanel newStackPanel = new StackPanel();

            newStackPanel.Width      = 120;
            newStackPanel.Margin     = new Thickness(0, 10, 0, 10);
            newStackPanel.Background = new SolidColorBrush(Colors.LightGray);

            Button deleteListButton = new Button()
            {
                Content             = "-",
                FontSize            = 16,
                HorizontalAlignment = HorizontalAlignment.Right,
                Tag    = newProjectList,
                Height = 12,
                Margin = new Thickness(0, 6, 6, 0),
            };

            deleteListButton.Click += DeleteListButton_Click;
            newStackPanel.Children.Add(deleteListButton);

            Label listHeaderLabel = new Label();

            listHeaderLabel.Content = listName;
            newStackPanel.Children.Add(listHeaderLabel);

            ComboBox     priorityComboBox = new ComboBox();
            ComboBoxItem lowPriority      = new ComboBoxItem();

            lowPriority.Content = "Low";
            ComboBoxItem mediumPriority = new ComboBoxItem();

            mediumPriority.Content = "Medium";
            ComboBoxItem highPriority = new ComboBoxItem();

            highPriority.Content = "High";
            priorityComboBox.Items.Add(lowPriority);
            priorityComboBox.Items.Add(mediumPriority);
            priorityComboBox.Items.Add(highPriority);
            switch (listPriority)
            {
            case "Low":
                priorityComboBox.SelectedIndex = 0;
                break;

            case "Medium":
                priorityComboBox.SelectedIndex = 1;
                break;

            case "High":
                priorityComboBox.SelectedIndex = 2;
                break;
            }
            newStackPanel.Children.Add(priorityComboBox);

            newStackPanel.Children.Add(new Separator()
            {
                Visibility = Visibility.Hidden
            });

            Button addTaskButton = new Button();

            addTaskButton.Click              += AddTaskButton_Click;
            addTaskButton.Content             = "+";
            addTaskButton.Width               = 20;
            addTaskButton.Height              = 20;
            addTaskButton.HorizontalAlignment = HorizontalAlignment.Left;
            addTaskButton.Margin              = new Thickness(10, 0, 0, 0);
            addTaskButton.Tag = newStackPanel;
            newStackPanel.Tag = newProjectList.Id;
            newStackPanel.Children.Add(addTaskButton);

            MainStackPanel.Children.Add(newStackPanel);

            Button addNewButton = null;

            foreach (var child in MainStackPanel.Children)
            {
                if (child is Button)
                {
                    addNewButton = child as Button;
                }
            }

            // Generate tasks UI
            List <Task> tasks = DatabaseHandler.getInstance().getTasksOnList(newProjectList);

            foreach (Task task in tasks)
            {
                AddNewTaskToList(task, newStackPanel);
            }

            MainStackPanel.Children.Remove(addNewButton);
            MainStackPanel.Children.Add(addNewButton);
        }