Exemple #1
0
        private void Form1_Load(object sender, EventArgs e)     //Form1_Load
        {
            if (!Variable.allowBakRes)
            {
                button24.Enabled = false;
                button25.Enabled = false;
            }
            //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);   //If crush, call CrushHandler

            //寫入目前LoLToolsX版本到Log
            Logger.log("LoLToolsX版本: " + Application.ProductVersion, Logger.LogType.Info);

            Logger.log("目前客戶端 : 台服", Logger.LogType.Info);
            //載入LoLToolsX Logo
            PictureBox1.ImageLocation = Application.StartupPath + @"\logo.png";
            Logger.log("LoLToolsX Logo載入成功!", Logger.LogType.Info);

            if (Variable.forceSelectPath)
            {
                goto SelectPath;
            }

            //取得LoL路徑
            GetReg gr = new GetReg();

            installPath = gr.TwPath(Application.StartupPath + @"\config.ini");
            Logger.log("LoL目錄取得成功! " + installPath, Logger.LogType.Info);

SelectPath:
            CFGFile CFGFile = new CFGFile(Application.StartupPath + @"\config.ini");

            //檢查路徑是否存有 LoLTW 字串
            if (!installPath.Contains("LoLTW"))
            {
                if (MessageBox.Show("無法取得LoL目錄 請手動選擇LoLTW目錄", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                {
                    folderBrowserDialog1.ShowDialog();
                    Logger.log("LoL手動選擇目錄! ", Logger.LogType.Info);
                    if (folderBrowserDialog1.SelectedPath.Contains("LoLTW"))
                    {
                        installPath = folderBrowserDialog1.SelectedPath;
                        Logger.log("LoL目錄檢查成功! " + installPath, Logger.LogType.Info);
                        CFGFile.SetValue("LoLPath", "TwPath", "\"" + installPath + "\"");
                        CFGFile.SetValue("LoLToolsX", "Version", Application.ProductVersion.ToString());
                    }
                    else
                    {
                        MessageBox.Show("目錄選擇錯誤 按確定退出程式", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Logger.log("LoL目錄檢查失敗 ", Logger.LogType.Error);
                        Logger.log("強制關閉程式... ", Logger.LogType.Info);
                        Application.Exit();
                    }
                }
                else
                {
                    Logger.log("LoL目錄選擇取消 ", Logger.LogType.Error);
                    Logger.log("關閉程式... " + installPath, Logger.LogType.Info);
                    Application.Exit();
                }
            }
            else
            {
                CFGFile.SetValue("LoLPath", "TwPath", "\"" + installPath + "\"");
                CFGFile.SetValue("LoLToolsX", "Version", Application.ProductVersion.ToString());
                PathLabel.Text = installPath;
                Logger.log("LoL目錄檢查成功! ", Logger.LogType.Info);
                Logger.log("LoL目錄寫入成功! " + installPath, Logger.LogType.Info);
            }

            //CFGFile = null;

            if (Variable.allowUpdate)
            {
                //CFGFile checkAutoUpdate = new CFGFile(Application.StartupPath + @"\config.ini");
                if (CFGFile.GetValue("LoLToolsX", "AutoUpdate") == "true")
                {
                    Variable.updating      = true;
                    this.checkBox1.Checked = false;
                    Thread updateThread = new Thread(CheckUpdate.checkUpdate);
                    //開始檢查更新
                    updateThread.Start();
                }
                else
                {
                    this.checkBox1.Checked = true;
                }
            }
            else
            {
                button23.Enabled = false;
            }

            //檢查語言檔更新
            //Thread langUpdate = new Thread(LangUpdate.CheckLangUpdate);
            //langUpdate.Start();

            //string test = Application.StartupPath;
            //MessageBox.Show(test);

            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            //取得目前伺服器
            CheckProp cp = new CheckProp();

            cp.CheckPropFL(installPath);
            serverLocation.Text = cp.currentLoc;

            notifyIcon1.Visible = false;
            PathLabel.Text      = installPath;

            //取得版本資訊
            toolsVersion.Text    = Application.ProductVersion.ToString();
            LoLVersionLabel.Text = GetLoLVer();



            //在綫統計使用人數
            try
            {
                WebBrowser1.Navigate("http://nitroxenon.com/loltoolsx/stat.html");
            }
            catch (Exception e2)
            {
                Logger.log("使用人數統計失敗", Logger.LogType.Error);
                Logger.log(e2);
            }

            //刪除物件
            cp = null;
            gr = null;


            string[] skins = File.ReadAllLines(Application.StartupPath + @"\Skin.txt");
            foreach (string s in skins)
            {
                installedSkin.Items.Add(s);
            }

            //Variable.tw_installPath = installPath;
            Variable.curClient = "台服";
        }
        private void VerSelect_Load(object sender, EventArgs e)
        {
            CFGFile CFGFile = new CFGFile(Variable.CurrentDirectory + @"\config.ini");

            //取得LoL路徑
            GetReg gr = new GetReg();

            installPath = gr.NaPath(Variable.CurrentDirectory + @"\config.ini");
            Logger.log("LoL目錄取得成功! " + installPath, Logger.LogType.Info);



            //檢查路徑是否存有 LoLTW 字串
            if (!installPath.Contains("League of Legends"))
            {
                if (MessageBox.Show("無法取得LoL目錄 請手動選擇 League of Legends 目錄", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                {
                    folderBrowserDialog1.ShowDialog();
                    Logger.log("LoL手動選擇目錄! ", Logger.LogType.Info);
                    if (folderBrowserDialog1.SelectedPath.Contains("League of Legends"))
                    {
                        installPath = folderBrowserDialog1.SelectedPath;
                        Logger.log("LoL目錄檢查成功! " + installPath, Logger.LogType.Info);

                        CFGFile.SetValue("LoLPath", "NaPath", "\"" + installPath + "\"");
                        CFGFile.SetValue("LoLToolsX", "Version", Application.ProductVersion.ToString());
                        Logger.log("LoL目錄檢查成功! ", Logger.LogType.Info);
                        Logger.log("LoL目錄寫入成功! " + installPath, Logger.LogType.Info);

                        string[] folder = Directory.GetDirectories(installPath + @"\RADS\projects\lol_air_client\releases");
                        foreach (string f in folder)
                        {
                            airBox.Items.Add(Path.GetFileName(f));
                        }

                        string[] folder2 = Directory.GetDirectories(installPath + @"\RADS\projects\lol_game_client\releases");
                        foreach (string f in folder2)
                        {
                            gameBox.Items.Add(Path.GetFileName(f));
                        }
                        Variable.n_installPath = this.installPath;
                    }
                    else
                    {
                        MessageBox.Show("目錄選擇錯誤 按確定退出程式", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Logger.log("LoL目錄檢查失敗 ", Logger.LogType.Error);
                        Logger.log("強制關閉程式... ", Logger.LogType.Info);
                        Application.Exit();
                    }
                }
                else
                {
                    Logger.log("LoL目錄選擇取消 ", Logger.LogType.Error);
                    Logger.log("關閉程式... " + installPath, Logger.LogType.Info);
                    Application.Exit();
                }
            }
            else
            {
                CFGFile.SetValue("LoLPath", "NaPath", "\"" + installPath + "\"");
                CFGFile.SetValue("LoLToolsX", "Version", Application.ProductVersion.ToString());
                Logger.log("LoL目錄檢查成功! ", Logger.LogType.Info);
                Logger.log("LoL目錄寫入成功! " + installPath, Logger.LogType.Info);

                string[] folder = Directory.GetDirectories(installPath + @"\RADS\projects\lol_air_client\releases");
                foreach (string f in folder)
                {
                    airBox.Items.Add(Path.GetFileName(f));
                }

                string[] folder2 = Directory.GetDirectories(installPath + @"\RADS\projects\lol_game_client\releases");
                foreach (string f in folder2)
                {
                    gameBox.Items.Add(Path.GetFileName(f));
                }
                Variable.n_installPath = this.installPath;
            }
        }