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