示例#1
0
        //ADDMESSAGE
        private void AddMessage(string botNameArg, Bots.Interfaces.BotType typeArg,
                                Bots.Interfaces.BotTask taskArg, Bots.Interfaces.BotTaskStatus taskStatusArg)
        {
            DateTime time    = DateTime.Now;
            string   message = time.Hour + ":" + time.Minute + ":" + time.Second + " - " + botNameArg + ", " + typeArg + ": " + taskArg + taskStatusArg;

            Invoke((Action)(() => { listBoxMessages.Items.Add(message); }));
        }
示例#2
0
        //CONNECT TO BOT
        private void connectBotButton_Click(object sender, EventArgs e)
        {
            //verify valid bot name
            if (String.IsNullOrEmpty(textBoxBotName.Text))
            {
                return;
            }

            //determine bot type
            Bots.Interfaces.BotType botType = Bots.Interfaces.BotType.Unipedal;
            if (radioButtonUnipedal.Checked)
            {
                botType = Bots.Interfaces.BotType.Unipedal;
            }
            else if (radioButtonBipedal.Checked)
            {
                botType = Bots.Interfaces.BotType.Bipedal;
            }
            else if (radioButtonQuadripedal.Checked)
            {
                botType = Bots.Interfaces.BotType.Quadripedal;
            }
            else if (radioButtonArachnid.Checked)
            {
                botType = Bots.Interfaces.BotType.Arachnid;
            }
            else if (radioButtonRadial.Checked)
            {
                botType = Bots.Interfaces.BotType.Radial;
            }
            else if (radioButtonAero.Checked)
            {
                botType = Bots.Interfaces.BotType.Aeronautical;
            }

            //obtain interface to bot
            Bots.Interfaces.IBot bot = iBotManager.ConnectToBot(textBoxBotName.Text, botType);
            if (iBotManager.AddBotToList(bot))
            {
                //refresh the bot list view
                RefreshListView();

                //set created bot as selected
                int connectedBotIndex = botList.IndexOf(botList.Last());
                listViewBots.Items[connectedBotIndex].Selected = true;

                //assign 5 random tasks to bot
                Array  values = Enum.GetValues(typeof(Bots.Interfaces.BotTask));
                Random random = new Random();

                for (int i = 0; i < 5; i++)
                {
                    Bots.Interfaces.BotTask randomTask = (Bots.Interfaces.BotTask)values.GetValue(random.Next(values.Length));
                    bot.AssignTask(randomTask);
                }

                //refresh or update the task list
                RefreshTaskListControls(bot);

                //clear the bot name textbox
                textBoxBotName.Clear();

                //subscribe to task event
                bot.TaskUpdate += TaskUpdateHandler;
            }
            else
            {
                //show message?
            }
        }