private void LikeButtom_Click(object sender, EventArgs e) { //if (listView1.SelectedItems.Count == 0) //{ // string request = "https://api.vk.com/method/photos.getAlbums?owner_id=" + textBox1.Text + "&" + // Access_token + "&v=5.52"; // WebClient client = new WebClient(); // string answer = Encoding.UTF8.GetString(client.DownloadData(request)); // PhotosAlbums user = JsonConvert.DeserializeObject<PhotosAlbums>(answer); // string[] texts = new string[user.response.count]; // listView1.Items.Clear(); // foreach (PhotosAlbums.Item item in user.response.items) // { // texts[0] = item.title; // texts[1] = item.id.ToString(); // ListViewItem lvi = new ListViewItem(texts); // listView1.Items.Add(lvi); // } // Owner_id = textBox1.Text; // SearchButton.Visible = false; // SearchFriends.Visible = false; // button1.Visible = true; // textBox1.Text = ""; // label1.Text = "Введите ID альбома"; // columnHeader1.Text = "Название альбома"; // columnHeader2.Text = "ID альбома"; //} //else //{ if (listView1.SelectedItems.Count == 0) { } else { listView1.View = View.Details; imageList1.ImageSize = new Size(35, 35); string Name = listView1.SelectedItems[0].SubItems[0].Text; string id = listView1.SelectedItems[0].SubItems[1].Text; textBox1.Text = id; string request = "https://api.vk.com/method/photos.getAlbums?owner_id=" + textBox1.Text + "&" + Access_token + "&v=5.52"; WebClient client = new WebClient(); string answer = Encoding.UTF8.GetString(client.DownloadData(request)); PhotosAlbums user = JsonConvert.DeserializeObject <PhotosAlbums>(answer); //int CountPhotoAlbums = user.response.count; string[] texts = new string[2]; listView1.Items.Clear(); foreach (PhotosAlbums.Item item in user.response.items) { texts[0] = item.title; texts[1] = item.id.ToString(); ListViewItem lvi = new ListViewItem(texts); listView1.Items.Add(lvi); } Owner_id = textBox1.Text; SearchButton.Visible = false; SearchFriends.Visible = false; button1.Visible = true; textBox1.Text = ""; label1.Text = "Введите ID альбома"; columnHeader1.Text = "Название альбома"; columnHeader2.Text = "ID альбома"; UsersSearchB.Visible = false; } }
private void LikeButtom_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) { string request = "https://api.vk.com/method/photos.getAlbums?owner_id=" + textBox1.Text + "&" + Access_token + "&v=5.52"; WebClient client = new WebClient(); string answer = Encoding.UTF8.GetString(client.DownloadData(request)); PhotosAlbums user = JsonConvert.DeserializeObject <PhotosAlbums>(answer); string[] texts = new string[user.response.count]; listView1.Items.Clear(); foreach (PhotosAlbums.Item item in user.response.items) { texts[0] = item.title; texts[1] = item.id.ToString(); ListViewItem lvi = new ListViewItem(texts); listView1.Items.Add(lvi); } Owner_id = textBox1.Text; SearchButton.Visible = false; SearchFriends.Visible = false; button1.Visible = true; textBox1.Text = ""; label1.Text = "Введите ID альбома"; columnHeader1.Text = "Номер фотографии"; columnHeader2.Text = "ID Фотографии"; } else { string Name = listView1.SelectedItems[0].SubItems[0].Text; string id = listView1.SelectedItems[0].SubItems[1].Text; textBox1.Text = id; string request = "https://api.vk.com/method/photos.getAlbums?owner_id=" + textBox1.Text + "&" + Access_token + "&v=5.52"; WebClient client = new WebClient(); string answer = Encoding.UTF8.GetString(client.DownloadData(request)); PhotosAlbums user = JsonConvert.DeserializeObject <PhotosAlbums>(answer); int CountPhotoAlbums = user.response.count; string[] texts = new string[CountPhotoAlbums]; listView1.Items.Clear(); foreach (PhotosAlbums.Item item in user.response.items) { texts[0] = item.title; texts[1] = item.id.ToString(); ListViewItem lvi = new ListViewItem(texts); listView1.Items.Add(lvi); } Owner_id = textBox1.Text; SearchButton.Visible = false; SearchFriends.Visible = false; button1.Visible = true; textBox1.Text = ""; label1.Text = "Введите ID альбома"; columnHeader1.Text = "Номер фотографии"; columnHeader2.Text = "ID Фотографии"; } }