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); }
public void Initialize(PokeBotRunner runner, PokeBotConfig cfg) { Runner = runner; Config = cfg; ReloadStatus(); L_Description.Text = string.Empty; }
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 void ExitNoConfig() { var cfg = new PokeBotConfig(); var created = JsonConvert.SerializeObject(cfg); File.WriteAllText(ConfigPath, created); Console.WriteLine("Created new config file since none was found in the program's path. Please configure it and restart the program."); Console.WriteLine("It is suggested to configure this config file using the GUI project if possible, as it will help you assign values correctly."); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
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); }
private void AddBotControl(PokeBotConfig cfg) { var row = new BotController { Width = FLP_Bots.Width }; row.Initialize(RunningEnvironment, cfg); FLP_Bots.Controls.Add(row); FLP_Bots.SetFlowBreak(row, true); row.Click += (s, e) => { TB_IP.Text = cfg.IP; NUD_Port.Value = cfg.Port; CB_Routine.SelectedValue = (int)cfg.InitialRoutine; }; row.Remove += (s, e) => { Bots.Remove(row.Config); RunningEnvironment.Remove(row.Config.IP, !RunningEnvironment.Hub.Config.SkipConsoleBotCreation); FLP_Bots.Controls.Remove(row); }; }
public MockExecutor(PokeBotConfig cfg) : base(cfg) { }