Пример #1
0
        private void MyProfileBtn_Click(object sender, EventArgs e)
        {
            //GlobalAPI.GetCacheFileInfo("wangpengtest", CacheFileType.Image, 0, (info) =>
            //{

            //});
            ObjectPropertyInfoForm form = new ObjectPropertyInfoForm();

            form.Text               = "我的信息";
            form.TargetObject       = _selfNameCard;
            form.UpdateObjectAction = (o) =>
            {
                NIM.User.UserAPI.UpdateMyCard(o as UserNameCard, (a) =>
                {
                    if (a == ResponseCode.kNIMResSuccess)
                    {
                        UserAPI.GetUserNameCard(new List <string>()
                        {
                            SelfId
                        }, (ret) =>
                        {
                            if (ret.Any())
                            {
                                _selfNameCard = ret[0];
                                DisplayMyProfile(_selfNameCard);
                            }
                        });
                    }
                });
            };
            form.Show();
        }
Пример #2
0
        /// <summary>
        /// 更新用户名片
        /// </summary>
        /// <param name="card"></param>
        /// <param name="d"></param>
        public static void UpdateMyCard(UserNameCard card, UpdateNameCardResultDelegate d)
        {
            var json = card.Serialize();
            var ptr  = NimUtility.DelegateConverter.ConvertToIntPtr(d);

            UserNativeMethods.nim_user_update_my_user_name_card(json, null, UpdateNameCardCompleted, ptr);
        }
Пример #3
0
        void DisplayMyProfile(NIM.User.UserNameCard card)
        {
            if (card == null)
            {
                return;
            }
            _selfNameCard = card;
            _actionWrapper.InvokeAction(() =>
            {
                IDLabel.Text   = card.AccountId;
                NameLabel.Text = card.NickName;
                SigLabel.Text  = card.Signature;

                ThreadPool.QueueUserWorkItem((arg) =>
                {
                    if (!string.IsNullOrEmpty(card.IconUrl))
                    {
                        var url = Uri.UnescapeDataString(card.IconUrl);
                        if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
                        {
                            try
                            {
                                var stream = System.Net.WebRequest.Create(card.IconUrl).GetResponse().GetResponseStream();
                                _actionWrapper.InvokeAction(() =>
                                {
                                    if (stream != null)
                                    {
                                        IconPictureBox.Image = Image.FromStream(stream);
                                    }
                                });
                            }
                            catch (Exception e)
                            {
                                System.Diagnostics.Debug.WriteLine("set user icon failed:%s", e.Message);
                            }
                        }
                    }
                });
            });
        }