コード例 #1
0
 private void btncontroller_Click(object sender, EventArgs e)
 {
     P1.Hide(); P2.Hide(); P5.Hide(); P4.Hide();
     P3.Show(); P3.BringToFront();
     lbltab.Text             = "Controller Page";
     btnConnecting.BackColor = Color.FromArgb(41, 39, 40); btnConnecting.ForeColor = Color.DimGray;
     btnsetting.BackColor    = Color.FromArgb(41, 39, 40); btnsetting.ForeColor = Color.DimGray;
     btncontroller.BackColor = Color.FromArgb(41, 39, 70); btncontroller.ForeColor = Color.Aquamarine;
     btnstatus.BackColor     = Color.FromArgb(41, 39, 40); btnstatus.ForeColor = Color.DimGray;
     btnhome.BackColor       = Color.FromArgb(41, 39, 40); btnhome.ForeColor = Color.DimGray;
 }
コード例 #2
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (btnConnect.Text == "Connect")
            {
                try
                {
                    UART.PortName = cbxCom.Text;
                    UART.Open();
                }
                catch (Exception)
                {
                    MessageBox.Show("This Com is unavailable now. PLease select another one.");
                    return;
                }
                btnConnect.Text = "Disconnected";
                //enable START & STOP
                btnChay.Enabled = true;
                btnDung.Enabled = true;
                //enable Setting
                chbxAuto.Enabled = true;
                chbxMan.Enabled  = true;
                cbxLevel.Enabled = true;
                //cbxTime.Enabled = true;
                btnChay.Text = "SET UP";
                //other changes
                //btnDung.Enabled = false;
                //btnChay.Enabled = true;
                stt.Text                       = "THE MACHINE is CONNECTED.";
                stt.ForeColor                  = Color.Green;
                btnConnect.BackColor           = Color.Green;
                lblwarning.Text                = "PLEASE SELECT YOUR OPTIONS."; lblwarn.Text = ""; lblwarning.ForeColor = Color.Chocolate;
                timer1.Enabled                 = true;
                timerForSentCoordinate.Enabled = true;

                startX = PMap.Width / 2; startY = PMap.Height / 2; preMapDone = 0;
                //startTmpX = PMap.Width / 2; startTmpY = PMap.Height / 2;
                File.Delete("map1");
                StreamWriter write = new StreamWriter("map1", true); write.Close();
            }
            else
            {
                timer1.Enabled       = false; timerForSentCoordinate.Enabled = false;
                btnConnect.Text      = "Connect";
                stt.Text             = "THE MACHINE IS DISCONNECTED.";
                stt.ForeColor        = Color.Red;
                btnConnect.BackColor = Color.Teal;
                //disable START & STOP
                btnChay.Enabled = false;
                btnDung.Enabled = false;
                //disable Controller
                btnback.Enabled     = false; btnback.BackColor = Color.FromArgb(33, 42, 52);
                btnleft.Enabled     = false; btnleft.BackColor = Color.FromArgb(33, 42, 52);
                btnstop.Enabled     = false; btnleft.BackColor = Color.FromArgb(33, 42, 52);
                btnright.Enabled    = false; btnright.BackColor = Color.FromArgb(33, 42, 52);
                btnstraight.Enabled = false; btnstraight.BackColor = Color.FromArgb(33, 42, 52);
                //disable Setting
                chbxAuto.Enabled = false; chbxAuto.Checked = false;
                chbxMan.Enabled  = false; chbxMan.Checked = false;
                cbxLevel.Enabled = false; cbxTime.Enabled = false;
                btnTime.Enabled  = false; btnTime.BackColor = Color.FromArgb(33, 42, 52);

                P3.BringToFront();
                status.Text       = "THE MACHINE ARE DISCONNECT";
                lblwarning.Text   = "YOU DON'T HAVE CONNECTION YET.";
                lblwarn.Text      = "YOU DON'T HAVE CONNECTION YET.";
                lblwarn.ForeColor = Color.Red; lblwarning.ForeColor = Color.Red;
                UART.Close();
            }
        }
コード例 #3
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (btnConnect.Text == "Connect")
            {
                try
                {
                    UART.PortName = cbxCom.Text;
                    UART.Open();
                }
                catch (Exception)
                {
                    MessageBox.Show("This Com is unavailable now. PLease select another one.");
                    return;
                }
                btnConnect.Text = "Disconnect";
                //enable START & STOP
                btnchay.Enabled = true;
                btndung.Enabled = true;
                //enable Setting
                cbx_auto.Enabled = true;
                cbx_man.Enabled  = true;
                cbxlevel.Enabled = true;
                cbxtime.Enabled  = true;
                btnchay.Text     = "SET UP";
                //other changes
                btndung.Enabled      = false;
                btnchay.Enabled      = true;
                stt.Text             = "THE MACHINE is CONNECTED.";
                stt.ForeColor        = Color.Green;
                btnConnect.BackColor = Color.Green;
                lblwarning.Text      = "PLEASE SELECT YOUR OPTIONS."; lblwarn.Text = ""; lblwarning.ForeColor = Color.Chocolate;
                timer1.Enabled       = true;
            }
            else
            {
                timer1.Enabled       = false;
                btnConnect.Text      = "Connect";
                stt.Text             = "THE MACHINE IS DISCONNECTED.";
                stt.ForeColor        = Color.Red;
                btnConnect.BackColor = Color.Teal;
                //disable START & STOP
                btnchay.Enabled = false;
                btndung.Enabled = false;
                //disable Controller
                btnback.Enabled     = false; btnback.BackColor = Color.FromArgb(33, 42, 52);
                btnleft.Enabled     = false; btnleft.BackColor = Color.FromArgb(33, 42, 52);
                btnstop.Enabled     = false; btnleft.BackColor = Color.FromArgb(33, 42, 52);
                btnright.Enabled    = false; btnright.BackColor = Color.FromArgb(33, 42, 52);
                btnstraight.Enabled = false; btnstraight.BackColor = Color.FromArgb(33, 42, 52);
                //disable Setting
                cbx_auto.Enabled = false;
                cbx_man.Enabled  = false;
                cbxlevel.Enabled = false;
                cbxtime.Enabled  = false;

                P3.BringToFront();
                status.Text       = "THE MACHINE ARE DISCONNECT";
                lblwarning.Text   = "YOU DON'T HAVE CONNECTION YET.";
                lblwarn.Text      = "YOU DON'T HAVE CONNECTION YET.";
                lblwarn.ForeColor = Color.Red; lblwarning.ForeColor = Color.Red;
                UART.Close();
            }
        }