private void Form2_Load(object sender, EventArgs e)
        {
            UtilValues.PublicValue.ProgramRunTime = 0;

            //Thread[] FormsLoad = {
            //    new Thread(new ParameterizedThreadStart(ChildForms.LoadSettingsForm)),
            //    new Thread(new ParameterizedThreadStart(ChildForms.LoadFilterForm))};
            //var waits = new EventWaitHandle[2];
            //int temp = 0;
            //foreach (Thread subThread in FormsLoad)
            //{
            //    var handler = new ManualResetEvent(false);
            //    waits[temp]=handler;
            //    subThread.Start(handler);
            //    subThread.DisableComObjectEagerCleanup();
            //}

            label1.BackColor      = Color.Transparent;
            linkLabel1.BackColor  = Color.Transparent;
            panel2.BackColor      = Color.Transparent;
            menuStrip1.BackColor  = Color.Transparent;
            panel1.BackColor      = Color.Transparent;
            menuStrip1.BackColor  = Color.Transparent;
            gmProgressBar1.XTheme = new Gdu.WinFormUI.ThemeProgressBarGreen();


            dataGridView1.Visible = false;
            string           SupportStatus     = StaticUtilFunctions.JsonGet("https://api.sayobot.cn/support");
            JavaScriptObject SupportStatusJson = (JavaScriptObject)JavaScriptConvert.DeserializeObject(SupportStatus);

            if (!SupportStatusJson.ContainsKey("data"))
            {
                MessageBox.Show("网络错误,请检查网络连接后重启程序", "SayobotBeatmapDownloader",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(-1);
            }

            JavaScriptObject Data = (JavaScriptObject)SupportStatusJson["data"];

            gmProgressBar1.Percentage = (Int32)(Convert.ToDouble(Data["total"]) / Convert.ToDouble(Data["target"]) * 100.0);
            linkLabel1.Text           = "投喂进度:$" + Data["total"].ToString() + "/$" + Data["target"].ToString();
            linkLabel1.Links.Add(0, linkLabel1.Text.Length, "https://sayobot.cn/home");


            PublicControlers.notifyIcon   = notifyIcon1;
            PublicControlers.mediaPlayer  = axWindowsMediaPlayer1;
            PublicControlers.dataGridView = dataGridView1;
            PublicControlers.mainForm     = this;
            PublicControlers.settingForm  = settingForm;
            PublicControlers.MemoryUsage  = label2;

            StaticUtilFunctions.SetFormMid(settingForm);
            StaticUtilFunctions.SetFormMid(beatmapDetailInfo);
            StaticUtilFunctions.SetFormMid(filter);

            if (File.Exists(ConfigFile.inifilepath))
            {
                ConfigFile.GetAllConfigsApply();
            }
            else
            {
                /*
                 * welcome = new Forms.Welcome();
                 * welcome.Show();
                 */
                FileStream streamtmp = File.Create(ConfigFile.inifilename);
                streamtmp.Close();
                ConfigFile.ResetAllConfigs();
            }
            if (Settings.MainFormImage != "")
            {
                StaticUtilFunctions.LoadingMainFormBackgroundPic();
            }
            StaticUtilFunctions.FindNanoPad();
            if (UtilValues.PublicValue.nanoPads.Length != 0)
            {
                notifyIcon1.ShowBalloonTip(500, "SayobotBeatmapDownloader",
                                           "发现" + UtilValues.PublicValue.nanoPads.Length.ToString() + "个触盘", ToolTipIcon.Info);
            }
            //WaitHandle.WaitAll(waits);
        }
        private void label1_TextChanged(object sender, EventArgs e)
        {
            pictureBox1.Image         = Image.FromFile(Environment.CurrentDirectory + "\\Resources\\Pics\\loading.png");
            pictureBox1.ImageLocation = "https://cdn.sayobot.cn:25225/beatmaps/" + label1.Text + "/covers/cover.jpg?0";
            string           GettedJsonString = StaticUtilFunctions.JsonGet("https://api.sayobot.cn/v2/beatmapinfo?0=" + label1.Text);
            JavaScriptObject Json             = (JavaScriptObject)JavaScriptConvert.DeserializeObject(GettedJsonString);

            if (!Json.ContainsKey("status"))
            {
                MessageBox.Show("请求API失败", "网络错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (Convert.ToInt32(Json["status"]) == -1)
            {
                MessageBox.Show("没有查询到数据", "SayobotBeatmapDownloader", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                JavaScriptObject Data = (JavaScriptObject)Json["data"];
                setInfo.approved      = Convert.ToInt16(Data["approved"]);
                setInfo.approved_date = Convert.ToInt32(Data["approved_date"]);
                setInfo.artist        = Convert.ToString(Data["artist"]);
                setInfo.beatmap_count = Convert.ToInt16(Data["bids_amount"]);
                setInfo.bpm           = Convert.ToDouble(Data["bpm"]);
                setInfo.genre         = Convert.ToInt16(Data["genre"]);
                setInfo.language      = Convert.ToInt16(Data["language"]);
                setInfo.last_update   = Convert.ToInt32(Data["last_update"]);
                setInfo.preview       = Convert.ToInt16(Data["preview"]);
                setInfo.sid           = Convert.ToInt32(Data["sid"]);
                setInfo.source        = Convert.ToString(Data["source"]);
                setInfo.storyboard    = Convert.ToInt16(Data["storyboard"]);
                setInfo.tags          = Convert.ToString(Data["tags"]);
                setInfo.title         = Convert.ToString(Data["title"]);
                setInfo.video         = Convert.ToInt16(Data["video"]);
                setInfo.favorite      = Convert.ToInt16(Data["favourite_count"]);
                JavaScriptArray mapArray = (JavaScriptArray)Data["bid_data"];
                setInfo.beatmapInfos = new System.Collections.Generic.List <BeatmapInfo>();
                for (int i = 0; i < setInfo.beatmap_count; i++)
                {
                    JavaScriptObject singleMap = (JavaScriptObject)mapArray[i];
                    BeatmapInfo      beatmap   = new BeatmapInfo
                    {
                        ar         = Convert.ToDouble(singleMap["AR"]),
                        bid        = Convert.ToInt32(singleMap["bid"]),
                        creator    = Convert.ToString(Data["creator"]),
                        cs         = Convert.ToDouble(singleMap["CS"]),
                        hp         = Convert.ToDouble(singleMap["HP"]),
                        img_base64 = Convert.ToString(singleMap["img"]),
                        maxcombo   = Convert.ToInt32(singleMap["maxcombo"]),
                        od         = Convert.ToDouble(singleMap["OD"]),
                        passcount  = Convert.ToInt32(singleMap["passcount"]),
                        playcount  = Convert.ToInt32(singleMap["playcount"]),
                        stars      = Convert.ToDouble(singleMap["star"]),
                        version    = Convert.ToString(singleMap["version"]),
                        length     = Convert.ToInt16(singleMap["length"])
                    };
                    if (beatmap.passcount != 0)
                    {
                        beatmap.passrate = Convert.ToDouble(beatmap.passcount * 100) / beatmap.playcount;
                    }
                    else
                    {
                        beatmap.passrate = 0.0D;
                    }
                    setInfo.beatmapInfos.Add(beatmap);
                }
                DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
                string[] MapStatus = { "graveyard", "WIP", "pending", "ranked", "approved", "qualified", "loved" };
                label2.Text  = setInfo.beatmapInfos[0].version;
                label23.Text = Convert.ToString(setInfo.sid);
                label24.Text = MapStatus[setInfo.approved + 2];
                label3.Text  = setInfo.artist + " - " + setInfo.title;
                button8.Text = startTime.AddSeconds(setInfo.last_update + 8 * 3600).ToString("yyyy-MM-dd HH:mm:ss");
                if (setInfo.approved_date > 0)
                {
                    button9.Text = startTime.AddSeconds(setInfo.approved_date + 8 * 3600).ToString("yyyy-MM-dd HH:mm:ss");
                }
                else
                {
                    button9.Text = "null";
                }
                button2.Text = Convert.ToString(setInfo.bpm);
                button5.Text = UtilValues.PublicValue.Language[setInfo.language];
                button6.Text = UtilValues.PublicValue.Genre[setInfo.genre];
                button7.Text = Convert.ToString(setInfo.favorite);
                toolTip1.SetToolTip(label8, setInfo.tags);
                toolTip1.SetToolTip(label12, setInfo.source);
                if (50 * setInfo.beatmap_count < 450)
                {
                    panel2.Size = new Size(50 * setInfo.beatmap_count, 32);
                }
                else
                {
                    panel2.Size = new Size(450, 32);
                }
                DrawRoundRectControl(panel2, Color.FromArgb(127, 216, 148, 139));
                displayInfo(0);
                if (!this.Visible)
                {
                    this.Show();
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && button1.Text == "搜索")
            {
                dataGridView1.Rows.Clear();
                DataTable table = new DataTable();
                table.Columns.Add("艺术家 - 标题", typeof(string));
                table.Columns.Add("sid", typeof(string));
                table.Columns.Add("谱面状态", typeof(string));
                table.Columns.Add("Mapper", typeof(string));
                string           GettedJsonString = StaticUtilFunctions.JsonGet(StaticUtilFunctions.Spawn_SearchHttpLink(textBox1.Text, 0));
                JavaScriptObject GettedJson       = (JavaScriptObject)JavaScriptConvert.DeserializeObject(GettedJsonString);
                if (!GettedJson.ContainsKey("status"))
                {
                    MessageBox.Show("请求API失败", "网络错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                else if (Convert.ToInt32(GettedJson["status"]) == -1)
                {
                    MessageBox.Show("没有查询到数据", "SayobotBeatmapDownloader", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dataGridView1.Visible = false;
                    label3.Visible        = true;
                    return;
                }
                label3.Visible = false;
                JavaScriptArray Data = (JavaScriptArray)GettedJson["data"];

                for (int tmp = 0; tmp < Data.Count; ++tmp)
                {
                    JavaScriptObject SingleMap = (JavaScriptObject)Data[tmp];
                    string           BasicInfo = SingleMap["artist"].ToString() + " - " + SingleMap["title"].ToString();
                    table.Rows.Add(BasicInfo, SingleMap["sid"].ToString(), UtilValues.PublicValue.MapStatus[Convert.ToInt32(SingleMap["approved"]) + 2], SingleMap["creator"].ToString());
                }
                while (Convert.ToInt32(GettedJson["endid"]) != 0 && table.Rows.Count < 1000)
                {
                    var offset = Convert.ToInt32(GettedJson["endid"]);
                    GettedJsonString = StaticUtilFunctions.JsonGet(StaticUtilFunctions.Spawn_SearchHttpLink(textBox1.Text, offset));
                    GettedJson       = (JavaScriptObject)JavaScriptConvert.DeserializeObject(GettedJsonString);
                    if (!GettedJson.ContainsKey("status"))
                    {
                        GettedJson.Add("endid", offset);
                        continue;
                    }
                    Data = (JavaScriptArray)GettedJson["data"];
                    for (int tmp = 0; tmp < Data.Count; ++tmp)
                    {
                        JavaScriptObject SingleMap = (JavaScriptObject)Data[tmp];
                        string           BasicInfo = SingleMap["artist"].ToString() + " - " + SingleMap["title"].ToString();
                        table.Rows.Add(BasicInfo, SingleMap["sid"].ToString(), UtilValues.PublicValue.MapStatus[Convert.ToInt32(SingleMap["approved"]) + 2], SingleMap["creator"].ToString());
                    }
                }
                if (29 + 23 * table.Rows.Count > 354)
                {
                    dataGridView1.Height = 354;
                }
                else
                {
                    dataGridView1.Height = 29 + 23 * table.Rows.Count;
                }
                foreach (DataRow row in table.Rows)
                {
                    dataGridView1.Rows.Add(row.ItemArray[0], row.ItemArray[1], row.ItemArray[2], row.ItemArray[3]);
                }
                dataGridView1.Visible = true;
                table.Clear();
                table.Dispose();
            }
            else if (textBox1.Text != "" && button1.Text == "查找")
            {
                bool flag = false;
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    for (int tmp = 0; tmp < 4; tmp++)
                    {
                        if (row.Cells[tmp].Value.ToString().Contains(textBox1.Text))
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        row.Visible = false;
                    }
                }
            }
            else if (button1.Text == "过滤器")
            {
                PublicControlers.SearchBtn = button1;
                filter.BackColor           = ColorTranslator.FromHtml(Settings.MainFormColor);
                filter.Show();
            }
        }