示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }