using CommonLang.Log;
using CommonLang.Property;
using CommonLang.Xml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using XmdsBattleClientBot;
using XmdsBattleClientBot.Bot;

namespace XmdsBattleClientWin32
{

    static class Program
    {
        public static bool ARG_TC { get; private set; }
        public static bool AUTO_LOGIN { get; private set; }

        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(params string[] args)
        {
            ReflectionUtil.LoadDlls(new System.IO.DirectoryInfo(Application.StartupPath));
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            HashSet<string> args_set = new HashSet<string>(args);
            if (args_set.Count > 0)
            {
                AUTO_LOGIN = true;
                ARG_TC = args_set.Contains("-tc");
            }
            var launcher = new FormLauncher();
            launcher.OnStart += Launcher_OnStart;
            Application.Run(launcher);
            //TODO 2017/1/22 CommonSecure.ConnectWS.Run(launcher);
        }
        private static void Launcher_OnStart(FormLauncher sender, XmdsBattleClientBot.BotConfig config)
        {
            var bot = new WinForm.FormBot();
            bot.FormClosed += (s2, e2) =>
            {
                sender.Close();
            };
            bot.Show();
        }

    }
}