private async void ShowResult(IJson json, string type) { if (json.GetValue("code").ToLong() == 0 && json.GetValue("data").GetValue("numresults").ToLong() > 0) { switch (type) { case "video": foreach (IJson v in json.GetValue("data").GetValue("result")) { Video video = new Video(v); ResultVideo resultVideo = new ResultVideo(video); resultVideo.PreviewMouseLeftButtonDown += ResultVideo_PreviewMouseLeftButtonDown; ContentPanel.Children.Add(resultVideo); } break; case "media_bangumi": StringBuilder stringBuilderBangumi = new StringBuilder(); foreach (IJson v in json.GetValue("data").GetValue("result")) { stringBuilderBangumi.Append(','); stringBuilderBangumi.Append(v.GetValue("season_id").ToString()); } Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("season_ids", stringBuilderBangumi.ToString().Substring(1)); try { IJson cardsJson = await BiliApi.GetJsonResultAsync("https://api.bilibili.com/pgc/web/season/cards", dic, true); foreach (IJson v in json.GetValue("data").GetValue("result")) { Season season = new Season(v, cardsJson); ResultSeason resultSeason = new ResultSeason(season); resultSeason.PreviewMouseLeftButtonDown += ResultSeason_PreviewMouseLeftButtonDown; ContentPanel.Children.Add(resultSeason); } } catch (WebException) { } break; case "media_ft": StringBuilder stringBuilderFt = new StringBuilder(); foreach (IJson v in json.GetValue("data").GetValue("result")) { stringBuilderFt.Append(','); stringBuilderFt.Append(v.GetValue("season_id").ToString()); } Dictionary <string, string> dic1 = new Dictionary <string, string>(); dic1.Add("season_ids", stringBuilderFt.ToString().Substring(1)); try { IJson cardsJson1 = await BiliApi.GetJsonResultAsync("https://api.bilibili.com/pgc/web/season/cards", dic1, false); foreach (IJson v in json.GetValue("data").GetValue("result")) { Season season = new Season(v, cardsJson1); ResultSeason resultSeason = new ResultSeason(season); resultSeason.PreviewMouseLeftButtonDown += ResultSeason_PreviewMouseLeftButtonDown; ContentPanel.Children.Add(resultSeason); } } catch (WebException) { } break; case "bili_user": foreach (IJson v in json.GetValue("data").GetValue("result")) { User user = new User(v); ResultUser resultUser = new ResultUser(user); resultUser.PreviewMouseLeftButtonDown += ResultUser_PreviewMouseLeftButtonDown; ContentPanel.Children.Add(resultUser); } break; } } }
private async void ShowResult(Json.Value json, string type) { if (json["code"] == 0 && json["data"]["numResults"] > 0) { switch (type) { case "video": foreach (Json.Value v in json["data"]["result"]) { Video video = new Video(v); ResultVideo resultVideo = new ResultVideo(video); resultVideo.PreviewMouseLeftButtonDown += ResultVideo_PreviewMouseLeftButtonDown; ContentPanel.Children.Add(resultVideo); } break; case "media_bangumi": case "media_ft": StringBuilder stringBuilderBangumi = new StringBuilder(); foreach (Json.Value v in json["data"]["result"]) { stringBuilderBangumi.Append(','); stringBuilderBangumi.Append(((uint)v["season_id"]).ToString()); } Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("season_ids", stringBuilderBangumi.ToString().Substring(1)); try { Json.Value cardsJson = await BiliApi.GetJsonResultAsync("https://api.bilibili.com/pgc/web/season/cards", dic, true); foreach (Json.Value v in json["data"]["result"]) { Season season = new Season(v, cardsJson); ResultSeason resultSeason = new ResultSeason(season); resultSeason.PreviewMouseLeftButtonDown += ResultSeason_PreviewMouseLeftButtonDown; ContentPanel.Children.Add(resultSeason); } } catch (WebException) { } break; case "bili_user": foreach (Json.Value v in json["data"]["result"]) { User user = new User(v); ResultUser resultUser = new ResultUser(user); resultUser.PreviewMouseLeftButtonDown += ResultUser_PreviewMouseLeftButtonDown; ContentPanel.Children.Add(resultUser); } break; } ContentViewer.Visibility = Visibility.Visible; } else { NoMoreGrid.Visibility = Visibility.Visible; } }