public TaskWindow(int toDoListId, int taskId, int userId) { InitializeComponent(); _toDoListId = toDoListId; _taskId = taskId; _service = new ApplicationService(); _userId = userId; _selectedContacts = new List <Contact>(); if (taskId == 0) { Textlabel.Content = "Neuen Task hinzufügen"; } else { Textlabel.Content = "Task bearbeiten"; Task task = _service.GetTaskById(_taskId); task.TaskFininshed = _service.GetBoolFromTask(_taskId); TaskTitle.Text = task.Title; StartDate.Text = task.StartDate.ToString("d"); EndDate.Text = task.EndDate.ToString("d"); Priority.Text = task.Priority.ToString(); TaskDescription.Text = task.Description; TaskFinished.IsChecked = task.TaskFininshed; _selectedContacts.AddRange(_service.GetContactsByTaskId(_taskId)); ReloadTaskContacts(); } }
public ToDoListWindow(int userId) { InitializeComponent(); _userId = userId; _service = new ApplicationService(); List <ToDoList> toDoLists = _service.GetToDoListsByUserId(userId); ToDoListList.Items.Clear(); foreach (var toDoListItem in toDoLists) { //Zusammenbau eines Items StackPanel toDoNonCheck = new StackPanel() { Orientation = Orientation.Horizontal }; ImageAwesome image = new ImageAwesome() { Icon = FontAwesomeIcon.Close, Width = _iconWidth, Height = _iconHeight, HorizontalAlignment = HorizontalAlignment.Center }; TextBlock textBox = new TextBlock() { Text = toDoListItem.Title + " " }; toDoNonCheck.Children.Add(textBox); toDoNonCheck.Children.Add(image); StackPanel toDoCheck = new StackPanel() { Orientation = Orientation.Horizontal }; image = new ImageAwesome() { Icon = FontAwesomeIcon.Check, Width = _iconWidth, Height = _iconHeight, HorizontalAlignment = HorizontalAlignment.Center }; textBox = new TextBlock() { Text = toDoListItem.Title + " " }; toDoCheck.Children.Add(textBox); toDoCheck.Children.Add(image); TreeViewItem toDoListTitle = new TreeViewItem(); toDoListTitle.Header = toDoNonCheck; toDoListTitle.Name = "toDoList" + toDoListItem.Id.ToString(); ToDoListList.Items.Add(toDoListTitle); List <Task> tasks = _service.GetTaksByToDoListId(toDoListItem.Id); int finishedCount = 0; foreach (var task in tasks) { StackPanel taskNonCheck = new StackPanel() { Orientation = Orientation.Horizontal }; image = new ImageAwesome() { Icon = FontAwesomeIcon.Close, Width = _iconWidth, Height = _iconHeight, HorizontalAlignment = HorizontalAlignment.Center }; textBox = new TextBlock() { Text = task.Title + " " }; taskNonCheck.Children.Add(textBox); taskNonCheck.Children.Add(image); StackPanel taskCheck = new StackPanel() { Orientation = Orientation.Horizontal }; image = new ImageAwesome() { Icon = FontAwesomeIcon.Check, Width = _iconWidth, Height = _iconHeight, HorizontalAlignment = HorizontalAlignment.Center }; textBox = new TextBlock() { Text = task.Title + " " }; taskCheck.Children.Add(textBox); taskCheck.Children.Add(image); TreeViewItem taskTitle = new TreeViewItem(); taskTitle.Header = taskNonCheck; if (_service.GetBoolFromTask(task.Id)) { taskTitle.Header = taskCheck; finishedCount++; } taskTitle.Name = "task" + task.Id.ToString(); toDoListTitle.Items.Add(taskTitle); } if (finishedCount == tasks.Count && finishedCount != 0) { toDoListTitle.Header = toDoCheck; } } }