Пример #1
0
 void Bw_DoWork1(object sender, DoWorkEventArgs e)
 {
     if (Config.Beelogin)
     {
         bgWorker.ReportProgress(2);
         if (!Config.Beemod)
         {
             string fh = Beelogin.Bee_login(Config.beeurl, Config.UserName, Config.Beepsw, ip);
             if (fh != "yes")
             {
                 Ts("登录失败", "详细信息:" + fh);
                 bgWorker.ReportProgress(233);
                 return;
             }
         }
         else
         {
             var    jsondir = core.GetVersionJsonPath(ver.JarId);
             string tdir    = Beelogin.GetLeft(jsondir, "\\") + "\\config";
             if (!Directory.Exists(tdir))
             {
                 Directory.CreateDirectory(tdir);//创建文件夹
             }
             string fh = Beelogin.Beemodlogin_token(Config.beeurl, Config.UserName, Config.Beepsw, (Config.LaunchMode ? rundir + @".minecraft\config\BeeLogin.cfg" : tdir + "\\BeeLogin.cfg"), ip);
             if (fh != "yes")
             {
                 Ts("登录失败", "详细信息:" + fh);
                 bgWorker.ReportProgress(233);
             }
         }
     }
 }
Пример #2
0
        void Bw_DoWork1(object sender, DoWorkEventArgs e)
        {
            downFile = MainWindow.lostFlie;
            int max = downFile.Count;

            //   SetmaxProgressBar(max + 1);

            for (int i = 0; max > i; i++)
            {
                string filename = downFile[i];
                string dir      = Beelogin.GetLeft(downFile[i], "\\");

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);        //创建文件夹
                }
                string URL = "http://download.mcbbs.net" + Beelogin.GetRight(downFile[i], "\\libraries").Replace("\\", "/").ToString();
                //MessageBox.Show(URL);

                if (Beelogin.DownloadFile(URL, filename))
                {
                    bgWorker.ReportProgress(i);
                }

                else
                {
                    Dispatcher.Invoke(new Action(() => { ts.Text = "下载过程中出现了错误,将继续下载.出错URL:" + URL; }));
                }
                // jdt.Dispatcher.Invoke(new Action(() => { jdt.Value = i; }));
            }
        }
Пример #3
0
        void Bw_asswork(object sender, DoWorkEventArgs e)
        {
            bool newass;

            if (MainWindow.lostasset.Count != 0)
            {
                newass = true;
            }
            else
            {
                newass = false;
            }
            downFile = (newass == true ? MainWindow.lostasset : MainWindow.lostlegacyasset);
            int max = downFile.Count;

            //   SetmaxProgressBar(max + 1);
            for (int i = 0; max > i; i++)
            {
                string filename;
                string two;

                if (newass == true)
                {
                    two      = downFile[i].Substring(0, 2);
                    filename = @AppDomain.CurrentDomain.BaseDirectory + @".minecraft\assets\objects\" + two + "\\" + downFile[i];
                    //MessageBox.Show(filename);
                }
                else
                {
                    filename = @AppDomain.CurrentDomain.BaseDirectory + @".minecraft\assets\" + downFile[i];
                }
                string dir = Beelogin.GetLeft(filename, "\\");
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);//创建文件夹
                }
                string URL = "http://download.mcbbs.net/" + (newass == true ? "assets" : "resources") + "/" + (newass == true ? $"{downFile[i].Substring(0, 2)}/" : "") + downFile[i].Replace("\\", "/");

                try
                {
                    if (Beelogin.DownloadFile(URL, filename) == true)
                    {
                        bgWorker.ReportProgress(i);
                    }
                }
                catch
                {
                    Dispatcher.Invoke(new Action(() => { ts.Text = "下载过程中出现了错误,将继续下载.出错URL:" + URL; }));
                }
            }
        }