Ejemplo n.º 1
0
        private void addAction(int x, int y)
        {
            Button temp = new Button();

            temp.AutoSize = true;
            temp.Location = new System.Drawing.Point(x, y);
            temp.Name     = "Auton Action " + (actions.Length + 1);
            temp.Size     = new System.Drawing.Size(35, 13);
            temp.TabIndex = 1;
            temp.Text     = "Auton Action " + (actions.Length + 1);
            temp.Enabled  = true;
            temp.Visible  = true;
            temp.Show();
            ContextMenu cm = new ContextMenu();

            cm.MenuItems.Add("Open Config File", new EventHandler(LoadConfig));
            cm.MenuItems.Add("Delete Action", new EventHandler(Delete));
            temp.ContextMenu = cm;
            //pictureBox1.Enabled = false;
            this.Controls.Add(temp);
            temp.BringToFront();
            AutonAction[] tempActions = new AutonAction[actions.Length + 1];
            for (int i = 0; i < actions.Length; i++)
            {
                tempActions[i] = actions[i];
            }
            tempActions[actions.Length] = new AutonAction(temp, true);
            actions = tempActions;
        }
Ejemplo n.º 2
0
        private void Delete(object sender, EventArgs e)
        {
            AutonAction[] temp          = new AutonAction[actions.Length - 1];
            bool          found         = false;
            MenuItem      menuItem      = sender as MenuItem;
            ContextMenu   menu          = menuItem.GetContextMenu();
            Control       sourceControl = menu.SourceControl;

            try {
                for (int i = 0; i < actions.Length; i++)
                {
                    if (found)
                    {
                        temp[i - 1] = actions[i];
                    }
                    else if (!actions[i].button.Equals((Button)sourceControl))
                    {
                        temp[i] = actions[i];
                    }
                    else
                    {
                        actions[i].button.Enabled = false;
                        actions[i].button.Visible = false;
                    }
                }
                actions = temp;
            }
            catch (Exception d)
            {
            }
        }
Ejemplo n.º 3
0
        private double backwardMove(AutonAction one, AutonAction two, double orentation, ref String code)
        {
            double angleToMove = Math.Atan2(-one.button.Location.Y + two.button.Location.Y,
                                            -one.button.Location.X + two.button.Location.X);

            angleToMove *= (180 / Math.PI);
            angleToMove -= orentation;
            orentation   = angleToMove;
            if (angleToMove > 0)
            {
                code += "right(" + -(int)angleToMove + ");\n";
            }
            else
            {
                code += "left(" + -(int)angleToMove + ");\n";
            }
            double distance = Math.Pow(inchesToTicks(one.button.Location.Y - two.button.Location.Y, 4), 2)
                              + Math.Pow(inchesToTicks(one.button.Location.X - two.button.Location.X, 4), 2);

            distance = Math.Sqrt(distance);
            code    += "backward(" + (int)distance + ");\n";
            return(orentation);
        }
Ejemplo n.º 4
0
 public Form2(AutonAction action)
 {
     this.action = action;
     InitializeComponent();
 }