Exemplo n.º 1
0
        //REFRESHTASKLISTCONTROLS
        private void RefreshTaskListControls(Bots.Interfaces.IBot bot)
        {
            //clear the task list control
            listBoxTaskList.Items.Clear();

            //get latest bot tasks and add them to the task list control
            Queue <Bots.Interfaces.BotTask> botQueue = bot.GetTasks();

            foreach (Bots.Interfaces.BotTask task in botQueue)
            {
                listBoxTaskList.Items.Add(task);
            }

            //clear any selection from combo box for new task
            comboBoxTasks.SelectedIndex = -1;

            //set the active bot label
            labelTaskList.Text = bot.Name + "'s " + "Task List:";
        }
Exemplo n.º 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?
            }
        }