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

namespace DontHarmDesktop.Pages
{
    /// <summary>
    /// Логика взаимодействия для AuthPage.xaml
    /// </summary>
    public partial class AuthPage : Page
    {
        public AuthPage()
        {
            InitializeComponent();
        }

        private void TogglePasswordButton_MouseDown(object sender, MouseButtonEventArgs e)
        {
            ShowPasswordTextBox.Text = PasswordPasswordBox.Password;
            PasswordPasswordBox.Visibility = Visibility.Collapsed;
            ShowPasswordTextBox.Visibility = Visibility.Visible;
        }

        private void TogglePasswordButton_MouseUp(object sender, MouseButtonEventArgs e)
        {
            PasswordPasswordBox.Visibility = Visibility.Visible;
            ShowPasswordTextBox.Visibility = Visibility.Collapsed;
        }

        private void AuthorizeButton_Click(object sender, RoutedEventArgs e)
        {
            var success = App.LogOn(LoginTextBox.Text, PasswordPasswordBox.Password);
            if (success)
            {
                NavigationService.Navigate(new WelcomePage());
            } else { 
                MessageBox.Show("Введённые логин или пароль неверны");
            }
        }
    }
}
