SearchContent.xaml.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using PDF_Office.CustomControl;
  2. using PDF_Office.Model.BOTA;
  3. using PDF_Office.ViewModels.BOTA;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.ComponentModel;
  8. using System.Linq;
  9. using System.Runtime.CompilerServices;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows;
  13. using System.Windows.Controls;
  14. using System.Windows.Data;
  15. using System.Windows.Documents;
  16. using System.Windows.Input;
  17. using System.Windows.Media;
  18. using System.Windows.Media.Imaging;
  19. using System.Windows.Navigation;
  20. using System.Windows.Shapes;
  21. namespace PDF_Office.Views.BOTA
  22. {
  23. /// <summary>
  24. /// SearchContent.xaml 的交互逻辑
  25. /// </summary>
  26. public partial class SearchContent : UserControl
  27. {
  28. public SearchContent()
  29. {
  30. InitializeComponent();
  31. }
  32. private void TextBox_KeyDown(object sender, KeyEventArgs e)
  33. {
  34. if (e.Key==Key.Enter)
  35. {
  36. TextBox text = e.Source as TextBox;
  37. if (text==null)
  38. {
  39. return;
  40. }
  41. (DataContext as SearchContentViewModel).SearchText(text.Text);
  42. }
  43. }
  44. /// <summary>
  45. /// 控制收起与展开
  46. /// </summary>
  47. private void BtnExptend_Click(object sender, RoutedEventArgs e)
  48. {
  49. var btn = sender as CustomIconToggleBtn;
  50. if (btn == null) return;
  51. var item = (sender as FrameworkElement).DataContext as CollectionViewGroup;
  52. if (item != null)
  53. {
  54. foreach (object item2 in item.Items)
  55. {
  56. SearchItem searchItem = item2 as SearchItem;
  57. if (searchItem.TextProperty.ItemVisibility==Visibility.Visible)
  58. {
  59. searchItem.TextProperty.ItemVisibility = Visibility.Collapsed;
  60. }
  61. else
  62. {
  63. searchItem.TextProperty.ItemVisibility = Visibility.Visible;
  64. }
  65. }
  66. }
  67. }
  68. private void Create_Click(object sender, RoutedEventArgs e)
  69. {
  70. MenuItem menuItem= sender as MenuItem;
  71. if (menuItem==null)
  72. {
  73. return;
  74. }
  75. foreach (object item in SearchResultList.SelectedItems)
  76. {
  77. (DataContext as SearchContentViewModel).CreateAnnotate(item, menuItem.Tag.ToString());
  78. }
  79. }
  80. private void TextBoxEx_Initialized(object sender, EventArgs e)
  81. {
  82. var btn = sender as TextBoxEx;
  83. if (btn != null)
  84. {
  85. btn.ContextMenu = null;
  86. }
  87. }
  88. private void PathButton_Click(object sender, RoutedEventArgs e)
  89. {
  90. ContextSearchText.PlacementTarget = SearchText;
  91. ContextSearchText.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
  92. ContextSearchText.IsOpen = true;
  93. }
  94. private void MenuItem_Click(object sender, RoutedEventArgs e)
  95. {
  96. }
  97. }
  98. }