using System; using System.Collections.Generic; using System.Linq; 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 compdfkit_tools.PDFControlUI { /// /// 搜索输入控件 /// public partial class CPDFSearchInputUI : UserControl { /// /// 搜索事件 /// public event EventHandler SearchEvent; /// /// 清除搜索输入 /// public event EventHandler ClearEvent; /// /// 搜索关键词 /// public string SearchKeyWord { get { return SearchTextBox.Text; } set { SearchTextBox.Text = value; } } /// /// 搜索输入文本框宽度 /// public double InputTextBoxWidth { get { return SearchTextBox.Width; } set { SearchTextBox.Width = value; } } /// /// 搜索输入文本框高度 /// public double InputTextBoxHeight { get { return SearchTextBox.Height; } set { SearchTextBox.Height = value; } } public CPDFSearchInputUI() { InitializeComponent(); } /// /// 输入框回车搜索 /// private void SearchTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && string.IsNullOrEmpty(SearchKeyWord)==false) { SearchEvent?.Invoke(this, SearchKeyWord); } } /// /// 清除搜索框 /// private void TextClear_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { SearchKeyWord = string.Empty; ClearEvent?.Invoke(this,new EventArgs()); } /// /// 搜索按钮点击 /// private void SearchBtn_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(SearchKeyWord) == false) { SearchEvent?.Invoke(this, SearchKeyWord); } } } }