Esempio n. 1
0
        Point ORI_CAR2 = new Point(941, 802);  // car lt


        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (btnCar.InvokeRequired == true)
            {
                btnCar.Invoke((MethodInvoker) delegate
                {
                    try
                    {
                        //Xuất phát từ Vĩnh Cửu ->Long Thành
                        Y_Car1 -= rotSpeed * 2;
                        X_Car1 += rotSpeed;
                        if (!VC_LT_DepartTime.Equals("0"))
                        {
                            if (Convert.ToInt32(VC_LT_DepartTime) >= 60)
                            {
                                X_Car1 = 0; Y_Car1 = 0;
                            }
                            else
                            {
                                Y_Car1 = -1 * Convert.ToInt32(VC_LT_DepartTime) * 3;
                                X_Car1 = Convert.ToInt32(VC_LT_DepartTime) * 3;
                            }
                        }
                        else
                        {
                            X_Car1 = 0; Y_Car1 = 0;
                        }

                        btnCar.Location = new Point(ORI_CAR1.X + X_Car1, ORI_CAR1.Y - Y_Car1);
                        if (btnCar.Location.X >= 941 && btnCar.Location.Y >= 802)  //941, 802
                        {
                            Y_Car1 = 0; X_Car1 = 0;
                        }
                        //======================================================================

                        //Xuất phát từ Long Thành -> Vĩnh Cửu
                        //Y_Car2 += rotSpeed * 2;
                        //X_Car2 -= rotSpeed;

                        if (!string.IsNullOrEmpty(LT_VC_DepartTime))
                        {
                            DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(LT_VC_DepartTime.Substring(0, 2)), Convert.ToInt32(LT_VC_DepartTime.Substring(3, 2)), 00);
                            DateTime endTime   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                                                              Convert.ToInt32(DateTime.Now.ToString("HH")), Convert.ToInt32(DateTime.Now.ToString("mm")), 00);
                            TimeSpan span = endTime.Subtract(startTime);
                            minutes       = Convert.ToInt32(span.TotalMinutes);
                            Y_Car2        = (minutes * 3) * 2;
                            X_Car2        = -1 * minutes * 3;
                        }
                        else
                        {
                            X_Car2 = 0;
                            X_Car2 = 0;
                        }
                        btnCar2.Location = new Point(ORI_CAR2.X + X_Car2, ORI_CAR2.Y - Y_Car2);
                        if (btnCar2.Location.X <= 789 && btnCar2.Location.Y <= 491)  //789, 491
                        {
                            Y_Car2 = 0; X_Car2 = 0;
                        }
                    }
                    catch { }
                });
            }
        }
Esempio n. 2
0
        Point ORI_CAR3 = new Point(1518, 134); // car tp

        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (btnCar.InvokeRequired == true)
            {
                btnCar.Invoke((MethodInvoker) delegate
                {
                    try
                    {
                        //Xuất phát từ Vĩnh Cửu ->Long Thành
                        if (!string.IsNullOrEmpty(btnCar.Text))
                        {
                            Y_Car1 -= rotSpeed * 2;
                            X_Car1 += rotSpeed;
                            if (!VC_LT_DepartTime.Equals("0"))
                            {
                                if (Convert.ToInt32(VC_LT_DepartTime) >= 60)
                                {
                                    X_Car1          = 958;
                                    Y_Car1          = 832;
                                    btnCar.Text     = "VJ1->VJ2";
                                    btnCar.Location = new Point(X_Car1, Y_Car1);
                                }
                                else
                                {
                                    Y_Car1          = (-1 * Convert.ToInt32(VC_LT_DepartTime) * (5 / 2)) * 2;
                                    X_Car1          = Convert.ToInt32(VC_LT_DepartTime) * (5 / 2);
                                    btnCar.Location = new Point(ORI_CAR1.X + X_Car1, ORI_CAR1.Y - Y_Car1);
                                }
                            }
                            else
                            {
                                X_Car1      = 152; Y_Car1 = -311;
                                btnCar.Text = "VJ1->VJ2";
                                //  btnCar.Location = new Point(X_Car1, Y_Car1);
                                btnCar.Location = new Point(ORI_CAR1.X, ORI_CAR1.Y);
                            }

                            if (btnCar.Location.X >= 941 && btnCar.Location.Y >= 802)  //941, 802
                            {
                                X_Car1          = 958;
                                Y_Car1          = 832;
                                btnCar.Location = new Point(X_Car1, Y_Car1);
                            }
                        }
                        else
                        {
                            btnCar.Location = new Point(ORI_CAR1.X, ORI_CAR1.Y);
                            btnCar.Text     = "VJ1->VJ2";
                            btnCar.Location = new Point(X_Car1, Y_Car1);
                        }


                        //======================================================================

                        //Xuất phát từ Long Thành -> Vĩnh Cửu
                        if (!string.IsNullOrEmpty(btnCar2.Text))
                        {
                            if (!string.IsNullOrEmpty(LT_VC_DepartTime))
                            {
                                DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(LT_VC_DepartTime.Substring(0, 2)), Convert.ToInt32(LT_VC_DepartTime.Substring(3, 2)), 00);
                                DateTime endTime   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                                                                  Convert.ToInt32(DateTime.Now.ToString("HH")), Convert.ToInt32(DateTime.Now.ToString("mm")), 00);
                                TimeSpan span = endTime.Subtract(startTime);
                                minutes       = Convert.ToInt32(span.TotalMinutes);
                                Y_Car2        = (minutes * (5 / 2)) * 2;
                                X_Car2        = (-1 * (minutes * (5 / 2)));
                                if (minutes >= 60)
                                {
                                    Y_Car2       = 311;
                                    X_Car2       = -152;
                                    btnCar2.Text = "VJ2->VJ1";
                                }
                                btnCar2.Location = new Point(ORI_CAR2.X + X_Car2, ORI_CAR2.Y - Y_Car2);
                            }
                            else
                            {
                                //868, 667

                                Y_Car2           = 746; // 311;
                                X_Car2           = 975; // -152;
                                btnCar2.Text     = "VJ2->VJ1";
                                btnCar2.Location = new Point(X_Car2, Y_Car2);
                            }

                            if (btnCar2.Location.X <= 789 && btnCar2.Location.Y <= 491) //VC: 789, 491  LT: 941, 802
                            {
                                Y_Car2           = 746;                                 // 311;
                                X_Car2           = 975;                                 // -152;
                                btnCar2.Text     = "VJ2->VJ1";
                                btnCar2.Location = new Point(X_Car2, Y_Car2);
                            }
                        }
                        else
                        {
                            btnCar2.Location = new Point(ORI_CAR2.X, ORI_CAR2.Y); btnCar2.Text = "";
                        }

                        //Xuất phát từ TÂN PHÚ -> Vĩnh Cửu
                        if (!string.IsNullOrEmpty(btnCar3.Text))
                        {
                            if (!string.IsNullOrEmpty(TP_VC_Departtime))
                            {
                                DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(TP_VC_Departtime.Substring(0, 2)), Convert.ToInt32(TP_VC_Departtime.Substring(3, 2)), 00);
                                DateTime endTime   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                                                                  Convert.ToInt32(DateTime.Now.ToString("HH")), Convert.ToInt32(DateTime.Now.ToString("mm")), 00);
                                TimeSpan span = endTime.Subtract(startTime);
                                minutes       = Convert.ToInt32(span.TotalMinutes);

                                if (minutes >= 180 || TP_VC_Arr.Equals("1"))
                                {
                                    Y_Car3           = 499;
                                    X_Car3           = 792;
                                    btnCar3.Location = new Point(X_Car3, Y_Car3);
                                    btnCar3.Text     = "VJ3->VJ1";
                                    return;
                                }
                                else
                                {
                                    Y_Car3           = minutes * (5 / 2);
                                    X_Car3           = minutes * (5 / 2);
                                    btnCar3.Location = new Point(ORI_CAR3.X - X_Car3 * 2, ORI_CAR3.Y + Y_Car3);
                                }
                            }
                            else
                            {
                                Y_Car3           = 499;
                                X_Car3           = 792;
                                btnCar3.Location = new Point(ORI_CAR3.X, ORI_CAR3.Y);
                                btnCar3.Text     = "VJ3->VJ1";
                            }

                            if (btnCar3.Location.X <= 792 && btnCar3.Location.Y >= 499) //VC: 789, 491  LT: 941, 802
                            {
                                Y_Car3           = 510;                                 // 499;
                                X_Car3           = 800;                                 // 792;
                                btnCar3.Text     = "VJ3->VJ1";
                                btnCar3.Location = new Point(X_Car3, Y_Car3);
                            }
                        }
                        else
                        {
                            btnCar3.Location = new Point(ORI_CAR3.X, ORI_CAR3.Y); btnCar3.Text = "VJ3->VJ1";
                        }
                    }
                    catch { }
                });
            }
        }