public PictureData(WebPicData webPic, string[] baseUrls) { this.picType = PictureType.Web; this.Id = webPic.id; this.PackId = webPic.packId; this.FillType = webPic.FillType; this.Extras = new PictureDataExtras(); this.Extras.webPath = PicWebPath.FromWebPic(webPic, baseUrls); this.PicClass = PicClass.Common; }
public static PicWebPath FromWebPic(WebPicData webPic, string[] baseUrls) { return(new PicWebPath { icon = webPic.icon, lineart = webPic.lineart, colored = webPic.colored, json = webPic.json, baseUrls = baseUrls }); }
private void ParseDailyPageContent(DailyPageResponse response) { List <PictureData> localPictures = DatabaseManager.GetLocalPictures(); this.dailyTabInfo = new DailyTabInfo(); this.dailyTabInfo.monthes = new List <DailyMonthInfo>(); if (response.months != null) { for (int i = 0; i < response.months.Count; i++) { DailyMonthInfo dailyMonthInfo = new DailyMonthInfo(); dailyMonthInfo.monthName = ((!string.IsNullOrEmpty(response.months[i].monthName)) ? response.months[i].monthName : string.Empty); dailyMonthInfo.monthIndex = response.months[i].monthIndex; dailyMonthInfo.year = response.months[i].year; dailyMonthInfo.pics = new List <PictureData>(); for (int j = 0; j < response.months[i].pics.Count; j++) { WebPicData webPic = response.months[i].pics[j]; PictureData pictureData = this.ParseWebPic(webPic, response.paths, localPictures, false); if (pictureData != null) { pictureData.SetDailyTabDate(response.months[i].pics.Count - j); pictureData.SetPicClass(PicClass.Daily); dailyMonthInfo.pics.Add(pictureData); } } this.dailyTabInfo.monthes.Add(dailyMonthInfo); } } if (response.daily != null) { this.dailyTabInfo.dailyPic = new DailyPicInfo(); this.dailyTabInfo.dailyPic.day = ((!string.IsNullOrEmpty(response.daily.day)) ? response.daily.day : string.Empty); this.dailyTabInfo.dailyPic.desc = ((!string.IsNullOrEmpty(response.daily.description)) ? response.daily.description : string.Empty); this.dailyTabInfo.dailyPic.month = ((!string.IsNullOrEmpty(response.daily.month)) ? response.daily.month : string.Empty); this.dailyTabInfo.dailyPic.btnLabel = (response.daily.cta ?? string.Empty); PictureData pictureData2 = this.ParseWebPic(response.daily.pic, response.paths, localPictures, false); if (pictureData2 != null) { pictureData2.SetPicClass(PicClass.Daily); this.dailyTabInfo.dailyPic.picData = pictureData2; } else { this.dailyTabInfo.dailyPic = null; } } }
private List <PictureData> ParseGiftCodeContent(BonusCodeResponse response) { List <PictureData> list = new List <PictureData>(); if (response.content != null) { for (int i = 0; i < response.content.Length; i++) { WebPicData webPic = response.content[i]; PictureData pictureData = this.ParseWebPic(webPic, response.paths, null, true); if (pictureData != null) { list.Add(pictureData); } } } return(list); }
private PictureData ParseWebPic(WebPicData webPic, string[] serverPaths, List <PictureData> pics, bool forceManualSearch = false) { if (pics != null) { PictureData pictureData = pics.Find((PictureData pd) => pd.Id == webPic.id); if (pictureData != null) { pictureData.AddExtras(WebPicData.ParseLabels(webPic.labels), webPic.categories); if (pictureData.Solved) { PictureSaveData save = this.GetSave(pictureData); if (save != null && save.progres == 100) { pictureData.SetCompleted(); } } return(pictureData); } } else if (forceManualSearch) { PictureData pictureData2 = this.GetPictureData(webPic.id); if (pictureData2 != null) { pictureData2.AddExtras(WebPicData.ParseLabels(webPic.labels), webPic.categories); if (pictureData2.Solved) { PictureSaveData save2 = this.GetSave(pictureData2); if (save2 != null && save2.progres == 100) { pictureData2.SetCompleted(); } } return(pictureData2); } } PictureData pictureData3 = new PictureData(webPic, serverPaths); pictureData3.AddExtras(WebPicData.ParseLabels(webPic.labels), webPic.categories); return(pictureData3); }
public void DeletePictureData(PictureData pd) { FMLogger.Log("del pd invoke. " + pd.Id); DatabaseManager.DeletePicture(pd); FileHelper.DeleteFile(pd.Icon); FileHelper.DeleteFile(pd.LineArt); if (pd.FillType == FillAlgorithm.Flood) { FileHelper.DeleteFile(pd.ColorMap); } FileHelper.DeleteFile(pd.Palette); PictureData pictureData = null; if (this.libResponse != null) { int num = -1; for (int i = 0; i < this.libResponse.content.Count; i++) { if (this.libResponse.content[i].id == pd.Id) { num = i; FMLogger.Log("found respone match " + i); break; } } if (num != -1) { pictureData = this.ParseWebPic(this.libResponse.content[num], this.libResponse.paths, null, false); pictureData.Solved = pd.Solved; if (pd.PicClass == PicClass.Daily) { pictureData.SetPicClass(PicClass.Daily); } else if (pd.PicClass == PicClass.FacebookGift) { pictureData.SetPicClass(PicClass.FacebookGift); } for (int j = 0; j < this.orderedMainPage.Count; j++) { if (this.orderedMainPage[j].Id == pictureData.Id) { this.orderedMainPage[j] = pictureData; FMLogger.Log("found and replaced local pd with web pd in main page pics"); break; } } if (this.featuredSection != null) { this.featuredSection.UpdatePicData(pictureData); } if (this.newsTabInfo != null) { this.newsTabInfo.UpdatePicData(pictureData); } if (this.dailyTabInfo != null) { this.dailyTabInfo.UpdatePicData(pictureData); } } else { WebPicData webPicData = null; if (this.libResponse.featured != null) { if (this.libResponse.featured.daily_items != null) { for (int k = 0; k < this.libResponse.featured.daily_items.Count; k++) { if (this.libResponse.featured.daily_items[k].pic != null && this.libResponse.featured.daily_items[k].pic.id == pd.Id) { webPicData = this.libResponse.featured.daily_items[k].pic; break; } } } if (webPicData == null && this.dailyPageResponse != null) { bool flag = false; if (this.dailyPageResponse.months != null) { for (int l = 0; l < this.dailyPageResponse.months.Count; l++) { if (this.dailyPageResponse.months[l].pics != null) { for (int m = 0; m < this.dailyPageResponse.months[l].pics.Count; m++) { if (this.dailyPageResponse.months[l].pics[m].id == pd.Id) { webPicData = this.dailyPageResponse.months[l].pics[m]; flag = true; break; } } } if (flag) { break; } } } if (!flag && this.dailyPageResponse.daily != null && this.dailyPageResponse.daily.pic != null && this.dailyPageResponse.daily.pic.id == pd.Id) { webPicData = this.dailyPageResponse.daily.pic; } } } if (webPicData != null) { pictureData = this.ParseWebPic(webPicData, this.libResponse.paths, null, false); pictureData.Solved = pd.Solved; if (pd.PicClass == PicClass.Daily) { pictureData.SetPicClass(PicClass.Daily); } if (this.featuredSection != null) { this.featuredSection.UpdatePicData(pictureData); } if (this.newsTabInfo != null) { this.newsTabInfo.UpdatePicData(pictureData); } if (this.dailyTabInfo != null) { this.dailyTabInfo.UpdatePicData(pictureData); } } } } if (this.PictureDataDeleted != null) { this.PictureDataDeleted(pd, pictureData); } }
private void ParseMainPageContent(LibraryPageResponce responce) { List <PictureData> localPictures = DatabaseManager.GetLocalPictures(); List <PictureData> list = new List <PictureData>(); for (int i = 0; i < responce.content.Count; i++) { WebPicData webPic = responce.content[i]; PictureData pictureData = this.ParseWebPic(webPic, responce.paths, localPictures, false); if (pictureData != null) { list.Add(pictureData); } } this.orderedMainPage = list; this.featuredSection = new FeaturedInfo(); if (responce.featured != null) { this.featuredSection.dailies = new List <DailyPicInfo>(); this.featuredSection.promoPics = new List <PromoPicInfo>(); this.featuredSection.externalLinks = new List <ExternalLinkInfo>(); if (responce.featured.daily_items != null) { for (int j = 0; j < responce.featured.daily_items.Count; j++) { FeaturedDailyResp tmp = responce.featured.daily_items[j]; DailyPicInfo dailyPicInfo = new DailyPicInfo(); dailyPicInfo.order = tmp.order; dailyPicInfo.id = tmp.id; dailyPicInfo.desc = (tmp.description ?? string.Empty); dailyPicInfo.day = (tmp.day ?? string.Empty); dailyPicInfo.month = (tmp.month ?? string.Empty); dailyPicInfo.btnLabel = (tmp.cta ?? string.Empty); PictureData pictureData2 = this.orderedMainPage.Find((PictureData p) => p.Id == tmp.pic.id); if (pictureData2 != null) { dailyPicInfo.picData = pictureData2; } else { dailyPicInfo.picData = this.ParseWebPic(tmp.pic, responce.paths, localPictures, false); } dailyPicInfo.picData.SetPicClass(PicClass.Daily); this.featuredSection.dailies.Add(dailyPicInfo); } } if (responce.featured.editor_choice != null) { for (int k = 0; k < responce.featured.editor_choice.Count; k++) { FeaturedEditorChoiceResp tmp = responce.featured.editor_choice[k]; PromoPicInfo promoPicInfo = new PromoPicInfo(); promoPicInfo.order = tmp.order; promoPicInfo.id = tmp.id; promoPicInfo.desc = (tmp.description ?? string.Empty); promoPicInfo.title = (tmp.title ?? string.Empty); promoPicInfo.btnLabel = (tmp.cta ?? string.Empty); PictureData pictureData3 = this.orderedMainPage.Find((PictureData p) => p.Id == tmp.pic.id); if (pictureData3 != null) { promoPicInfo.picData = pictureData3; } else { promoPicInfo.picData = this.ParseWebPic(tmp.pic, responce.paths, localPictures, false); } this.featuredSection.promoPics.Add(promoPicInfo); } } if (responce.featured.external_links != null) { for (int l = 0; l < responce.featured.external_links.Count; l++) { FeaturedExternalLink featuredExternalLink = responce.featured.external_links[l]; ExternalLinkInfo externalLinkInfo = new ExternalLinkInfo(); externalLinkInfo.id = featuredExternalLink.id; externalLinkInfo.order = featuredExternalLink.order; externalLinkInfo.desc = (featuredExternalLink.description ?? string.Empty); externalLinkInfo.title = (featuredExternalLink.title ?? string.Empty); externalLinkInfo.btnLabel = (featuredExternalLink.cta ?? string.Empty); externalLinkInfo.targetUrl = featuredExternalLink.target_url; externalLinkInfo.targetScheme = (featuredExternalLink.target_scheme ?? string.Empty); externalLinkInfo.imageData = new ImageData(featuredExternalLink.paths, featuredExternalLink.img_url); this.featuredSection.externalLinks.Add(externalLinkInfo); } } } this.featuredSection.OrderItems(); this.newsTabInfo = new NewsInfo(); if (responce.news != null) { this.newsTabInfo.promoPics = new List <PromoPicInfo>(); this.newsTabInfo.externalLinks = new List <ExternalLinkInfo>(); if (responce.news.editor_choice != null) { for (int m = 0; m < responce.news.editor_choice.Count; m++) { FeaturedEditorChoiceResp tmp = responce.news.editor_choice[m]; PromoPicInfo promoPicInfo2 = new PromoPicInfo(); promoPicInfo2.id = tmp.id; promoPicInfo2.order = tmp.order; promoPicInfo2.desc = (tmp.description ?? string.Empty); promoPicInfo2.title = (tmp.title ?? string.Empty); promoPicInfo2.btnLabel = (tmp.cta ?? string.Empty); PictureData pictureData4 = this.orderedMainPage.Find((PictureData p) => p.Id == tmp.pic.id); if (pictureData4 != null) { promoPicInfo2.picData = pictureData4; } else { promoPicInfo2.picData = this.ParseWebPic(tmp.pic, responce.paths, localPictures, false); } this.newsTabInfo.promoPics.Add(promoPicInfo2); } } if (responce.news.external_links != null) { for (int n = 0; n < responce.news.external_links.Count; n++) { FeaturedExternalLink featuredExternalLink2 = responce.news.external_links[n]; ExternalLinkInfo externalLinkInfo2 = new ExternalLinkInfo(); externalLinkInfo2.id = featuredExternalLink2.id; externalLinkInfo2.order = featuredExternalLink2.order; externalLinkInfo2.desc = (featuredExternalLink2.description ?? string.Empty); externalLinkInfo2.title = (featuredExternalLink2.title ?? string.Empty); externalLinkInfo2.btnLabel = (featuredExternalLink2.cta ?? string.Empty); externalLinkInfo2.targetUrl = featuredExternalLink2.target_url; externalLinkInfo2.targetScheme = (featuredExternalLink2.target_scheme ?? string.Empty); externalLinkInfo2.imageData = new ImageData(featuredExternalLink2.paths, featuredExternalLink2.img_url); this.newsTabInfo.externalLinks.Add(externalLinkInfo2); } } } this.newsTabInfo.OrderItems(); }