Beispiel #1
0
        private static XmlElement ConvertToXml(XmlDocument doc, Knot knot, int id, XmlFlags flag)
        {
            // Create the element from the document
            XmlElement ele = doc.CreateElement("k" + id.ToString());

            // Create the element to represent the point
            XmlElement poi = doc.CreateElement("Point");

            // Create and set elements to for the point
            XmlElement poi_x = doc.CreateElement("X");
            XmlElement poi_y = doc.CreateElement("Y");

            poi_x.InnerText = knot.Point.x.ToString();
            poi_y.InnerText = knot.Point.y.ToString();

            // Add points to the point element
            poi.AppendChild(poi_x);
            poi.AppendChild(poi_y);

            // Add point to element
            ele.AppendChild(poi);

            // Does knot support in tangents?
            if (flag.HasFlag(XmlFlags.In))
            {
                // Create the element to represent the in tangent
                XmlElement ta_in = doc.CreateElement("In");

                // Create and set elements to for the tangent
                XmlElement ta_in_x = doc.CreateElement("X");
                XmlElement ta_in_y = doc.CreateElement("Y");

                ta_in_x.InnerText = knot.In.x.ToString();
                ta_in_y.InnerText = knot.In.y.ToString();

                // Add points to the tangent element
                ta_in.AppendChild(ta_in_x);
                ta_in.AppendChild(ta_in_y);

                // Add tangent to element
                ele.AppendChild(ta_in);
            }

            // Does knot support in tangents?
            if (flag.HasFlag(XmlFlags.Out))
            {
                // Create the element to represent the out tangent
                XmlElement ta_out = doc.CreateElement("Out");

                // Create and set elements to for the tangent
                XmlElement ta_out_x = doc.CreateElement("X");
                XmlElement ta_out_y = doc.CreateElement("Y");

                ta_out_x.InnerText = knot.Out.x.ToString();
                ta_out_y.InnerText = knot.Out.y.ToString();

                // Add points to the tangent element
                ta_out.AppendChild(ta_out_x);
                ta_out.AppendChild(ta_out_y);

                // Add tangent to element
                ele.AppendChild(ta_out);
            }

            // Return the element
            return(ele);
        }