public static void Draw()// Graphics g)
        {
            Pen lePen = new Pen(Color.White, 3);


            foreach (DrawingObject obj in objectIdentifier)                     //iterates through the objects
            {
                switch (obj.shapeType)
                {
                case 2:                 //line
                {
                    Line temp = (Line)drawingList[obj.indexNo];

                    lePen.Color = temp.AccessContourColor;
                    lePen.Width = temp.AccessLineWidth;
                    gcodeString[gcodeStringIndex].AppendFormat("(Line color{0} )\r\n", temp.AccessContourColor);

                    temp.Draw(mainScale);

                    break;
                }

                case 3:                 //rectangle
                {
                    rectangle temp = (rectangle)drawingList[obj.indexNo];

                    lePen.Color = temp.AccessContourColor;
                    //            lePen.Width = temp.AccessLineWidth;

                    gcodeString[gcodeStringIndex].AppendFormat("(Rect color{0} )\r\n", temp.AccessContourColor);

                    temp.Draw();        // lePen, g);

                    break;
                }

                case 4:                 //circle
                {
                    circle temp = (circle)drawingList[obj.indexNo];

                    lePen.Color = temp.AccessContourColor;
                    lePen.Width = temp.AccessLineWidth;
                    gcodeString[gcodeStringIndex].AppendFormat("(Circle color{0} )\r\n", temp.AccessContourColor);

                    if (mainScale == 0)
                    {
                        mainScale = 1;
                    }

                    temp.Draw();        // lePen, g, mainScale);

                    break;
                }

                case 5:                 //polyline
                {
                    polyline temp = (polyline)drawingList[obj.indexNo];

                    lePen.Color = temp.AccessContourColor;
                    lePen.Width = temp.AccessLineWidth;
                    gcodeString[gcodeStringIndex].AppendFormat("(Poly color{0} )\r\n", temp.AccessContourColor);

                    if (mainScale == 0)
                    {
                        mainScale = 1;
                    }

                    temp.Draw(mainScale);

                    break;
                }

                case 6:                 //arc
                {
                    arc temp = (arc)drawingList[obj.indexNo];

                    lePen.Color = temp.AccessContourColor;
                    lePen.Width = temp.AccessLineWidth;
                    gcodeString[gcodeStringIndex].AppendFormat("(Arc color{0} )\r\n", temp.AccessContourColor);

                    if (mainScale == 0)
                    {
                        mainScale = 1;
                    }

                    temp.Draw();        // lePen, g, mainScale);

                    break;
                }
                }
            }


            //	g.Dispose();		//not disposed because "g" is get from the paintbackground event..
            lePen.Dispose();
        }
        private static void PolylineModule(StreamReader reader)    //Interpretes polyline objects in the DXF file
        {
            string line1, line2;

            line1 = "0";
            line2 = "0";

            double x1 = 0;
            double y1 = 0;
            double x2 = 0;
            double y2 = 0;


            thePolyLine = new polyline(Color.White, 1);

            int ix = drawingList.Add(thePolyLine);

            objectIdentifier.Add(new DrawingObject(5, ix));

            int       counter          = 0;
            int       numberOfVertices = 1;
            int       openOrClosed     = 0;
            ArrayList pointList        = new ArrayList();


            do
            {
                GetLineCouple(reader, out line1, out line2);

                if (line1 == "90")
                {
                    numberOfVertices = Convert.ToInt32(line2);
                }

                if (line1 == "70")
                {
                    openOrClosed = Convert.ToInt32(line2);
                }


                if (line1 == "10")
                {
                    x1 = Convert.ToDouble(line2);
                    if (x1 > XMax)
                    {
                        XMax = x1;
                    }

                    if (x1 < XMin)
                    {
                        XMin = x1;
                    }
                }

                if (line1 == "20")
                {
                    y1 = -Convert.ToDouble(line2);

                    if (y1 > YMax)
                    {
                        YMax = y1;
                    }

                    if (y1 < YMin)
                    {
                        YMin = y1;
                    }

                    pointList.Add(new Point((int)x1, (int)-y1));
                    counter++;
                }
            }while (counter < numberOfVertices);

            //****************************************************************************************************//
            //***************This Part is related with the drawing editor...the data taken from the dxf file******//
            //***************is interpreted hereinafter***********************************************************//


            for (int i = 1; i < numberOfVertices; i++)
            {
                thePolyLine.AppendLine(new Line((Point)pointList[i - 1], (Point)pointList[i], Color.White, 1));
            }

            if (openOrClosed == 1)
            {
                thePolyLine.AppendLine(new Line((Point)pointList[numberOfVertices - 1], (Point)pointList[0], Color.White, 1));
            }


            mainScale = Math.Min(scaleX, scaleY);

            //////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////
        }