private void listView1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { var item = listView1.GetItemAt(e.X, e.Y); if (item != null) { var player = (Form_Main.Player)item.Tag; var ct = new ContextMenuStrip(); ct.Items.Add("Quick Lookup", null, async(s, ee) => { string[] info = await GetUserData(player.Name); if (info != null) { var result = new Form_PlayerLookupResult(info[0], info[1], info[2], info[3], info[4], info[5]); result.StartPosition = FormStartPosition.Manual; result.Location = new Point { X = Cursor.Position.X - (result.Width / 2), Y = Cursor.Position.Y - (result.Height / 2) }; result.ShowDialog(); } }); ct.Items.Add("Name to Clipboard", null, (s, ee) => { Utility.StringToClipboard(player.Name); }); ct.Items.Add("Add to Login Alert", null, (s, ee) => { Form_Main.Form.tab_LoginAlert1.AddPlayer(player.Name); Form_Main.Form.tab_LoginAlert1.OpenLoginAlertTab(); }); ct.Show(Cursor.Position); } } }
private async void button1_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(textBox1.Text)) { string[] info = await GetUserData(textBox1.Text); if (info != null) { var result = new Form_PlayerLookupResult(info[0], info[1], info[2], info[3], info[4], info[5]); result.ShowDialog(); } else { MessageBox.Show($"Could not retrieve info on player \"{textBox1.Text}\", did you mistype it?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Cannot leave player name blank", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }