コード例 #1
0
ファイル: EntryPoint.cs プロジェクト: stakaman21/qwinapt
        private static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // load current culture, en-US or zh-CN
            // make be can change to configalbe later.
            Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
            // load resource files
            MainForm.LocRM = new ResourceManager("WinApt.Client.WinAptStrings", typeof(MainForm).Assembly);

            SplashForm mySplash = new SplashForm();
            bool       exitFlag = false;

            mySplash.Show();
            try
            {
                //when the fisrt time run this program, exception("new") throws
                mySplash.InitApp();
            }
            catch (Exception e)
            {
                //build new config file.
                if (e.Message == "new")
                {
                    ChoseForm myChoseForm = new ChoseForm();
                    myChoseForm.ShowDialog(mySplash);
                    if (myChoseForm.DialogResult == DialogResult.OK)
                    {
                        myChoseForm.Config();
                        mySplash.InitApp();
                    }
                    myChoseForm.Close();
                }
                else
                {
                    MessageBox.Show(e.Message);
                    exitFlag = true;
                }
            }
            finally
            {
                mySplash.Close();
            }
            if (exitFlag)
            {
                return;
            }
            Application.Run(new MainForm());
        }