private void button14_Click(object sender, EventArgs e)
        {
            UtilValues.DownloadInfo info = new UtilValues.DownloadInfo();
            info.FileName = setInfo.sid.ToString() + " " + setInfo.artist + " - " + setInfo.title + ".png";
            info.FileName = StaticUtilFunctions.RenameFile(info.FileName);
            info.URL      = "https://txy1.sayobot.cn/maps/bg/" + setInfo.beatmapInfos[0].img_base64;
            info.type     = UtilValues.DownloadFileType.PicFile;
            Thread DownloadThread = new Thread(new ParameterizedThreadStart(StaticUtilFunctions.DownloadFile));

            DownloadThread.Start(info);
            DownloadThread.DisableComObjectEagerCleanup();
        }
        private void button12_Click(object sender, EventArgs e)
        {
            UtilValues.DownloadInfo info = new UtilValues.DownloadInfo();
            info.URL      = "https://txy1.sayobot.cn/maps/audio/" + setInfo.sid.ToString();
            info.FileName = setInfo.sid.ToString() + " " + setInfo.artist + " - " + setInfo.title + ".mp3";
            info.FileName = StaticUtilFunctions.RenameFile(info.FileName);
            info.type     = UtilValues.DownloadFileType.MusicFile;
            Thread DownloadThread = new Thread(new ParameterizedThreadStart(StaticUtilFunctions.DownloadFile));

            PublicControlers.notifyIcon.ShowBalloonTip(500, "SayobotMapDownloader", info.FileName + "开始下载", ToolTipIcon.Info);
            DownloadThread.Start(info);
            DownloadThread.DisableComObjectEagerCleanup();
        }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 4 && e.ColumnIndex != 5)
            {
                return;
            }
            string sid         = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
            string TitleArtist = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();

            if (dataGridView1.Columns[e.ColumnIndex].Name == "DownloadButton" && e.RowIndex >= 0 &&
                ((DataGridViewButtonCell)dataGridView1.CurrentCell).FormattedValue.ToString() == "√")
            {
                UtilValues.DownloadInfo info = new UtilValues.DownloadInfo();
                vCell            = (DataGridViewButtonCell)dataGridView1.CurrentCell;
                info.FileName    = sid + " " + StaticUtilFunctions.RenameFile(TitleArtist) + ".osz";
                info.URL         = "https://osu.sayobot.cn/osu.php?s=" + sid + ".osz";
                info.ClickedCell = (DataGridViewButtonCell)dataGridView1.CurrentCell;
                info.type        = UtilValues.DownloadFileType.BeatmapFile;
                Thread DownloadThread = new Thread(new ParameterizedThreadStart(StaticUtilFunctions.DownloadFile));
                notifyIcon1.ShowBalloonTip(500, "SayobotMapDownloader", info.FileName + "开始下载", ToolTipIcon.Info);
                DownloadThread.Start(info);
                DownloadThread.DisableComObjectEagerCleanup();
            }
            else if (dataGridView1.Columns[e.ColumnIndex].Name == "Listening" && e.RowIndex >= 0 &&
                     ((DataGridViewButtonCell)dataGridView1.CurrentCell).FormattedValue.ToString() == "▶")
            {
                vCell = (DataGridViewButtonCell)dataGridView1.CurrentCell;
                for (int tmp = 0; tmp < dataGridView1.RowCount; tmp++)
                {
                    dataGridView1.Rows[tmp].Cells[5].Value = "▶";
                }
                axWindowsMediaPlayer1.URL = "https://txy1.sayobot.cn/preview/" + sid + ".mp3";
                vCell.Value = "■";
                vCell.Tag   = true;
            }
            else if (dataGridView1.Columns[e.ColumnIndex].Name == "Listening" && e.RowIndex >= 0 &&
                     vCell.FormattedValue.ToString() == "■")
            {
                vCell       = (DataGridViewButtonCell)dataGridView1.CurrentCell;
                vCell.Value = "▶";
                vCell.Tag   = true;
                axWindowsMediaPlayer1.URL = "";
            }
        }
        public static void DownloadFile(object Info)
        {
            UtilValues.DownloadInfo downloadInfo = (UtilValues.DownloadInfo)Info;
            DataGridViewButtonCell  ClickedCell  = null;

            if (downloadInfo.type == UtilValues.DownloadFileType.BeatmapFile)
            {
                ClickedCell = downloadInfo.ClickedCell;
            }
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | (SecurityProtocolType)3072;
            ServicePointManager.ServerCertificateValidationCallback += CheckValidationResult;
            string          CertificateFilePath = Directory.GetCurrentDirectory() + "\\Resources\\crt.cer";
            X509Certificate cert        = new X509Certificate(CertificateFilePath);
            string          MapFilePath = Settings.DefaultDownloadPath + "\\" + downloadInfo.FileName;
            float           precent     = 0f;

            if (ClickedCell != null)
            {
                ClickedCell.Value = "连接中...";
                ClickedCell.Tag   = true;
            }
            try
            {
                HttpWebRequest Myrq = (HttpWebRequest)WebRequest.Create(downloadInfo.URL);
                Myrq.Method    = "get";
                Myrq.KeepAlive = false;
                Myrq.UserAgent = "SayobotBeatmapDownloader(ChingC ver.)";
                Myrq.ClientCertificates.Add(cert);
                HttpWebResponse myrp                = (HttpWebResponse)Myrq.GetResponse();
                long            totalBytes          = myrp.ContentLength;
                Stream          st                  = myrp.GetResponseStream();
                Stream          so                  = new FileStream(MapFilePath, FileMode.Create);
                long            totalDownloadedByte = 0;
                byte[]          by                  = new byte[1024];
                int             osize               = st.Read(by, 0, by.Length);
                while (osize > 0)
                {
                    totalDownloadedByte = osize + totalDownloadedByte;
                    Application.DoEvents();
                    so.Write(by, 0, osize);
                    osize = st.Read(by, 0, by.Length);

                    precent = (float)totalDownloadedByte / totalBytes * 100;
                    if (ClickedCell != null)
                    {
                        ClickedCell.Value = Convert.ToString(Math.Round(precent, 2)) + "%";
                        ClickedCell.Tag   = true;
                    }
                    Application.DoEvents();
                }
                so.Close();
                st.Close();
                if (ClickedCell != null)
                {
                    ClickedCell.Value = "下载完成";
                    ClickedCell.Tag   = true;
                }
                PublicControlers.notifyIcon.ShowBalloonTip(500, "SayobotBeatmapDownloader",
                                                           downloadInfo.FileName + " 下载完成", ToolTipIcon.Info);
                if (Settings.AutoOpen)
                {
                    var processStartInfo = new ProcessStartInfo();
                    processStartInfo.FileName  = MapFilePath;
                    processStartInfo.Arguments = "";
                    Process.Start(processStartInfo);
                }
                return;
            }
            catch (System.ComponentModel.Win32Exception)
            {
                MessageBox.Show(downloadInfo.FileName + "\n" + "自动打开文件失败",
                                "SayobotBeatmapDownloader", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            catch (WebException ex)
            {
                MessageBox.Show(downloadInfo.FileName + "下载失败" + "\n" + ex.Message, "网络错误",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                if (File.Exists(MapFilePath))
                {
                    File.Delete(MapFilePath);
                }
                if (ClickedCell != null)
                {
                    ClickedCell.Value = "下载失败";
                    ClickedCell.Tag   = true;
                }
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(downloadInfo.FileName + "下载失败" + "\n" + ex.Message, "未知错误",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                if (File.Exists(MapFilePath))
                {
                    File.Delete(MapFilePath);
                }
                if (ClickedCell != null)
                {
                    ClickedCell.Value = "下载失败";
                    ClickedCell.Tag   = true;
                }
                return;
            }
        }