CPDFSearchInputUI.xaml.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 enum MoveDirection
  10. {
  11. Previous = 0,
  12. Next = 1
  13. };
  14. public event EventHandler<string> SearchEvent;
  15. public event EventHandler ClearEvent;
  16. public event EventHandler<MoveDirection> MoveResultEvent;
  17. public string SearchKeyWord
  18. {
  19. get
  20. {
  21. return SearchTextBox.Text;
  22. }
  23. set
  24. {
  25. SearchTextBox.Text = value;
  26. }
  27. }
  28. public string ReplaceWord
  29. {
  30. get
  31. {
  32. return ReplaceTextBox.Text;
  33. }
  34. set
  35. {
  36. ReplaceTextBox.Text = value;
  37. }
  38. }
  39. public double InputTextBoxWidth
  40. {
  41. get
  42. {
  43. return SearchTextBox.Width;
  44. }
  45. set
  46. {
  47. SearchTextBox.Width = value;
  48. ReplaceTextBox.Width = value;
  49. }
  50. }
  51. public double InputTextBoxHeight
  52. {
  53. get
  54. {
  55. return SearchTextBox.Height;
  56. }
  57. set
  58. {
  59. SearchTextBox.Height = value;
  60. ReplaceTextBox.Height = value;
  61. }
  62. }
  63. public CPDFSearchInputUI()
  64. {
  65. InitializeComponent();
  66. }
  67. private void SearchTextBox_KeyDown(object sender, KeyEventArgs e)
  68. {
  69. if (e.Key == Key.Enter && string.IsNullOrEmpty(SearchKeyWord)==false)
  70. {
  71. SearchEvent?.Invoke(this, SearchKeyWord);
  72. }
  73. }
  74. private void TextClear_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  75. {
  76. SearchKeyWord = string.Empty;
  77. ClearEvent?.Invoke(this,new EventArgs());
  78. }
  79. private void SearchBtn_Click(object sender, RoutedEventArgs e)
  80. {
  81. if (string.IsNullOrEmpty(SearchKeyWord) == false)
  82. {
  83. SearchEvent?.Invoke(this, SearchKeyWord);
  84. }
  85. }
  86. private void ReplaceTextClear_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  87. {
  88. ReplaceTextBox.Text = string.Empty;
  89. }
  90. private void Previous_Click(object sender, RoutedEventArgs e)
  91. {
  92. MoveResultEvent?.Invoke(this,MoveDirection.Previous);
  93. }
  94. private void Next_Click(object sender, RoutedEventArgs e)
  95. {
  96. MoveResultEvent?.Invoke(this,MoveDirection.Next);
  97. }
  98. }
  99. }