MultiSelector.xaml.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. namespace AIPractice.LabellerServer.WPF
  7. {
  8. /// <summary>
  9. /// Interaction logic for MultiSelector.xaml
  10. /// </summary>
  11. public partial class MultiSelector : UserControl
  12. {
  13. public event EventHandler<bool> SelectUnSelectAll;
  14. public event EventHandler Refreshed;
  15. public IEnumerable ItemsSource
  16. {
  17. get => SelectorItems.ItemsSource;
  18. set => SelectorItems.ItemsSource = value;
  19. }
  20. public DataTemplate ItemTemplate
  21. {
  22. get => SelectorItems.ItemTemplate;
  23. set => SelectorItems.ItemTemplate = value;
  24. }
  25. public string Text
  26. {
  27. get => MultiSelectorButton.Content.ToString();
  28. set => MultiSelectorButton.Content = value;
  29. }
  30. public MultiSelector()
  31. {
  32. InitializeComponent();
  33. }
  34. private void OnShowItemsClick(object sender, RoutedEventArgs e)
  35. {
  36. PART_Popup.IsOpen = true;
  37. }
  38. private void OnSelectAllChecked(object sender, RoutedEventArgs e)
  39. {
  40. OnSelectUnSelectAll(true);
  41. }
  42. private void OnSelectAllUnChecked(object sender, RoutedEventArgs e)
  43. {
  44. OnSelectUnSelectAll(false);
  45. }
  46. private void OnSelectUnSelectAll(bool e)
  47. {
  48. SelectUnSelectAll?.Invoke(this, e);
  49. }
  50. public void SelectAll()
  51. {
  52. SelectAllCheckBox.IsChecked = true;
  53. OnSelectUnSelectAll(true);
  54. }
  55. public void UnSelectAll()
  56. {
  57. SelectAllCheckBox.IsChecked = false;
  58. OnSelectUnSelectAll(false);
  59. }
  60. private void OnRefreshClick(object sender, RoutedEventArgs e)
  61. {
  62. OnRefreshed();
  63. }
  64. private void OnRefreshed()
  65. {
  66. Refreshed?.Invoke(this, EventArgs.Empty);
  67. }
  68. }
  69. }