コード例 #1
0
        private void DrawPixelGril(Bitmap bm, Pen pen)
        {
            Graphics g      = Graphics.FromImage(bm);
            int      i      = 0,
                     width  = Variables.Globals.sizeOfNewCoor_2D.Width,
                     height = Variables.Globals.sizeOfNewCoor_2D.Height;

            if (chkLuoiPixel.Checked)
            {
                // Vẽ toàn bộ đường dọc
                for (; i <= width; i++)
                {
                    if (i == width / 2)
                    {
                        continue;
                    }
                    g.DrawLine(new Pen(Color.Black), 5 * i, 0, 5 * i, picb_2DArea.Height);
                }
                // Vẽ toàn bộ đường ngang
                for (i = 0; i <= height; i++)
                {
                    if (i == height / 2)
                    {
                        continue;
                    }
                    g.DrawLine(new Pen(Color.Black), 0, 5 * i, picb_2DArea.Width, 5 * i);
                }
            }

            // Vẽ 2 đường biên Ox và Oy
            g.DrawLine(pen, 5 * width / 2, 0, 5 * width / 2, picb_2DArea.Height);
            g.DrawLine(pen, 0, 5 * height / 2, picb_2DArea.Width, 5 * height / 2);
            g.DrawString("Y", new Font("Time New Roman", 10), Brushes.Yellow, ToaDo.NguoiDungMayTinh(new Point(1, 59)));
            g.DrawString("X", new Font("Time New Roman", 10), Brushes.Yellow, ToaDo.NguoiDungMayTinh(new Point(107, -1)));
        }
コード例 #2
0
        private void picb_2DArea_MouseMove(object sender, MouseEventArgs e)
        {
            Point p = e.Location;

            lbl_SizeGird.Text = picb_2DArea.ToString();

            p = ToaDo.MayTinhNguoiDung(p);
            lbl_SizeGird.Text       = ((picb_2DArea.Size.Width / 5) / 2) + ", " + ((picb_2DArea.Size.Height / 5) / 2);
            lbl_LocationInGird.Text = p.X + ", " + p.Y;
        }
コード例 #3
0
 private void CircleProperties_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (ht != null)
     {
         CircleProperties cp = (sender as CircleProperties);
         if (e.PropertyName.Equals("radius"))
         {
             ht.Radius = cp.Radius;
         }
         else if (e.PropertyName.Equals("coorOriginal"))
         {
             ht.Point = ToaDo.NguoiDungMayTinh(cp.CoorOriginal);
         }
     }
 }
コード例 #4
0
 private void Picb_3DArea_MouseClick(object sender, MouseEventArgs e)
 {
     ToaDo.HienThi(e.Location, picb_3DArea.CreateGraphics(), Color.Black);
 }
コード例 #5
0
        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;
                //    }
                //}
            }
        }