Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
将用户细节更改为新的方法
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiichiamane committed May 12, 2020
1 parent bb6acff commit 78d74b8
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
60 changes: 60 additions & 0 deletions PixivFSUWP/Data/UserDetail.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
}
}
4 changes: 2 additions & 2 deletions PixivFSUWP/UserDetailPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 78d74b8

Please sign in to comment.