Esempio n. 1
0
        private void 刷新AOE直播列表按钮点击事件_Click(object sender, RoutedEventArgs e)
        {
            刷新AOE直播列表按钮.IsEnabled = false;
            刷新AOE直播列表按钮.Content   = "刷新中....";
            new Thread(new ThreadStart(delegate {
                try
                {
                    外部API.正在直播数据 直播数据 = new 外部API.正在直播数据();
                    直播数据.更新正在直播数据();
                    this.Dispatcher.Invoke(new Action(delegate
                    {
                        bilibiliAOE直播列表.Items.Clear();
                        youtubeAOE直播列表.Items.Clear();
                        tcAOE直播列表.Items.Clear();
                    }));
                    foreach (var item in 直播数据.直播数据)
                    {
                        string 时间 = MMPU.将时间戳转换为日期类型(item.实际开始时间);
                        if (!string.IsNullOrEmpty(item.直播连接))
                        {
                            switch (item.频道类型)
                            {
                            case 4:

                                this.Dispatcher.Invoke(new Action(delegate
                                {
                                    bilibiliAOE直播列表.Items.Add(new { 称 = item.主播名称, 标题 = item.标题, 观看人数 = item.当前观众, 直播开始时间 = 时间, 直播URL = item.直播连接 });
                                }));
                                break;

                            case 1:
                                this.Dispatcher.Invoke(new Action(delegate
                                {
                                    youtubeAOE直播列表.Items.Add(new { 称 = item.主播名称, 标题 = item.标题, 观看人数 = item.当前观众, 直播开始时间 = 时间, 直播URL = item.直播连接 });
                                }));
                                break;

                            case 8:
                                this.Dispatcher.Invoke(new Action(delegate
                                {
                                    tcAOE直播列表.Items.Add(new { 称 = item.主播名称, 标题 = item.标题, 观看人数 = item.当前观众, 直播开始时间 = 时间, 直播URL = item.直播连接 });
                                }));
                                break;
                            }
                        }
                    }
                    if (bilibiliAOE直播列表.Items.Count == 0)
                    {
                        this.Dispatcher.Invoke(new Action(delegate
                        {
                            bilibiliAOE直播列表.Items.Add(new { 称 = "", 标题 = "当前没有在BILIBILI直播的VTB", 观看人数 = "", 直播开始时间 = "", 直播URL = "" });
                        }));
                    }
                    if (youtubeAOE直播列表.Items.Count == 0)
                    {
                        this.Dispatcher.Invoke(new Action(delegate
                        {
                            youtubeAOE直播列表.Items.Add(new { 称 = "", 标题 = "当前没有在YouTuBe直播的VTB", 观看人数 = "", 直播开始时间 = "", 直播URL = "" });
                        }));
                    }
                    if (tcAOE直播列表.Items.Count == 0)
                    {
                        this.Dispatcher.Invoke(new Action(delegate
                        {
                            tcAOE直播列表.Items.Add(new { 称 = "", 标题 = "当前没有在TwitCasting直播的VTB", 观看人数 = "", 直播开始时间 = "", 直播URL = "" });
                        }));
                    }
                }
                catch (Exception)
                {
                }
                this.Dispatcher.Invoke(new Action(delegate
                {
                    刷新AOE直播列表按钮.IsEnabled = true;
                    刷新AOE直播列表按钮.Content   = "刷新列表";
                }));
            })).Start();
        }