using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using C4F.LegoRcx;

namespace Test3
{
    public partial class Form1 : Form
    {

        private Rcx _rcx = new Rcx();  // Create an Rcx object

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Go forward for a second when left bumper is touched
            _rcx.Sensor1.SensorType = RcxSensorType.Touch;
            _rcx.Sensor3.SensorType = RcxSensorType.Touch;

            while (_rcx.Sensor1.Value != 1) {};
            _rcx.MotorA.Power = 5;
            _rcx.MotorC.Power = 5;
            System.Threading.Thread.Sleep(1000);
            this._rcx.MotorA.Off();
            this._rcx.MotorC.Off();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //Display battery voltage in the GUI textbox 
            _rcx.SetDisplay(_rcx.BatteryPower);
            textBox1.Text = _rcx.BatteryPower.ToString();
        }

        private void button3_Click(object sender, EventArgs e)
        {   // Spin in place for a second
            _rcx.MotorA.Power = 5;
            this._rcx.MotorC.Power = -5;
            System.Threading.Thread.Sleep(1000);
            this._rcx.MotorA.Off();
            this._rcx.MotorC.Off();
        }
    }
}