コード例 #1
0
        static private void SaveNestParts(XmlDocument xmlDoc, XmlNode partListNode, NestPartListEx nestParts, List <KeyValuePair <long, string> > partDxfPath, Dictionary <long, int> partColorConfig)
        {
            for (int i = 0; i < nestParts.Size(); i++)
            {
                NestPartEx nestPart = nestParts.GetNestPartByIndex(i);

                XmlElement partNode = xmlDoc.CreateElement("Part");
                partListNode.AppendChild(partNode);

                // path node.
                {
                    for (int j = 0; i < partDxfPath.Count; j++)
                    {
                        if (partDxfPath[j].Key == nestPart.GetID())
                        {
                            XmlElement pathNode = xmlDoc.CreateElement("Path");
                            pathNode.InnerText = partDxfPath[j].Value;
                            partNode.AppendChild(pathNode);
                            break;
                        }
                    }
                }

                // Count
                {
                    XmlElement countNode = xmlDoc.CreateElement("Count");
                    countNode.InnerText = nestPart.GetNestCount().ToString();
                    partNode.AppendChild(countNode);
                }

                // Rotate.
                {
                    XmlElement rotateNode = xmlDoc.CreateElement("Rotate");
                    rotateNode.InnerText = ((int)nestPart.GetRotStyle()).ToString();
                    partNode.AppendChild(rotateNode);

                    // custom angles.
                    if (nestPart.GetRotStyle() == PART_ROT_STYLE_EX.PART_ROT_CUSTOM_ANG)
                    {
                        // the angle-string.
                        string    strAngs = "";
                        ArrayList angles  = nestPart.GetCustomRotAng();
                        for (int k = 0; k < angles.Count; k++)
                        {
                            double dAngle = (double)angles[k];
                            strAngs += dAngle.ToString("0.00000000");
                            strAngs += ",";
                        }

                        // append the node.
                        XmlElement customAngleNode = xmlDoc.CreateElement("CustomAng");
                        customAngleNode.InnerText = strAngs;
                        partNode.AppendChild(customAngleNode);
                    }
                }

                // part color.
                {
                    XmlElement colorNode = xmlDoc.CreateElement("Color");
                    colorNode.InnerText = partColorConfig[nestPart.GetPart().GetID()].ToString();
                    partNode.AppendChild(colorNode);
                }
            }
        }