private PokeBotConfig CreateNewBotConfig() { var type = (PokeRoutineType)WinFormsUtil.GetIndex(CB_Routine); var ip = TB_IP.Text; var port = (int)NUD_Port.Value; var cfg = SwitchBotConfig.GetConfig <PokeBotConfig>(ip, port); cfg.NextRoutineType = type; return(cfg); }
private PokeBotConfig CreateNewBotConfig() { var type = (PokeRoutineType)WinFormsUtil.GetIndex(CB_Routine); var ip = TB_IP.Text; var port = (int)NUD_Port.Value; var connectionType = (ConnectionType)WinFormsUtil.GetIndex(CB_ConnectionType); var addedIndexes = Bots.Where(z => z.UsbPortIndex != string.Empty).Select(z => z.UsbPortIndex); var usbPortIndex = SwitchConnectionUSB.GetUsbPortIndex(addedIndexes); var cfg = SwitchBotConfig.GetConfig <PokeBotConfig>(ip, port, connectionType, usbPortIndex); cfg.Initialize(type, connectionType); return(cfg); }
private static void CreateNewConfig(PokeTradeHubConfig hub) { List <PokeBotConfig> botList = new(); var type = PokeRoutineType.FlexTrade; var ip = "192.168.1.1"; var usbPortIndex = "1"; var port = 6000; var connectionType = ConnectionType.USB; var bot = SwitchBotConfig.GetConfig <PokeBotConfig>(ip, port, connectionType, usbPortIndex); bot.Initialize(type, connectionType); botList.Add(bot); ProgramConfig cfg = new() { Bots = botList.ToArray(), Hub = hub, }; var lines = JsonConvert.SerializeObject(cfg); File.WriteAllText(ConfigFileName, lines); }