コード例 #1
0
ファイル: Paper.cs プロジェクト: nekoprog/LabelPrint
        public void Parse(string FilePath)
        {
            ID = "";
            coordinateSystem = null;
            labelLayout      = null;

            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(FilePath);
            XmlNodeList node = xDoc.GetElementsByTagName("paper");

            foreach (XmlNode nodex in node)
            {
                foreach (XmlAttribute attrib in nodex.Attributes)
                {
                    if (attrib.Name.Equals("type", StringComparison.OrdinalIgnoreCase))
                    {
                        ID = attrib.Value;
                    }
                }

                foreach (XmlNode nodexx in nodex.ChildNodes)
                {
                    if (nodexx.Name.Equals("coordinates", StringComparison.OrdinalIgnoreCase))
                    {
                        coordinateSystem = new Tools.CoordinateSystem();
                        coordinateSystem.Parse(nodexx);
                    }
                    else if (nodexx.Name.Equals("size", StringComparison.OrdinalIgnoreCase))
                    {
                        size = new ACA.LabelX.Tools.Size(0, 0, coordinateSystem.units);
                        size.Parse(nodexx);
                    }
                    else if (nodexx.Name.Equals("labelpos", StringComparison.OrdinalIgnoreCase))
                    {
                        labelLayout = new LabelLayout(coordinateSystem.units);
                        labelLayout.Parse(nodexx);
                    }
                    else if (nodexx.Name.Equals("offsets", StringComparison.OrdinalIgnoreCase))
                    {
                        foreach (XmlNode nodexxx in nodexx)
                        {
                            if (nodexxx.Name.Equals("offset", StringComparison.OrdinalIgnoreCase))
                            {
                                Offset offset = new Offset(coordinateSystem.units);
                                offset.Parse(nodexxx);

                                Offsets.Add(string.Format("{0}@{1}", offset.Printer, offset.Machine), offset);
                            }
                        }
                    }
                }
            }
        }