Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            TexList.Clear();
            ModelInfo.Clear();
            MODEL = new string[3];
            if (startGetDriveFile != true)
            {
                DriveFile.Clear();
                GetDriveFile();
            }
            try
            {
                var downloadsArr = textBox1.Text.Split(Convert.ToChar("d"));
                int.Parse(downloadsArr[downloadsArr.Length - 1]);
                td_num = downloadsArr[downloadsArr.Length - 1];
            }
            catch (Exception)
            {
                MessageBox.Show("输入的网址有误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            var save = new FolderBrowserDialog
            {
                ShowNewFolderButton = true,
                Description         = "请选择保存目录"
            };

            save.ShowDialog();
            if (save.SelectedPath == "")
            {
                return;
            }
            Invoke(ShowInfo, "", 7);
            if (!Downloadjson())
            {
                return;
            }
            path = save.SelectedPath;
            if (Mod2.Checked)
            {
                var newThread = new Thread(Start);
                newThread.SetApartmentState(ApartmentState.STA);
                newThread.Start();
            }
            else
            {
                var GetWebInfo = true;
                var Browser    = new WebBrowser
                {
                    ScriptErrorsSuppressed = true
                };
                Browser.DocumentCompleted += delegate
                {
                    GetWebInfo = false;
                };
                Browser.Navigate("https://3d.nicovideo.jp/externals/embedded?id=td" + td_num, "_self", null,
                                 "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko");

                Task.Factory.StartNew(() =>
                {
                    if (AnalyseJson())
                    {
                        if (MessageLabel.Text == "Json反序列化成功")
                        {
                            Invoke(ShowInfo, "", 10);
                            Invoke(ShowInfo, "正在等待网络响应", 0);
                            Invoke(ShowInfo, "100", 55);
                            while (GetWebInfo)
                            {
                                if (toolStripProgressBar1.Value == 100)
                                {
                                    Invoke(ShowInfo, "100", 55);
                                }
                                Thread.Sleep(10);
                                Invoke(ShowInfo, "", 5);
                            }
                            Invoke(ShowInfo, "正在下载模型数据中", 0);
                            var DownloadModel = new DownloadHelper();
                            ThreadPool.QueueUserWorkItem(obj =>
                            {
                                while (DownloadModel.DownloadStatus != "正在下载模型数据中")
                                {
                                    Invoke(ShowInfo, DownloadModel.DownloadStatus, 0);
                                    Thread.Sleep(100);
                                }
                                Invoke(ShowInfo, DownloadModel.End.ToString(), 55); Invoke(ShowInfo, DownloadModel.DownloadStatus, 0);

                                while (DownloadModel.DownloadStatus != "下载完成")
                                {
                                    Invoke(ShowInfo, DownloadModel.current.ToString(), 555);
                                    Thread.Sleep(50);
                                }
                            });
                            if (DownloadModel.DownloadFile(
                                    $"https://3d.nicovideo.jp/upload/limited_contents/td{td_num}/{MODEL[1].Replace("[1]", "")}.{MODEL[2]}",
                                    out byte[] ModelData))
                            {
                                if (Decrypt(ModelData))
                                {
                                    Invoke(ShowInfo, ModelInfo.Count.ToString(), 55);
                                    Invoke(ShowInfo, MODEL[0] + "->下载成功", 1);
                                    Invoke(ShowInfo, "正在下载贴图数据中", 0);
                                    foreach (var TexInfo in ModelInfo)
                                    {
                                        Invoke(ShowInfo, "", 5);
                                        if (new DownloadHelper().DownloadFile(
                                                $"https://3d.nicovideo.jp/upload/limited_contents/td{td_num}/{TexInfo.texurl0.Replace("[1]", "")}.{TexInfo.texurl1}",
                                                out byte[] TexData))