private bool AddBot(PokeBotConfig cfg) { if (!cfg.IsValidIP()) { return(false); } var ip = cfg.GetAddress(); var match = Bots.FindIndex(z => z.GetAddress().Equals(ip)); if (match >= 0) { RemoveBotsAtIndexes(new[] { match }); } Bots.Add(cfg); var row = new[] { cfg.IP, cfg.Port.ToString(), cfg.NextRoutineType.ToString(), "Idle" }; var lvi = new ListViewItem(row); LV_Bots.Items.Add(lvi); B_Start.Enabled = true; B_Delete.Enabled = true; return(true); }
private static bool AddBot(PokeBotRunner env, PokeBotConfig cfg) { if (!cfg.IsValidIP() && cfg.ConnectionType == ConnectionType.WiFi) { Console.WriteLine($"{cfg.IP}'s config is not valid."); return(false); } else if (!cfg.IsValidUSBIndex() && cfg.ConnectionType == ConnectionType.USB) { Console.WriteLine($"{cfg.UsbPortIndex}'s config is not valid."); return(false); } var newbot = env.CreateBotFromConfig(cfg); try { env.Add(newbot); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); return(false); } Console.WriteLine($"Added: {cfg.IP}: {cfg.InitialRoutine}"); return(true); }
private bool AddBot(PokeBotConfig cfg) { if (!cfg.IsValidIP() || cfg.UsbPortIndex == "" && cfg.ConnectionType == ConnectionType.USB) { return(false); } var newbot = RunningEnvironment.CreateBotFromConfig(cfg); try { RunningEnvironment.Add(newbot); } catch (ArgumentException ex) { WinFormsUtil.Error(ex.Message); return(false); } AddBotControl(cfg); Bots.Add(cfg); return(true); }