private void Button_MouseDown(object sender, MouseEventArgs e)
        {
            Button btn = sender as Button;

            if (btn.Tag.Equals("Clock"))
            {
                Variables.Globals.clockProperties = new ClockProperties();

                Variables.Globals.clockProperties.PropertyChanged += ClockProperties_PropertyChanged;
                this.pnl_ToolBox.Controls.Add(Variables.Globals.clockProperties);
                if (Variables.Globals.flagXe == false)
                {
                    Variables.Globals.clockProperties.Refresh();
                }

                Variables.Globals.clockProperties.BringToFront();

                DateTime dt = DateTime.Now;
                Variables.Globals.clock = new Clock(new Point(0, 0), 15, dt);
                Variables.Globals.clock.CurrentDatetime = new DateTime(2019, 05, 19, 12, 30, 15);
                Variables.Globals.clock.Draw(this.picb_2DArea.CreateGraphics());
                Variables.Globals.clock.PropertyChanged += Clock_PropertyChanged;
            }
            else if (btn.Tag.Equals("TimePiece"))
            {
                timepieceProperties = new TimepieceProperties();
                timepieceProperties.PropertyChanged += TimepieceProperties_PropertyChanged;
                this.pnl_ToolBox.Controls.Add(timepieceProperties);
                timepieceProperties.BringToFront();

                timepiece = new Timepiece();
                timepiece.PropertyChanged += Timepiece_PropertyChanged;
            }
            else if (btn.Tag.Equals("Car"))
            {
                this.timer1.Start();
                Variables.Globals.xe     = new XeProperties();
                Variables.Globals.flagXe = true;
                Variables.Globals.hinhXe = new HinhXe();
                this.pnl_ToolBox.Controls.Add(Variables.Globals.xe);
                Variables.Globals.xe.BringToFront();
                Variables.Globals.xe.Visible          = true;
                Variables.Globals.xe.PropertyChanged += Xe_PropertyChanged;
            }
            else
            {
                MessageBox.Show("The function is unavailable. Please contact the author to get more information.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void TimepieceProperties_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals("currentTime"))
     {
         timepiece.Item_clock.CurrentDatetime = timepieceProperties.ClockProperties.CurrentTime;
     }
     else if (e.PropertyName.Equals("mainLocation"))
     {
         timepiece.Location = timepieceProperties.MainLocation;
     }
     else if (e.PropertyName.Equals("dispose"))
     {
         this.timepiece           = null;
         this.timepieceProperties = null;
     }
     else if (e.PropertyName.Equals("ZoomIn"))
     {
         this.timepiece.Item_clock.R += 5;
     }
     else if (e.PropertyName.Equals("ZoomOut"))
     {
         this.timepiece.Item_clock.R -= 5;
     }
 }
        private void Button_MouseDown(object sender, MouseEventArgs e)
        {
            Button btn = sender as Button;

            if (btn.Tag.Equals("Circle"))
            {
                CircleProperties circleProperties = new CircleProperties(this.pnl_Tb_2D.Size);
                circleProperties.PropertyChanged += CircleProperties_PropertyChanged;
                this.pnl_ToolBox.Controls.Add(circleProperties);
                circleProperties.BringToFront();

                ht = new HinhTron(new Point(550, 320), 10);
                circleProperties.CoorOriginal = ToaDo.MayTinhNguoiDung(new Point(550, 320));
                circleProperties.Radius       = 10;
                ht.Draw(picb_2DArea.CreateGraphics());
                ht.PropertyChanged += Ht_PropertyChanged;
            }
            else if (btn.Tag.Equals("Clock"))
            {
                clockProperties = new ClockProperties();

                clockProperties.PropertyChanged += ClockProperties_PropertyChanged;
                this.pnl_ToolBox.Controls.Add(clockProperties);
                if (flagXe == false)
                {
                    clockProperties.Refresh();
                }

                clockProperties.BringToFront();

                DateTime dt = DateTime.Now;
                clock = new Clock(new Point(0, 0), 15, dt);
                clock.CurrentDatetime = new DateTime(2019, 05, 19, 12, 30, 15);
                clock.Draw(this.picb_2DArea.CreateGraphics());
                clock.PropertyChanged += Clock_PropertyChanged;
            }
            else if (btn.Tag.Equals("TimePiece"))
            {
                timepieceProperties = new TimepieceProperties();
                timepieceProperties.PropertyChanged += TimepieceProperties_PropertyChanged;
                this.pnl_ToolBox.Controls.Add(timepieceProperties);
                timepieceProperties.BringToFront();

                timepiece = new Timepiece();
                timepiece.PropertyChanged += Timepiece_PropertyChanged;
            }
            else if (btn.Tag.Equals("Car"))
            {
                this.timer1.Start();
                xe     = new XeProperties();
                flagXe = true;
                hinhXe = new HinhXe();
                this.pnl_ToolBox.Controls.Add(xe);
                xe.BringToFront();
                xe.Visible          = true;
                xe.PropertyChanged += Xe_PropertyChanged;

                //if (flagXe)
                //{

                //    // biểu diễn các hoạt động của xe
                //    hinhXe.PropertyChanged += HinhXe_PropertyChanged;
                //    hinhXe.ToMau(e.Graphics);
                //    hinhXe.drawCar(e.Graphics);

                //    if (dem <= 30)
                //    {
                //        dem++;
                //        // tịnh tiến 5 đơn vị
                //        // đi phải qua trái
                //        hinhXe.traslationXe(5, 0);
                //        hinhXe.quayBanhXe(30);


                //    }
                //    else if (dem <= 60)
                //    {
                //        dem++;
                //        //tịnh tiến 5 đơn vị
                //        // đi phải qua trái
                //        hinhXe.traslationXe(0, 5);
                //        hinhXe.quayBanhXe(30);
                //    }
                //    else if (dem <= 90)
                //    {
                //        dem++;
                //        // đi từ trên xuống dưới
                //        hinhXe.traslationXe(-5, 0);
                //        hinhXe.quayBanhXe(-30);
                //    }
                //    else if (dem <= 120)
                //    {
                //        dem++;
                //        // đi từ dưới lên trên
                //        hinhXe.traslationXe(0, -5);
                //        hinhXe.quayBanhXe(-30);
                //    }else
                //    {
                //        // cập nhật lại
                //        dem = 0;
                //    }
                //}
            }
        }