Пример #1
0
        public static Image GetSkin(string uuid)
        {
            string  deENcodedDATA = Post.Get_Data("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid, new System.Net.CookieContainer(), "utf-8", "");
            JObject ENcodeedDATA  = JObject.Parse(deENcodedDATA);
            string  base64code    = ENcodeedDATA["properties"][0]["value"].ToString();
            JObject addrJSON      = JObject.Parse(BASE.DecodeBase64(base64code));
            string  url           = addrJSON["textures"]["SKIN"]["url"].ToString();
            var     img           = ImageGenerator.DownLoadImge(url);

            return(img);
        }
Пример #2
0
 public void LoadUser()
 {
     Logger.LogInfo("Load Users");
     if (User.Users.Count == 0)
     {
         LBL_Username.Content = "";
         UserTAB.SelectedItem = LoginItem;
     }
     else
     {
         LoadingBox.Visibility = Visibility.Visible;
         Logger.LogInfo("Set CachedNames");
         LBL_Username.Content = User.SelectUser.CachedUserName.Replace("_", "__");
         LoginType.Content    = User.SelectUser.UserTypeString;
         IMG_UserHead.Source  = ImageGenerator.bs(User.SelectUser.CachedIcon as System.Drawing.Bitmap);
         UserTAB.SelectedItem = ProfileItem;
         Logger.LogInfo("Get Name and Icon Task");
         var task = new ETask()
         {
             Title = "用户管理器", Content = "正在加载用户头像...", Percent = 0
         };
         Task t = new Task(() =>
         {
             MainWindow.Current.Dispatcher.BeginInvoke((Action) delegate()
             {
                 task.StartTask();
             });
             try
             {
                 var map         = User.SelectUser.Icon as System.Drawing.Bitmap;
                 string username = User.SelectUser.UserName;
                 MainWindow.Current.Dispatcher.BeginInvoke((Action) delegate()
                 {
                     LBL_Username.Content  = username;
                     ImageSource img       = ImageGenerator.bs(map);
                     IMG_UserHead.Source   = img;
                     LoadingBox.Visibility = Visibility.Collapsed;
                 });
             }
             catch (Exception ex)
             {
                 MainWindow.Current.Dispatcher.BeginInvoke((Action) delegate()
                 {
                     Logger.LogError("There is an error when we are loading ICON and USER_NAME:" + ex + "\n" + ex.Message + "\n" + ex.StackTrace);
                     MainWindow.Current.ShowMessageBox("错误", new TextBlock()
                     {
                         TextWrapping = TextWrapping.Wrap, Text = "错误,无法加载用户的头像\n" + ex.Message.ToString() + "\n我们将使用上次缓存的头像你可以打开日志文件并向作者反馈"
                     }, new List <object> {
                         "打开日志"
                     }, new List <RoutedEventHandler> {
                         (object sX, RoutedEventArgs eX) =>
                         {
                             Process.Start("OMCLC\\log.log");
                             MainWindow.Current.mainDialog.IsOpen = false;
                             LoadingBox.Visibility = Visibility.Collapsed;
                         }
                     });
                 });
             }
             finally
             {
                 MainWindow.Current.Dispatcher.BeginInvoke((Action) delegate()
                 {
                     task.CloseTask();
                 });
             }
         });
         t.Start();
     }
     Logger.LogInfo("Load Users Complete");
 }