CPDFSearchInputUI.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Input;
  5. namespace Compdfkit_Tools.PDFControlUI
  6. {
  7. public partial class CPDFSearchInputUI : UserControl
  8. {
  9. public event EventHandler<string> SearchEvent;
  10. public event EventHandler ClearEvent;
  11. public string SearchKeyWord
  12. {
  13. get
  14. {
  15. return SearchTextBox.Text;
  16. }
  17. set
  18. {
  19. SearchTextBox.Text = value;
  20. }
  21. }
  22. public double InputTextBoxWidth
  23. {
  24. get
  25. {
  26. return SearchTextBox.Width;
  27. }
  28. set
  29. {
  30. SearchTextBox.Width = value;
  31. }
  32. }
  33. public double InputTextBoxHeight
  34. {
  35. get
  36. {
  37. return SearchTextBox.Height;
  38. }
  39. set
  40. {
  41. SearchTextBox.Height = value;
  42. }
  43. }
  44. public CPDFSearchInputUI()
  45. {
  46. InitializeComponent();
  47. }
  48. private void SearchTextBox_KeyDown(object sender, KeyEventArgs e)
  49. {
  50. if (e.Key == Key.Enter && string.IsNullOrEmpty(SearchKeyWord)==false)
  51. {
  52. SearchEvent?.Invoke(this, SearchKeyWord);
  53. }
  54. }
  55. private void TextClear_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  56. {
  57. SearchKeyWord = string.Empty;
  58. ClearEvent?.Invoke(this,new EventArgs());
  59. }
  60. private void SearchBtn_Click(object sender, RoutedEventArgs e)
  61. {
  62. if (string.IsNullOrEmpty(SearchKeyWord) == false)
  63. {
  64. SearchEvent?.Invoke(this, SearchKeyWord);
  65. }
  66. }
  67. }
  68. }