diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:35:25 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:35:25 +0000 |
| commit | 674ca83ba9243a9e95a7568c797668dab6aee26a (patch) | |
| tree | 4a905b3fb1d827665a34d63f67bc5559f8e7235b /Gestor.Application/Views/Generic/BaseUserControl.cs | |
| download | gestor-674ca83ba9243a9e95a7568c797668dab6aee26a.tar.gz gestor-674ca83ba9243a9e95a7568c797668dab6aee26a.zip | |
feat: upload files
Diffstat (limited to 'Gestor.Application/Views/Generic/BaseUserControl.cs')
| -rw-r--r-- | Gestor.Application/Views/Generic/BaseUserControl.cs | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/Gestor.Application/Views/Generic/BaseUserControl.cs b/Gestor.Application/Views/Generic/BaseUserControl.cs new file mode 100644 index 0000000..a389f17 --- /dev/null +++ b/Gestor.Application/Views/Generic/BaseUserControl.cs @@ -0,0 +1,104 @@ +using Gestor.Application.Helpers;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using System;
+using System.Runtime.CompilerServices;
+using System.Text.RegularExpressions;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace Gestor.Application.Views.Generic
+{
+ public class BaseUserControl : UserControl
+ {
+ public virtual TipoTela Tela
+ {
+ get;
+ set;
+ }
+
+ public BaseUserControl()
+ {
+ }
+
+ public void DataAtual_OnDoubleClick(object sender, RoutedEventArgs e)
+ {
+ ((DatePicker)sender).SelectedDate = new DateTime?(Funcoes.GetNetworkTime().Date);
+ }
+
+ public void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ DatePicker today = (DatePicker)sender;
+ today.Text = ValidationHelper.FormatDate(today.Text);
+ if (string.IsNullOrEmpty(today.Text))
+ {
+ today.DisplayDate = DateTime.Today;
+ }
+ }
+
+ public void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key != Key.Return)
+ {
+ return;
+ }
+ DatePicker str = (DatePicker)sender;
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ str.Text = date.ToString("dd/MM/yyyy");
+ }
+
+ public virtual void FormatarDocumento(object sender, RoutedEventArgs e)
+ {
+ TextBox textBox = (TextBox)sender;
+ textBox.Text = ValidationHelper.FormatDocument(textBox.Text);
+ }
+
+ public virtual void FormatarTelefone(object sender, RoutedEventArgs e)
+ {
+ TextBox textBox = (TextBox)sender;
+ if (string.IsNullOrWhiteSpace(textBox.Text))
+ {
+ return;
+ }
+ textBox.Text = ValidationHelper.FormatarTelefone(textBox.Text);
+ }
+
+ public virtual void LetrasHabilitacao(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^a-eA-E]+");
+ e.Handled = regex.IsMatch(e.Text);
+ }
+
+ public virtual void Placa(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^a-zA-Z0-9]+");
+ e.Handled = regex.IsMatch(e.Text);
+ }
+
+ public void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
+ {
+ ScrollViewer scrollViewer = (ScrollViewer)sender;
+ scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset - (double)e.Delta);
+ e.Handled = true;
+ }
+
+ public void SomenteCaracteres(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^a-zA-Z]+$");
+ e.Handled = regex.IsMatch(e.Text);
+ }
+
+ public void SomenteData(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^0-9/-]+");
+ e.Handled = regex.IsMatch(e.Text);
+ }
+
+ public virtual void SomenteNumeros(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^0-9]+");
+ e.Handled = regex.IsMatch(e.Text);
+ }
+ }
+}
\ No newline at end of file |