40 lines
1 KiB
C#
40 lines
1 KiB
C#
using System.Text.RegularExpressions;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using Livia.Utility;
|
|
using Livia.ViewModels;
|
|
|
|
namespace Livia.Views.Controls;
|
|
|
|
/// <summary>
|
|
/// Interaction logic for SearchQueryInputControl.xaml
|
|
/// </summary>
|
|
public partial class SearchQueryInputControl
|
|
{
|
|
private readonly DebounceHelper _searchButtonBounceHelper;
|
|
|
|
public SearchQueryInputControl()
|
|
{
|
|
InitializeComponent();
|
|
_searchButtonBounceHelper = new DebounceHelper(TimeSpan.FromSeconds(0.5));
|
|
}
|
|
|
|
private void AgeInputPreview(object sender, TextCompositionEventArgs e)
|
|
{
|
|
Regex regex = new("[^0-9]+");
|
|
e.Handled = regex.IsMatch(e.Text);
|
|
}
|
|
|
|
private void SearchButtonClick(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!_searchButtonBounceHelper.TryFire())
|
|
return;
|
|
|
|
((SearchQueryInputControlViewModel)DataContext).Search();
|
|
}
|
|
|
|
private void ClearButtonClick(object sender, RoutedEventArgs e)
|
|
{
|
|
((SearchQueryInputControlViewModel)DataContext).Clear();
|
|
}
|
|
} |