using System.Text.RegularExpressions; using System.Windows; using System.Windows.Input; using Livia.ViewModels; namespace Livia.Views.Controls; /// /// Interaction logic for PagingControl.xaml /// public partial class PagingControl { public PagingControl() { InitializeComponent(); } private async void FirstButtonClick(object sender, RoutedEventArgs e) { await ((PagingControlViewModel)DataContext).First(); } private async void PreviousButtonClick(object sender, RoutedEventArgs e) { await ((PagingControlViewModel)DataContext).Previous(); } private async void NextButtonClick(object sender, RoutedEventArgs e) { await ((PagingControlViewModel)DataContext).Next(); } private async void LastButtonClick(object sender, RoutedEventArgs e) { await ((PagingControlViewModel)DataContext).Last(); } private async void PageBoxKeyDown(object sender, KeyEventArgs e) { if (e.Key != Key.Return) return; CurrentPageTextBox.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); await((PagingControlViewModel)DataContext).Refresh(); } private void PageBoxOnPreview(object sender, TextCompositionEventArgs e) { Regex regex = new("[^0-9]+"); e.Handled = regex.IsMatch(e.Text); } }