using Autodesk.AutoCAD.EditorInput;
using CollaborativePlatformMain.CADStartUtil;
using CollaborativePlatformMain.Form;
using CollaborativePlatformMain.Util;
using DFBIM.CADNETCommon.ExtensionMethod;
using DFBIM.CADNETCommon.ReconStruct;
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)
        {
            sp_Login.Visibility = Visibility.Collapsed;
            sp_Register.Visibility = Visibility.Visible;
            sp_temporaryLogin.Visibility = Visibility.Collapsed;
        }


        /// <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>() { "123456" };

            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);
            }
        }

        /// <summary>
        /// 注册事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LayButton_Click(object sender, RoutedEventArgs e)
        {
            //账号
            string name = tb_rguserName.Text.ToString();
            //密码
            string pwd1 = tb_rguserPwd.Text.ToString();
            //确认密码
            string pwd2 = tb_rgconuserPwd.Text.ToString();

            if (name == string.Empty)
            {
                MessageBox.Show("账号不允许为空！", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.None);
            }
            if (pwd1 == string.Empty || pwd2 == string.Empty)
            {
                MessageBox.Show("密码不允许为空！", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.None);
            }
            if (pwd1 != pwd2)
            {
                MessageBox.Show("两次密码不一致，请检查！", "提示", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.None);
            }

            HomepageForm homepageForm = new HomepageForm();
            homepageForm.Show();
            this.Close();
        }


        /// <summary>
        /// 启动CAD测试
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            StartCADUtil.StartCADMath(true);
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            StartCADUtil.StartCADMath(false,new OpenDrawPathData(true, @"C:\Users\jiantu\Desktop\Drawing2.dwg"));
        }
    }
}
