private async void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { string txt = friendsList.FocusedItem.Text; contextMenuStrip1.Hide(); UserModel usr = new UserModel(); FriendsModel f1, f2, f3; switch (e.ClickedItem.Text) { case "Dołącz do gry": break; case "Dodaj znajomego": usr = await GetUserAsync(txt); f1 = new FriendsModel(); f1.UserId = user.Id; f1.FriendId = usr.Id; f1.Date = DateTime.Now; for (int i = 0; i < l.Count(); i++) { if (f1.UserId == l[i].UserId && f1.FriendId == l[i].FriendId) { f1.RelationId = l[i].RelationId; } } await PutFriend(f1.RelationId, f1); Form1_Load(this, null); break; case "Czat": usr = await GetUserAsync(txt); var createForm = new Form1(url, client, user, usr); createForm.Show(this); break; case "Statystyki znajomego": usr = await GetUserAsync(txt); Ranking createForm1 = new Ranking(url, client, user, true, usr.Id); createForm1.Show(this); break; case "Usuń znajomego": usr = await GetUserAsync(txt); f2 = new FriendsModel(); f3 = new FriendsModel(); f3.FriendId = f2.UserId = user.Id; f3.UserId = f2.FriendId = usr.Id; for (int i = 0; i < l.Count(); i++) { if (f2.UserId == l[i].UserId && f2.FriendId == l[i].FriendId) { f2.RelationId = l[i].RelationId; } else if (f3.UserId == l[i].UserId && f3.FriendId == l[i].FriendId) { f3.RelationId = l[i].RelationId; } } await client.DeleteAsync($"api/friends/" + f2.RelationId); await client.DeleteAsync($"api/friends/" + f3.RelationId); Form1_Load(this, null); break; case "Usuń zaproszenie": usr = await GetUserAsync(txt); f2 = new FriendsModel(); f3 = new FriendsModel(); f3.FriendId = f2.UserId = user.Id; f3.UserId = f2.FriendId = usr.Id; for (int i = 0; i < l.Count(); i++) { if (f2.UserId == l[i].UserId && f2.FriendId == l[i].FriendId) { f2.RelationId = l[i].RelationId; } else if (f3.UserId == l[i].UserId && f3.FriendId == l[i].FriendId) { f3.RelationId = l[i].RelationId; } } await client.DeleteAsync($"api/friends/" + f2.RelationId); await client.DeleteAsync($"api/friends/" + f3.RelationId); Form1_Load(this, null); break; } }
private void label1_Click(object sender, EventArgs e) { var createForm = new Ranking(url, client, user, false, 0); createForm.Show(this); }