Esempio n. 1
0
 private void GetInformation_Click(object sender, EventArgs e)
 {
     try
     {
         StreamReader ControlInf = new StreamReader("UserInf.txt");
         _Token = ControlInf.ReadLine();
         ControlInf.Close();
         _ApiRequest = new VkAPI(_Token);
         _UserId     = User_ID.Text;
         string[] Params = { "city", "country", "photo_max" };
         _Response = _ApiRequest.GetInformation(_UserId, Params);
         if (_Response != null)
         {
             User_ID.Text             = _UserId;
             User_Photo.ImageLocation = _Response["photo_max"];
             User_Name.Text           = _Response["first_name"];
             User_Surname.Text        = _Response["last_name"];
             User_Country.Text        = _ApiRequest.GetCountryById(_Response["country"]);
             User_City.Text           = _ApiRequest.GetCityById(_Response["city"]);
             GetToken.Visible         = false;
         }
     }
     catch
     {
     }
 }
Esempio n. 2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                StreamReader ControlInf = new StreamReader("UserInf.txt");
                _Token  = ControlInf.ReadLine();
                _UserId = ControlInf.ReadLine();
                ControlInf.Close();
                if (_Token != null)
                {
                    _ApiRequest = new VkAPI(_Token);
                    string[] Params = { "city", "country", "photo_max" };
                    _Response = _ApiRequest.GetInformation(_UserId, Params);
                    if (_Response != null)
                    {
                        User_ID.Text             = _UserId;
                        User_Photo.ImageLocation = _Response["photo_max"];
                        User_Name.Text           = _Response["first_name"];
                        User_Surname.Text        = _Response["last_name"];
                        User_Country.Text        = _ApiRequest.GetCountryById(_Response["country"]);
                        User_City.Text           = _ApiRequest.GetCityById(_Response["city"]);
                        GetToken.Visible         = false;
                    }
                }
            }
            catch { }

            //Загрузка списка стран
            comboBox1.Items.Clear();

            dynamic results = _ApiRequest.GetCountries();

            foreach (var i in results.response.items)
            {
                if (i.title.ToString() == "Россия")
                {
                    ru           = it;
                    Country.Text = i.id.ToString();
                }
                it++;
                comboBox1.Items.Add(i.title.ToString());
            }
            comboBox1.SelectedIndex = ru;
            //загрузка списка стран конец

            if (textBox1.Text != "")
            {
                //Регион
                string id = _ApiRequest.GetCountryIdByName(_ApiRequest.GetCountries(), comboBox1.Text);
                Country.Text = id;
                dynamic Cities = _ApiRequest.GetCitiesById(id, textBox1.Text);
                comboBox2.Items.Clear();
                foreach (var i in Cities.response.items)
                {
                    comboBox2.Items.Add(i.region.ToString());
                }
                if (comboBox2.Items.Count > 2)
                {
                    comboBox2.SelectedIndex = 0;
                }
                //Определение региона
            }
        }