using PDF_Office.CustomControl; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace PDF_Office.Views.BOTA { public class TextSearchBindItem : INotifyPropertyChanged { public int ShowPageIndex { get { return BindProperty.PageIndex + 1; } set { BindProperty.PageIndex = value; } } public TextBindProperty BindProperty { get; set; } public TextSearchBindItem() { BindProperty = new TextBindProperty(); } public int PageCount { get; set; } private int _pageMaxCount; public int PageMaxCount { get { return _pageMaxCount; } set { _pageMaxCount = value; OnPropertyChanged("Percent"); } } public double Percent { get { if (PageMaxCount > 0 && PageCount >= 0) return (double)PageCount / (double)PageMaxCount; return 0; } } public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged([CallerMemberName] string name = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } } public class TextBindProperty { public int PageIndex { get; set; } public string TextContent { get; set; } public Color HighLightColor { get; set; } public string SearchWord { get; set; } public Rect TextRect { get; set; } public int PageRotate { get; set; } } /// /// SearchContent.xaml 的交互逻辑 /// public partial class SearchContent : UserControl { // private ObservableCollection searchResults; public SearchContent() { InitializeComponent(); // searchResults = new ObservableCollection(); // ICollectionView groupView = CollectionViewSource.GetDefaultView(searchResults); // groupView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(TextSearchBindItem.ShowPageIndex))); } private void SearchResultList_SelectionChanged(object sender, SelectionChangedEventArgs e) { } private void BtnExptend_Click(object sender, RoutedEventArgs e) { var btn = sender as CustomIconToggleBtn; if (btn == null) return; var item = (sender as FrameworkElement).DataContext as CollectionViewGroup; if(item != null) { foreach (var item2 in item.Items) { var item3 = item2 as TextSearchBindItem; var listBoxItem = SearchResultList.ItemContainerGenerator.ContainerFromItem(item3) as ListViewItem; if (listBoxItem != null) { if(btn.IsChecked == true) { listBoxItem.Visibility = Visibility.Collapsed; } else { listBoxItem.Visibility = Visibility.Visible; } } } } } } }