protected override void OnLoad(EventArgs e) { base.OnLoad(e); string key = "OK_ApiTitle"; if (config.Exists(key)) { titleNames = JsonConvert.DeserializeObject <List <TitleName> >(config.GetPicCacheData(key)); } else { var jsonData = OK_DataAPI.GetData("https://api.okzy.tv/api.php/provide/vod/at/json/?ac=list&t=1"); titleNames = OK_DataAPI.GetVideoType(jsonData); config.AddPicCacheData(key, JsonConvert.SerializeObject(titleNames)); } foreach (TitleName item in titleNames) { menuXList1.Items.Add(new TPlayerList.TopItem { Enabled = true, Visible = true, Tag = item.titleId, Name = item.titleType, }); } menuXList1.InPaint(); menuXList1.Invalidate(); }
void _LoadType() { timer1.Enabled = true; string key = dataClass.baseType + "Title"; menuXList1.Items.Clear(); Action _action = () => { List <TitleName> titleNames; if (config.Exists(key)) { titleNames = JsonConvert.DeserializeObject <List <TitleName> >(config.GetPicCacheData(key)); } else { titleNames = dataClass.GetVideoType(); config.AddPicCacheData(key, JsonConvert.SerializeObject(titleNames)); } foreach (TitleName item in titleNames) { menuXList1.Items.Add(new TPlayerList.TopItem { Enabled = true, Visible = true, Tag = item.titleId, Name = item.titleType, }); } }; _task.ContinueWhenAll(new Task[] { _task.StartNew(_action) }, (action => { this.Invoke(new Action(() => { menuXList1.InPaint(); menuXList1.Invalidate(); if (menuXList1.Items.Count > 0) { menuXList1_DownClick(menuXList1.Items[0]); } else { timer1.Enabled = false; if (isgo != -1) { isgo = -1; //isgo = true; pictureBox2.Image = FontAwesome.GetImage(fontlogo, "4FBB", 38, Color.Black); } } })); })); }