예제 #1
0
 /// <summary>
 /// 加载图片
 /// </summary>
 public void LoadImage()
 {
     if (ImageInfo == null || string.IsNullOrEmpty(ImageInfo.OriginURL))
     {
         return;
     }
     ProcessBar_LoadImage.Visible = true;
     new Thread(new ThreadStart(delegate
     {
         try
         {
             var img = AlbumHelper.GetImageByURL(ImageInfo.OriginURL);
             Invoke((EventHandler) delegate
             {
                 ProcessBar_LoadImage.Visible = false;
                 PictureBox_Main.Size         = new Size(Width - 2, Height - 2);
                 PictureBox_Main.Location     = new Point(1, 1);
                 PictureBox_Main.Image        = img;
                 PictureBox_Main.Visible      = true;
             });
         }
         catch { }
     }))
     {
         IsBackground = true
     }.Start();
 }
예제 #2
0
 /// <summary>
 /// 根据QQ号获取头像及昵称
 /// </summary>
 /// <param name="QQNumber">QQ号</param>
 /// <param name="HeadIMG">头像</param>
 /// <param name="UserName">昵称</param>
 /// <returns>操作是否成功</returns>
 public static bool GetUserPortrait(string QQNumber, out Bitmap HeadIMG, out string UserName, out string Number)
 {
     HeadIMG = new Bitmap(100, 100);
     try
     {
         UserName = "******";
         Number   = "0";
         string Get_URL = string.Format("http://r.pengyou.com/fcg-bin/cgi_get_portrait.fcg?uins={0}", QQNumber);
         string json    = RequestHelper.GetResponse(Get_URL, "", "", "gbk");
         if (json.StartsWith("portraitCallBack"))
         {
             Regex           reg = new Regex("\"(.*?)\"");
             MatchCollection mc  = reg.Matches(json);
             if (mc.Count == 3 && mc[0].Groups[1].ToString() == QQNumber)
             {
                 Number   = mc[0].Groups[1].ToString();
                 HeadIMG  = AlbumHelper.GetImageByURL(mc[1].Groups[1].ToString());
                 UserName = mc[2].Groups[1].ToString();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         UserName = "******";
         Number   = "0";
         return(false);
     }
 }
예제 #3
0
 /// <summary>
 /// 解析相册
 /// </summary>
 private void Detect()
 {
     try
     {
         Invoke((EventHandler) delegate
         {
             ProcessBar_Detect.Value        = 0;
             ProcessBar_Detect.Visible      = true;
             Text_Detect_Number.ReadOlay    = true;
             UserInformation.TargetQQNumber = Text_Detect_Number.Text;
             Label_Detect_Tip_SetText("正在获取信息");
             Label_Detect_Tip.Visible = true;
         });
         var DataRes        = string.Empty;
         var CheckHasAccess = AlbumHelper.CheckHasAccess(UserInformation.TargetQQNumber, UserInformation.Cookie, out DataRes);
         switch (CheckHasAccess)
         {
         case AlbumHelper.AccessState.OK:
         {
             Label_Detect_Tip_SetText("正在获取相册列表", Color.White);
             UserInformation.AlbumList = AlbumHelper.ResolveAlbum(DataRes, UserInformation.TargetQQNumber, UserInformation.Cookie);
             Label_Detect_Tip_SetText(string.Format("共获取到 {0} 个相册", UserInformation.AlbumList.Count), Color.White);
             if (UserInformation.AlbumList.Count == 0)
             {
                 Label_Detect_Tip_SetText(string.Format("未获取到任何开放相册"), Color.Red);
                 break;
             }
             int album_index = 1;
             foreach (var alb in UserInformation.AlbumList)
             {
                 ThreadPool.QueueUserWorkItem(new WaitCallback(delegate
                     {
                         var xml = AlbumHelper.GetImageListXml(UserInformation.TargetQQNumber, UserInformation.Cookie, alb.ID);
                         Label_Detect_Tip_SetText(string.Format
                                                      ("正在获取 {0}/{1} 相册照片列表", album_index, UserInformation.AlbumList.Count), Color.White);
                         if (AlbumHelper.ResolveImage(xml, out List <ImageInfo> list, out Exception e))
                         {
                             alb.Images = list;
                         }
                         else
                         {
                             Label_Detect_Tip_SetText("抓取数据时发生异常 - 网络异常", Color.Red);
                             if (ThreadDetect != null)
                             {
                                 ThreadDetect.Abort();
                             }
                             return;
                         }
                         album_index++;
                     }));
             }
             while (album_index <= UserInformation.AlbumList.Count)
             {
                 Thread.Sleep(10);
             }
             Label_Detect_Tip_SetText("正在加载相册缩略图", Color.White);
             LoadAlbumPage();
             Thread.Sleep(100);
             Invoke((EventHandler) delegate
                 {
                     TabControl_Main.SelectedTab = TabPage_Album;
                     Label_Detect_Tip.Visible    = false;
                 });
             break;
         }