public static void ListeCommand(string arg) { if (arg == "") { arg = "20"; } try { int limit = Int32.Parse(arg); int page = 1; int id = 0; //Appel de l'API Liste liste = null; Task t = Task.Run(async() => { liste = await ApiCalls.GetList(limit); }); t.Wait(); int nbTotal = 1118; if (limit <= 0 || limit > 1118) { limit = nbTotal; } int pageMax = (int)Math.Ceiling((double)nbTotal / limit); bool running = true; liste.Afficher(id); ListeFooter(page, pageMax); do { ConsoleKey ck = Console.ReadKey().Key; switch (ck) { case ConsoleKey.Spacebar: // page suivante if (page < pageMax) { page++; id += limit; t = Task.Run(async() => { liste = await ApiCalls.GetNextList(liste); }); t.Wait(); liste.Afficher(id); ListeFooter(page, pageMax); } break; case ConsoleKey.Backspace: //page précédente if (page > 1) { page--; id -= limit; t = Task.Run(async() => { liste = await ApiCalls.GetPreviousList(liste); }); t.Wait(); liste.Afficher(id); ListeFooter(page, pageMax); } break; case ConsoleKey.Escape: Console.Clear(); DefaultMessage(); running = false; break; case ConsoleKey.Divide: var args = Console.ReadLine().Split(' '); Console.WriteLine(args[0] + " et " + args[1]); if (args[0].StartsWith("pokemon")) { PokemonCommand(args[1]); } else { Console.WriteLine("Cette commande n'existe pas ou n'est pas disponible"); } ListeFooter(page, pageMax); break; default: break; } } while (running); } catch { Console.WriteLine(arg + " n'est pas un nombre valide"); } }