Example #1
0
        private void BindProfile(XmlNode n)
        {
            if (n == null)
            {
                return;
            }
            try
            {
                if (n.SelectSingleNode("photo") != null && !String.IsNullOrEmpty(n.SelectSingleNode("photo").InnerText))
                {
                    picPhoto.Image = Image.FromStream(new MemoryStream(new WebClient().DownloadData(n.SelectSingleNode("photo").InnerText)));
                }
                _UserId           = Helper.GetDataFromXmlNodeAsInt(n.SelectSingleNode("uid"));
                lblUserID.Text    = Helper.GetDataFromXmlNode(n.SelectSingleNode("uid"));
                lblFirstName.Text = Helper.GetDataFromXmlNode(n.SelectSingleNode("first_name"));
                lblLastName.Text  = Helper.GetDataFromXmlNode(n.SelectSingleNode("last_name"));
                lblNickname.Text  = Helper.GetDataFromXmlNode(n.SelectSingleNode("nickname"));
                switch (Helper.GetDataFromXmlNode(n.SelectSingleNode("sex")))
                {
                case "1":
                    lblSex.Text = "женский";
                    break;

                case "2":
                    lblSex.Text = "мужской";
                    break;

                default:
                    lblSex.Text = "паркетный";
                    break;
                }
                lblBirthday.Text = Helper.GetDataFromXmlNode(n.SelectSingleNode("bdate"));

                VKAPI myVK = new VKAPI(this.UserId, accessToken);
                // лучше сделать локальную базу стран и городов
                lblCity.Text    = Helper.GetDataFromXmlNode(n.SelectSingleNode("city"));    // myVK.GetCity(Helper.GetDataFromXmlNodeAsInt(n.SelectSingleNode("city")));
                lblCountry.Text = Helper.GetDataFromXmlNode(n.SelectSingleNode("country")); //myVK.GetCountry(Helper.GetDataFromXmlNodeAsInt(n.SelectSingleNode("country")));

                // инициируем событие ProfileLoaded
                if (ProfileLoaded != null)
                {
                    ProfileLoaded(this, String.Format("{0} {1} (ID: {2})", lblFirstName.Text, lblLastName.Text, _UserId));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error. " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void LoadProfile()
        {
            if (this.UserId == -1)
            {
                return;
            }
            VKAPI       myVK    = new VKAPI(this.UserId, accessToken);
            XmlDocument profile = myVK.GetProfile();

            if (profile == null)
            {
                return;
            }
            BindProfile(profile.SelectSingleNode("response/user"));
        }
Example #3
0
 private void LoadProfile()
 {
     if (this.UserId == -1) { return; }
       VKAPI myVK = new VKAPI(this.UserId, accessToken);
       XmlDocument profile = myVK.GetProfile();
       if (profile == null) { return; }
       BindProfile(profile.SelectSingleNode("response/user"));
 }
Example #4
0
        private void BindProfile(XmlNode n)
        {
            if (n == null) { return; }
              try
              {
            if (n.SelectSingleNode("photo") != null && !String.IsNullOrEmpty(n.SelectSingleNode("photo").InnerText))
            {
              picPhoto.Image = Image.FromStream(new MemoryStream(new WebClient().DownloadData(n.SelectSingleNode("photo").InnerText)));
            }
            _UserId = Helper.GetDataFromXmlNodeAsInt(n.SelectSingleNode("uid"));
            lblUserID.Text = Helper.GetDataFromXmlNode(n.SelectSingleNode("uid"));
            lblFirstName.Text = Helper.GetDataFromXmlNode(n.SelectSingleNode("first_name"));
            lblLastName.Text = Helper.GetDataFromXmlNode(n.SelectSingleNode("last_name"));
            lblNickname.Text = Helper.GetDataFromXmlNode(n.SelectSingleNode("nickname"));
            switch (Helper.GetDataFromXmlNode(n.SelectSingleNode("sex")))
            {
              case "1":
            lblSex.Text = "женский";
            break;
              case "2":
            lblSex.Text = "мужской";
            break;
              default:
            lblSex.Text = "паркетный";
            break;
            }
            lblBirthday.Text = Helper.GetDataFromXmlNode(n.SelectSingleNode("bdate"));

            VKAPI myVK = new VKAPI(this.UserId, accessToken);
            // лучше сделать локальную базу стран и городов
            lblCity.Text = Helper.GetDataFromXmlNode(n.SelectSingleNode("city")); // myVK.GetCity(Helper.GetDataFromXmlNodeAsInt(n.SelectSingleNode("city")));
            lblCountry.Text = Helper.GetDataFromXmlNode(n.SelectSingleNode("country")); //myVK.GetCountry(Helper.GetDataFromXmlNodeAsInt(n.SelectSingleNode("country")));

            // инициируем событие ProfileLoaded
            if (ProfileLoaded != null) { ProfileLoaded(this, String.Format("{0} {1} (ID: {2})", lblFirstName.Text, lblLastName.Text, _UserId)); }
              }
              catch (Exception ex)
              {
            MessageBox.Show("Error. " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
              }
        }