diff --git a/PixivFSUWP/Data/UserDetail.cs b/PixivFSUWP/Data/UserDetail.cs index c73185a..5562757 100644 --- a/PixivFSUWP/Data/UserDetail.cs +++ b/PixivFSUWP/Data/UserDetail.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.PortableExecutable; using System.Text; using System.Threading.Tasks; using Windows.Data.Json; @@ -117,5 +118,64 @@ public static UserDetail FromJsomValue(JsonObject Source) toret.WorkspaceImageUrl = workspace["workspace_image_url"].TryGetString(); return toret; } + + public static UserDetail FromObject(PixivCS.Objects.UserDetail Source) + { + UserDetail toret = new UserDetail(); + var user = Source.User; + toret.ID = (int)user.Id; + toret.Name = user.Name; + toret.Account = user.Account; + toret.AvatarUrl = user.ProfileImageUrls.Medium?.ToString() ?? ""; + toret.Comment = user.Comment; + toret.IsFollowed = user.IsFollowed.HasValue ? user.IsFollowed.Value : false; + var profile = Source.Profile; + toret.WebPage = profile.Webpage?.ToString() ?? ""; + toret.Gender = profile.Gender; + toret.Birth = profile.Birth; + toret.BirthDay = profile.BirthDay; + toret.BirthYear = (int)profile.BirthYear; + toret.Region = profile.Region; + toret.AddressID = (int)profile.AddressId; + toret.CountryCode = profile.CountryCode; + toret.Job = profile.Job; + toret.JobID = (int)profile.JobId; + toret.TotalFollowUsers = (int)profile.TotalFollowUsers; + toret.TotalMyPixivUsers = (int)profile.TotalMypixivUsers; + toret.TotalIllusts = (int)profile.TotalIllusts; + toret.TotalManga = (int)profile.TotalManga; + toret.TotalNovels = (int)profile.TotalNovels; + toret.TotalIllustBookmarksPublic = (int)profile.TotalIllustBookmarksPublic; + toret.TotalIllustSeries = (int)profile.TotalIllustSeries; + toret.TotalNovelSeries = (int)profile.TotalNovelSeries; + toret.BackgroundImage = profile.BackgroundImageUrl?.ToString() ?? ""; + toret.TwitterAccount = profile.TwitterAccount; + toret.TwitterUrl = profile.TwitterUrl?.ToString() ?? ""; + toret.PawooUrl = profile.PawooUrl?.ToString() ?? ""; + toret.IsPremium = profile.IsPremium; + toret.IsUsingCustomProfileImage = profile.IsUsingCustomProfileImage; + var profile_publicity = Source.ProfilePublicity; + toret.GenderPublicity = profile_publicity.Gender; + toret.RegionPublicity = profile_publicity.Region; + toret.BirthDayPublicity = profile_publicity.BirthDay; + toret.BirthYearPublicity = profile_publicity.BirthYear; + toret.JobPublicity = profile_publicity.Job; + toret.Pawoo = profile_publicity.Pawoo; + var workspace = Source.Workspace; + toret.PC = workspace.Pc; + toret.Monitor = workspace.Monitor; + toret.Tool = workspace.Tool; + toret.Scanner = workspace.Scanner; + toret.Tablet = workspace.Tablet; + toret.Mouse = workspace.Mouse; + toret.Printer = workspace.Printer; + toret.Desktop = workspace.Desktop; + toret.Music = workspace.Music; + toret.Desk = workspace.Desk; + toret.Chair = workspace.Chair; + toret.WorkspaceComment = workspace.Comment; + toret.WorkspaceImageUrl = workspace.WorkspaceImageUrl?.ToString() ?? ""; + return toret; + } } } diff --git a/PixivFSUWP/UserDetailPage.xaml.cs b/PixivFSUWP/UserDetailPage.xaml.cs index 99f8e7d..552abf3 100644 --- a/PixivFSUWP/UserDetailPage.xaml.cs +++ b/PixivFSUWP/UserDetailPage.xaml.cs @@ -89,8 +89,8 @@ protected override void OnNavigatedFrom(NavigationEventArgs e) async Task loadContents() { var res = await new PixivAppAPI(Data.OverAll.GlobalBaseAPI) - .UserDetail(userid.ToString()); - detail = Data.UserDetail.FromJsomValue(res); + .GetUserDetailAsync(userid.ToString()); + detail = Data.UserDetail.FromObject(res); string _getText(string input) => (input == "") ? GetResourceString("PrivatePlain") : input; txtUsername.Text = detail.Name; txtAuthor.Text = detail.Name;