/// <summary> /// Event handler for when listboxitems are double clicked/edit window trigger. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void item_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ListBoxItem listBoxItem = sender as ListBoxItem; string[] contentStr = listBoxItem.Content.ToString().Split('|'); ToDo existingToDo = new ToDo(); //Populate existing to do item with parameters extracted from selected item content existingToDo.Name = contentStr[0]; existingToDo.Description = contentStr[1]; if (contentStr[2] == " Due: ") { contentStr[2] = null; } else { existingToDo.DueDate = DateTime.Parse(contentStr[2].Replace("Due:", "")); } if (listBoxItem.Background == Brushes.Green) { existingToDo.Completed = true; } else { existingToDo.Completed = false; } existingToDo.Id = Guid.Parse(listBoxItem.Tag.ToString()); UpdateWindow editWindow = new UpdateWindow(TDList.Update.Edit, existingToDo); editWindow.ShowDialog(); MainList.Edit(editWindow.UtoDo); Refresh(); }
/// <summary> /// Add new to do item. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewTaskBtn_Click(object sender, RoutedEventArgs e) { UpdateWindow UpdateWindow = new UpdateWindow(TDList.Update.Add); UpdateWindow.ShowDialog(); MainList.Add(UpdateWindow.UtoDo); Refresh(); }