public string ReadFromDXF(StreamReader str, ListBox lb)
        {
            string GroupCode, Value, MyStr;

            GroupCode = "Unused";
            Value     = "Unassigned";

            lb.Items.Add("ARC");

            while (GroupCode != "0")
            {
                GroupCode = str.ReadLine().Trim();
                Value     = str.ReadLine().Trim();
                switch (GroupCode)
                {
                case "10":     // x-ordinate of the centre point
                    Centre.x = Convert.ToDouble(Value);
                    break;

                case "20":     // y-ordinate of the centre point
                    Centre.y = Convert.ToDouble(Value);
                    break;

                case "30":     // z-ordinate of the centre point
                    Centre.z = Convert.ToDouble(Value);
                    break;

                case "40":     // radius
                    Radius = Convert.ToDouble(Value);
                    break;

                case "50":     // start angle in degrees
                    StartAngle = Convert.ToDouble(Value);
                    break;

                case "51":     // end angle in degrees
                    EndAngle = Convert.ToDouble(Value);
                    break;
                }
            }

            // write the arc's properties onto the list box
            MyStr = string.Concat("Location: ", Centre.Publish());
            lb.Items.Add(MyStr);
            MyStr = string.Concat("Radius: ", Radius.ToString());
            lb.Items.Add(MyStr);
            MyStr = string.Concat("Angle sweep: ", StartAngle.ToString(), " to ", EndAngle.ToString());
            lb.Items.Add(MyStr);

            SetExtents();

            // this is the name of the next object to follow
            // it is the value when we get a group code of 0, thus exiting the while loop
            return(Value);
        }
Beispiel #2
0
        public string ReadFromDXF(StreamReader str, ListBox lb)
        {
            string GroupCode, Value, Coords;

            GroupCode = "Unused";
            Value     = "Unassigned";

            lb.Items.Add("LINE");

            while (GroupCode != "0")
            {
                // get the next code/value pair
                GroupCode = str.ReadLine().Trim();
                Value     = str.ReadLine().Trim();
                switch (GroupCode)
                {
                case "10":     // x-ordinate of start point
                    P1.x = Convert.ToDouble(Value);
                    break;

                case "20":     // y-ordinate of start point
                    P1.y = Convert.ToDouble(Value);
                    break;

                case "30":     // z-ordinate of start point
                    P1.z = Convert.ToDouble(Value);
                    break;

                case "11":     // x-ordinate of end point
                    P2.x = Convert.ToDouble(Value);
                    break;

                case "21":     // y-ordinate of end point
                    P2.y = Convert.ToDouble(Value);
                    break;

                case "31":     // z-ordinate of end point
                    P2.z = Convert.ToDouble(Value);
                    break;
                }
            }

            // write the co-ordinates onto the listbox
            Coords = string.Concat(P1.Publish(), " - ", P2.Publish());
            lb.Items.Add(Coords);

            SetExtents();

            // this is the name of the next object to follow
            // it is the value when we get a group code of 0, thus exiting the while loop
            return(Value);
        }
        public string ReadFromDXF(StreamReader str, ListBox lb)
        {
            string GroupCode, Value, Coords;

            GroupCode = "Unused";
            Value     = "Unassigned";

            lb.Items.Add("TEXT");

            while (GroupCode != "0")
            {
                // get the next code/value pair
                GroupCode = str.ReadLine().Trim();
                Value     = str.ReadLine().Trim();
                switch (GroupCode)
                {
                case "10":     // x-ordinate of the insertion point
                    Pos.x = Convert.ToDouble(Value);
                    break;

                case "20":     // y-ordinate of the insertion point
                    Pos.y = Convert.ToDouble(Value);
                    break;

                case "30":     // z-ordinate of the insertion point
                    Pos.z = Convert.ToDouble(Value);
                    break;

                case "40":     // text height
                    Height = Convert.ToDouble(Value);
                    break;

                case "1":     // content
                    Content = Value;
                    break;
                }
            }

            Coords = string.Concat("Location: ", Pos.Publish());
            lb.Items.Add(Coords);
            Coords = string.Concat("Height: ", Height.ToString());
            lb.Items.Add(Coords);
            lb.Items.Add(Content);

            // this is the name of the next object to follow
            // it is the value when we get a group code of 0, thus exiting the while loop
            return(Value);
        }
Beispiel #4
0
        public string ReadFromDXF(StreamReader str, ListBox lb)
        {
            string GroupCode, Value;

            GroupCode = "Unused";
            Value     = "Unassigned";

            lb.Items.Add("POLYLINE");

            while (GroupCode != "0")
            {
                // get the next code/value pair
                GroupCode = str.ReadLine().Trim();
                Value     = str.ReadLine().Trim();
                if (GroupCode == "70") // Closed or not
                {
                    if (Value == "0")
                    {
                        IsClosed = false;
                    }
                    else if (Value == "1")
                    {
                        IsClosed = true;
                    }
                }
                if (GroupCode == "10")
                {
                    // create a new 3D point, and then the x-ordinate of it
                    _3D Pt = new _3D();
                    Pt.x = Convert.ToDouble(Value);

                    // the next group code is 20, which is followed by the y-ordinate of the point
                    GroupCode = str.ReadLine().Trim();
                    Value     = str.ReadLine().Trim();

                    Pt.y = Convert.ToDouble(Value);

                    lb.Items.Add(Pt.Publish());

                    Pts.Add(Pt);
                }
            }

            SetExtents();
            // this is the name of the next object to follow
            // it is the value when we get a group code of 0, thus exiting the while loop
            return(Value);
        }
        public string ReadFromDXF(StreamReader str, ListBox lb)
        {
            string GroupCode, Value, Coords;

            GroupCode = "Unused";
            Value     = "Unassigned";

            lb.Items.Add("CIRCLE");

            while (GroupCode != "0")
            {
                // get the next code/value pair
                GroupCode = str.ReadLine().Trim();
                Value     = str.ReadLine().Trim();
                switch (GroupCode)
                {
                case "10":     // x-ordinate of the centre point
                    Centre.x = Convert.ToDouble(Value);
                    break;

                case "20":     // y-ordinate of the centre point
                    Centre.y = Convert.ToDouble(Value);
                    break;

                case "30":     // z-ordinate of the centre point
                    Centre.z = Convert.ToDouble(Value);
                    break;

                case "40":     // radius
                    Radius = Convert.ToDouble(Value);
                    break;
                }
            }

            // write the circle's properties onto the list box
            Coords = string.Concat("Location: ", Centre.Publish());
            lb.Items.Add(Coords);
            Coords = string.Concat("Radius: ", Radius.ToString());
            lb.Items.Add(Coords);

            SetExtents();

            // this is the name of the next object to follow
            // it is the value when we get a group code of 0, thus exiting the while loop
            return(Value);
        }
        public string ReadFromDXF(StreamReader str, ListBox lb)
        {
            string GroupCode, Value, MyStr;

            GroupCode = "Unused";
            Value     = "Unassigned";

            lb.Items.Add("ELLIPSE");

            while (GroupCode != "0")
            {
                // get the next code/value pair
                GroupCode = str.ReadLine().Trim();
                Value     = str.ReadLine().Trim();
                switch (GroupCode)
                {
                case "10":     // x-ordinate of the centre point
                    Centre.x = Convert.ToDouble(Value);
                    break;

                case "20":     // y-ordinate of the centre point
                    Centre.y = Convert.ToDouble(Value);
                    break;

                case "30":     // z-ordinate of the centre point
                    Centre.z = Convert.ToDouble(Value);
                    break;

                case "11":     // z-ordinate of the major axis endpoint
                    MajorAxisEndpt.x = Convert.ToDouble(Value);
                    break;

                case "21":     // z-ordinate of the major axis endpoint
                    MajorAxisEndpt.y = Convert.ToDouble(Value);
                    break;

                case "31":     // z-ordinate of the major axis endpoint
                    MajorAxisEndpt.z = Convert.ToDouble(Value);
                    break;

                case "40":     // ratio of minor axis to major axis
                    MinorMajorRatio = Convert.ToDouble(Value);
                    break;

                case "41":     // start angle in degrees
                    StartParameter = Convert.ToDouble(Value);
                    break;

                case "42":     // end angle in degrees
                    EndParameter = Convert.ToDouble(Value);
                    break;
                }
            }

            SetRadiiAndAngle();
            SetExtents();

            // write the ellipse's properties onto the listbox
            MyStr = string.Concat("Location: ", Centre.Publish());
            lb.Items.Add(MyStr);
            MyStr = string.Concat("Major Radius: ", MajorRadius.ToString());
            lb.Items.Add(MyStr);
            MyStr = string.Concat("Minor Radius: ", MinorRadius.ToString());
            lb.Items.Add(MyStr);
            MyStr = string.Concat("Angle: ", AngleDeg.ToString("F3"), "degrees");
            lb.Items.Add(MyStr);

            // this is the name of the next object to follow
            // it is the value when we get a group code of 0, thus exiting the while loop
            return(Value);
        }