using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; 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 HotelCalifornia { /// /// Логика взаимодействия для MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } //Перетаскивание окна private void Grid_MouseDown(object sender, MouseButtonEventArgs e) { DragMove(); } //Выход из приложения private void Close(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Вы хотите выйти из приложения?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question); switch (result) { case MessageBoxResult.Yes: Application.Current.Shutdown(); break; case MessageBoxResult.No: break; } } //Авторизация пользователя private void Vhod(object sender, RoutedEventArgs e) { try { if (logintxt.Text == "" || passwordtxt.Password == "") { MessageBox.Show("Поля не могут быть пустыми!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information); } else { Variant variant = new Variant(); this.Close(); variant.Show(); } } catch (Exception ex) { MessageBox.Show("Возникла ошибка! " + ex.ToString(),"Ошибка",MessageBoxButton.OK, MessageBoxImage.Error); } } //Запрет пробела private void logintxt_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Space) { e.Handled = true; } } //Запрет пробела private void passwordtxt_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Space) { e.Handled = true; } } //Определенные символы private void logintxt_TextChanged(object sender, TextChangedEventArgs e) { if (sender is TextBox textBox) { textBox.Text = new string (textBox.Text.Where(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')).ToArray()); } } //Определенные символы private void passwordtxt_PreviewTextInput(object sender, TextCompositionEventArgs e) { bool a = new Regex("[^A-Z]+").IsMatch(e.Text); bool b = new Regex("[^a-z]+").IsMatch(e.Text); bool c = new Regex("[^0-9]+").IsMatch(e.Text); e.Handled = a && b && c; } private void WindMin_Click(object sender, RoutedEventArgs e) { this.WindowState = WindowState.Minimized; } } }