using CollaborativePlatformMain.Util;
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 CollaborativePlatformMain
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            //窗体居中
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
        }

        /// <summary>
        /// 登陆
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoginLayButton_Click(object sender, RoutedEventArgs e)
        {
            //获取用户名和密码
            string userName = tb_userName.Text;
            string userPwd = tb_userPwd.Text;

            //验证登陆
            if (LoginUtil.VerifyLoginMethod(userName, userPwd))
            {
               // HomepageForm homepageForm = new HomepageForm();
                //homepageForm.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("用户名或密码错误！", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.None);
            }
        }

        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RegisterLayButton_Click(object sender, RoutedEventArgs e)
        {

        }


        /// <summary>
        /// 临时登陆按下
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TemporaryLogin_Click(object sender, RoutedEventArgs e)
        {
            sp_Login.Visibility = Visibility.Collapsed;
            sp_Register.Visibility = Visibility.Collapsed;
            sp_temporaryLogin.Visibility = Visibility.Visible;
        }
        /// <summary>
        /// 临时登陆-确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TemporaryLogin2_Click(object sender, RoutedEventArgs e)
        {
            List<string> temporaryLogins = new List<string>() { "550632" };

            if (!string.IsNullOrEmpty(tb_InvitationCode.Text) && temporaryLogins.Contains(tb_InvitationCode.Text))
            {
                //HomepageForm homepageForm = new HomepageForm();
                //homepageForm.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("邀请码错误！", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.None);
            }
        }

    }
}
