private void ContextMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { var selectedItems = BotList.SelectedItems; var selectedBotsTokens = new List <string>(); foreach (var selectedBot in selectedItems) { int idx = BotList.Items.IndexOf(selectedBot as ListViewItem); var token = BotList.Items[idx].Text; selectedBotsTokens.Add(token); } switch (e.ClickedItem.Text) { case "Запустить": { var args = new LaunchSeveralBotsArgs() { BotsTokens = selectedBotsTokens }; OnLaunchContextMenuItemClick?.Invoke(sender, args); break; } case "Остановить": { var args = new StopSeveralBotsArgs() { BotsTokens = selectedBotsTokens }; OnStopContextMenuItemClick?.Invoke(sender, args); break; } } }
private static void StopSeveralBots(object sender, StopSeveralBotsArgs e) { StopBots(e.BotsTokens); }