public MainForm() { InitializeComponent(); DrawObjects = new List <Shape>(); UserColor = Color.Black; LineWidth = 1; ShapeType = 0; AlgorithmType = 0; StartPoint = new Point(0, 0); EndPoint = new Point(0, 0); //init drawing objects DrawingObjects = new Shape[8]; DrawingObjects[0] = new Line(new Point(0, 0), new Point(0, 0), Color.Black, LineWidth); DrawingObjects[1] = new Circle(new Point(0, 0), new Point(0, 0), Color.Black, LineWidth); DrawingObjects[2] = new Ellipse(new Point(0, 0), new Point(0, 0), Color.Black, LineWidth); DrawingObjects[3] = new Triangle(new Point(0, 0), new Point(0, 0), Color.Black, LineWidth); DrawingObjects[4] = new Objects.Rectangle(new Point(0, 0), new Point(0, 0), Color.Black, LineWidth); DrawingObjects[5] = new EquilateralPolygon(new Point(0, 0), new Point(0, 0), Color.Black, 5, LineWidth); DrawingObjects[6] = new EquilateralPolygon(new Point(0, 0), new Point(0, 0), Color.Black, 6, LineWidth); DrawingObjects[7] = new Polygon(new Point(0, 0), new Point(0, 0), Color.Black, LineWidth); Status = "Drawing line"; lbStatus.Text = Status; IsStopTimer = false; btnColorTable.BackColor = UserColor; IsDrawing = false; RenderContextProvider_Height = openGLControl.OpenGL.RenderContextProvider.Height; }
private void openGLControl_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && ShapeType != 7) { EndPoint = e.Location; EndPoint.Y = RenderContextProvider_Height - EndPoint.Y; DrawingObjects[ShapeType].Completed = true; IsDrawing = false; //drawing real-time when move mouse switch (ShapeType) { case 0: DrawObjects.Add(DrawingObjects[ShapeType]); DrawingObjects[ShapeType] = new Line(new Point(0, 0), new Point(0, 0), Color.Black, LineWidth); break; case 1: Circle circle = new Circle(StartPoint, EndPoint, UserColor, LineWidth); DrawObjects.Add(circle); break; case 2: Ellipse ellipse = new Ellipse(StartPoint, EndPoint, UserColor, LineWidth); DrawObjects.Add(ellipse); break; case 3: DrawObjects.Add(DrawingObjects[ShapeType]); DrawingObjects[ShapeType] = new Triangle(new Point(0, 0), new Point(0, 0), Color.Black, LineWidth); break; case 4: DrawObjects.Add(DrawingObjects[ShapeType]); DrawingObjects[ShapeType] = new Objects.Rectangle(new Point(0, 0), new Point(0, 0), Color.Black, LineWidth); break; case 5: DrawObjects.Add(DrawingObjects[ShapeType]); DrawingObjects[ShapeType] = new Objects.EquilateralPolygon(new Point(0, 0), new Point(0, 0), Color.Black, 5, LineWidth); break; case 6: DrawObjects.Add(DrawingObjects[ShapeType]); DrawingObjects[ShapeType] = new Objects.EquilateralPolygon(new Point(0, 0), new Point(0, 0), Color.Black, 6, LineWidth); break; default: break; } } if (ShapeType == 7) { EndPoint = e.Location; EndPoint.Y = RenderContextProvider_Height - EndPoint.Y; DrawingObjects[ShapeType].StartPoint = EndPoint; if (e.Button == MouseButtons.Right) { DrawingObjects[ShapeType].Completed = true; DrawObjects.Add(DrawingObjects[ShapeType]); DrawingObjects[ShapeType] = new Polygon(new Point(0, 0), new Point(0, 0), Color.Black, LineWidth); } } }