TaskPage.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using WpfApp1.Entities;
  16. namespace WpfApp1
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для TaskPage.xaml
  20. /// </summary>
  21. public partial class TaskPage : Page
  22. {
  23. public TaskPage()
  24. {
  25. InitializeComponent();
  26. LViewTasks.ItemsSource = user20Entities.GetContext().Task.ToList();
  27. var allTypes = user20Entities.GetContext().Task.ToList();
  28. allTypes.Insert(0, new WpfApp1.Entities.Task
  29. {
  30. Title = "Все типы"
  31. });
  32. ComboType.ItemsSource = allTypes;
  33. CheckDeleted.IsChecked = true;
  34. ComboType.SelectedIndex = 0;
  35. }
  36. private void TBoxSearch_TextChanged(object sender, TextChangedEventArgs e)
  37. {
  38. UpdateTasks();
  39. }
  40. private void UpdateTasks()
  41. {
  42. var searchText = TBoxSearch.Text.ToLower();
  43. var Tasks = user20Entities.GetContext().Task.ToList();
  44. var currentTasks = user20Entities.GetContext().Task.ToList();
  45. if (ComboType.SelectedIndex > 0)
  46. currentTasks = currentTasks.Where(p => p.WorkType == ComboType.SelectedItem).ToList();
  47. currentTasks = currentTasks.Where(p => p.Title.ToLower().Contains(TBoxSearch.Text.ToLower())).ToList();
  48. if (CheckDeleted.IsChecked.Value)
  49. currentTasks = currentTasks.Where(p => p.IsDeleted).ToList();
  50. }
  51. private void CheckDeleted_Checked(object sender, RoutedEventArgs e)
  52. {
  53. UpdateTasks();
  54. }
  55. private void ComboType_SelectionChanged(object sender, SelectionChangedEventArgs e)
  56. {
  57. UpdateTasks();
  58. }
  59. }
  60. }