示例#1
0
        private void openGLControl_MouseUp(object sender, MouseEventArgs e)
        {
            if (mode == 1 && e.Button == MouseButtons.Left)
            {
                //Khi nhả chuột trái ở chế độ vẽ hình bình thường
                isDown = false;
                end    = e.Location;
                if (newShapeItem != null)
                {
                    WriteLog.AddLog(new Log {
                        name = newShapeItem.GetType().ToString().Split('.')[2], dayDraw = DateTime.Now, timeToDraw = newShapeItem.thoiGianVe
                    });
                }
                WriteLog.Render(name, thoigian);
            }
            else if (mode == 3)
            {
                //Khi nhả chuột ở chế độ vẽ Polygon
                if (e.Button == MouseButtons.Left)
                {
                    newPolygonItem.Add(e.Location);
                    mouseLeft = true;
                }
                else
                {
                    lPolygon.Add(newPolygonItem);
                    WriteLog.AddLog(new Log {
                        name = "Polygon", dayDraw = DateTime.Now, timeToDraw = newPolygonItem.thoiGianVe
                    });
                    newPolygonItem = new Polygon();
                    mouseLeft      = false;
                }
                WriteLog.Render(name, thoigian);
            }
            else if (mode == 4)
            {
                //Khi nhả  chuột ở chế độ chọn hình
                //Tính khoảng cách tới tất cả các hình, tìm nhỏ nhất, so với epsilon, nếu nhỏ hơn thì hiện hình đó
                ControlPoint.GetMin(lPolygon, Draw.listDraw, e.Location);
                ControlPoint.AllowToDraw(_epsilon);

                //Khi bấm ra ngoài hoặc bấm vào hình khác thì hủy old Mouse để tránh bị delay
                if (ControlPoint.minPolygon == null && ControlPoint.minShape == null)
                {
                    oldMousePoint.X = -1000;
                }

                if (ControlPoint.minPolygon != null && oldMousePoint.X != -1000)
                {
                    Affine.TinhTien(ControlPoint.minPolygon, new Point(e.Location.X - oldMousePoint.X, e.Location.Y - oldMousePoint.Y));
                }
                if (ControlPoint.minShape != null && oldMousePoint.X != -1000)
                {
                    Affine.TinhTien(ControlPoint.minShape, new Point(e.Location.X - oldMousePoint.X, e.Location.Y - oldMousePoint.Y));
                }
                isDown = false;
            }
        }