using Esoft.Pages;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
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 Esoft
{
    /// <summary>
    /// Логика взаимодействия для MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            MainFrame.Navigate(new Pages.General());
            //ImportUsers();
        }
        //private void ImportUsers()
        //{
        //    var fileData = File.ReadAllLines(@"C:\Users\Desktop\user.txt");
        //    foreach (var line in fileData)
        //    {
        //        var data = line.Split('\t');

        //        var tempUser = new User
        //        {
        //            Password = data[0].Replace("\"", ""),
        //            FirstName = data[1].Replace("\"", ""),
        //            MiddleName = data[2].Replace("\"", ""),
        //            LastName = data[3].Replace("\"", ""),
        //            Login = data[4].Replace("\"", ""),
        //            IsDeleted = (data[5] == "0") ? true : false
        //        };
        //        user6Entities.GetContext().User.Add(tempUser);
        //        user6Entities.GetContext().SaveChanges();
        //    }

        //    MessageBox.Show("Данные импортированы");
        //}


        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed) { DragMove(); }
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void btnMinimize_Click(object sender, RoutedEventArgs e)
        {
            WindowState = WindowState.Minimized;
        }

        private void AccExit_Click(object sender, RoutedEventArgs e)
        {
            //if (MessageBox.Show("Вы уверены, что хотите выйти из аккаунта ESOFT?", "Выйти", MessageBoxButton.YesNo, MessageBoxImage.Question)==MessageBoxResult.Yes)
            //{
            //    Pages.Authorization authorization = new Pages.Authorization();
            //    authorization.Show();
            //    this.Close();
            //}

            //Windows.AccExitWin window = new Windows.AccExitWin();
            //window.ShowDialog();
            if (MessageBox.Show("Вы собираетесь выйти из аккаунта ESOFT. Вам потребуется заново ввести ваши логин и пароль, чтобы снова войти в ESOFT", "Выйти", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                Pages.Authorization authorization = new Pages.Authorization();

                authorization.Show();

                this.Close();

            }

        }

        private void General_Click(object sender, RoutedEventArgs e)
        {
            MainFrame.Navigate(new Pages.General());
        }

        private void TaskList_Click(object sender, RoutedEventArgs e)
        {
            MainFrame.Navigate(new Pages.TaskList());
        }

        private void Chart_Click(object sender, RoutedEventArgs e)
        {
            //MainFrame.Navigate(new Pages.Chart());
            Pages.Diagram diagram = new Pages.Diagram();
            //this.IsEnabled = false;
            diagram.Owner = this;
            diagram.Show();
        }
    }
}
