SearchContent.xaml.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using PDF_Office.CustomControl;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.ComponentModel;
  6. using System.Linq;
  7. using System.Runtime.CompilerServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace PDF_Office.Views.BOTA
  20. {
  21. public class TextSearchBindItem : INotifyPropertyChanged
  22. {
  23. public int ShowPageIndex { get { return BindProperty.PageIndex + 1; } set { BindProperty.PageIndex = value; } }
  24. public TextBindProperty BindProperty { get; set; }
  25. public TextSearchBindItem()
  26. {
  27. BindProperty = new TextBindProperty();
  28. }
  29. public int PageCount { get; set; }
  30. private int _pageMaxCount;
  31. public int PageMaxCount { get { return _pageMaxCount; } set { _pageMaxCount = value; OnPropertyChanged("Percent"); } }
  32. public double Percent { get { if (PageMaxCount > 0 && PageCount >= 0) return (double)PageCount / (double)PageMaxCount; return 0; } }
  33. public event PropertyChangedEventHandler PropertyChanged;
  34. protected void OnPropertyChanged([CallerMemberName] string name = null)
  35. {
  36. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
  37. }
  38. }
  39. public class TextBindProperty
  40. {
  41. public int PageIndex { get; set; }
  42. public string TextContent { get; set; }
  43. public Color HighLightColor { get; set; }
  44. public string SearchWord { get; set; }
  45. public Rect TextRect { get; set; }
  46. public int PageRotate { get; set; }
  47. }
  48. /// <summary>
  49. /// SearchContent.xaml 的交互逻辑
  50. /// </summary>
  51. public partial class SearchContent : UserControl
  52. {
  53. // private ObservableCollection<TextSearchBindItem> searchResults;
  54. public SearchContent()
  55. {
  56. InitializeComponent();
  57. // searchResults = new ObservableCollection<TextSearchBindItem>();
  58. // ICollectionView groupView = CollectionViewSource.GetDefaultView(searchResults);
  59. // groupView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(TextSearchBindItem.ShowPageIndex)));
  60. }
  61. private void SearchResultList_SelectionChanged(object sender, SelectionChangedEventArgs e)
  62. {
  63. }
  64. private void BtnExptend_Click(object sender, RoutedEventArgs e)
  65. {
  66. var btn = sender as CustomIconToggleBtn;
  67. if (btn == null) return;
  68. var item = (sender as FrameworkElement).DataContext as CollectionViewGroup;
  69. if(item != null)
  70. {
  71. foreach (var item2 in item.Items)
  72. {
  73. var item3 = item2 as TextSearchBindItem;
  74. var listBoxItem = SearchResultList.ItemContainerGenerator.ContainerFromItem(item3) as ListViewItem;
  75. if (listBoxItem != null)
  76. {
  77. if(btn.IsChecked == true)
  78. {
  79. listBoxItem.Visibility = Visibility.Collapsed;
  80. }
  81. else
  82. {
  83. listBoxItem.Visibility = Visibility.Visible;
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }