using System;
using System.Collections.Generic;
using System.Collections.Specialized;
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.Shapes;

namespace InteractiveKiosk
{
    /// <summary>
    /// Interaction logic for AuthorizationWindow.xaml
    /// </summary>
    public partial class AuthorizationWindow : Window
    {
        InteractiveKioskEntities db = new InteractiveKioskEntities();
        public AuthorizationWindow()
        {
            InitializeComponent();
        }

        private void LoginButton(object sender, RoutedEventArgs e)
        {
            if (Login.Text == "" || Password.Password == "")
            {
                MessageBox.Show("Введено неверное значение!");
                return;
            }
            if (db.ParkManagers.Select(item => item.Username + " " + item.Password).Contains(Login.Text + " " + Password.Password))
            {
                MessageBox.Show("Добро пожаловать, вы авторизированы");
                this.Close();
            }
            else
            {
                MessageBox.Show("Введено неверное значение логина/пароля");
            }
        }

        private void MinButton_MouseDown(object sender, MouseButtonEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void ExitButton_MouseDown(object sender, MouseButtonEventArgs e)
        {
            this.Close();
        }

        private void Authorization_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                this.DragMove();
            }
        }

        private void OnPasswordChanged(object sender, RoutedEventArgs e)
        {
            if(Password.Password.Length > 0)
            {
                Watermark.Visibility = Visibility.Collapsed;     
            }
            else
            {
                Watermark.Visibility = Visibility.Visible;
            }
        }

        private void PasswordChecked(object sender, RoutedEventArgs e)
        {
            if (Password.Password.Length > 0)
            {
                Password.Visibility = Visibility.Visible;
            }
            
        }

    }
}
