using OMCS.Communication.Plus.Serialization;
using System;
using System.Configuration;
using System.Windows.Forms;

namespace OVCS
{
    /*
     * OVCS采用的是ESFramework通信框架和OMCS网络语音视频框架的免费版本，若想获取其它版本，请联系www.oraycn.com。
     * 
     */
    static class Program
    { 
        public static ESBasic.Loggers.FileAgileLogger Logger = new ESBasic.Loggers.FileAgileLogger(AppDomain.CurrentDomain.BaseDirectory + "AppLog.txt");
        public static MainForm MainForm;

        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            try
            {
                System.Threading.ThreadPool.SetMinThreads(50, 12);
                
                
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Oraycn.MFile.GlobalUtil.SetAuthorizedUser("FreeUser", "");
                //OMCS.GlobalUtil.SetMaxLengthOfUserID(20);
                //ESPlus.GlobalUtil.SetMaxLengthOfUserID(20);
                //bool haveRun = ESBasic.Helpers.ApplicationHelper.IsAppInstanceExist("OVCS");
                //if (haveRun)
                //{
                //    MessageBox.Show("OVCS已经在运行!");
                //    return;
                //}
                CompactPropertySerializer.SetDefault(new ExtenseCompactPropertySerializer()); 
                LoginForm form = new LoginForm();
                form.Text = ConfigurationManager.AppSettings["Title"];
                if (DialogResult.OK != form.ShowDialog())
                {
                    return;
                }              
                              
                MainForm = new MainForm();
                MainForm.Text = form.Text;
                MainForm.Show();
                MainForm.Initialize( form.MultimediaManager, form.UserID, form.RoomID); 

                Application.Run(MainForm);
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message + "\n" + ee.StackTrace);
            }
        }
    }
}
