Ejemplo n.º 1
0
        static XmlElement encodeSlice(XmlDocument doc, BuildLayerSlice slice)
        {
            XmlElement e = null;
            if (slice != null)
            {
                e = doc.CreateElement("slice");
                if (slice.getMinRange() > 0)
                {
                    Property p = new Property("ignore", slice.getMinRange());
                    e.SetAttribute("min_range", p.getValue());
                }
                if (slice.getMaxRange() < float.MaxValue)
                {
                    Property p = new Property("ignore", slice.getMaxRange());
                    e.SetAttribute("max_range", p.getValue());
                }
                e.SetAttribute("graph", slice.getFilterGraph().getName());

                if (slice.getSource() != null)
                    e.SetAttribute("source", slice.getSource().getName());

                foreach (Property it in slice.getProperties())
                {
                    e.AppendChild(encodeProperty(doc, it));
                }

                foreach (BuildLayerSlice it in slice.getSubSlices())
                {
                    e.AppendChild(encodeSlice(doc, it));
                }
            }
            return e;
        }
Ejemplo n.º 2
0
        static BuildLayerSlice decodeSlice(XmlElement e, Project proj)
        {
            BuildLayerSlice slice = null;
            if (e != null)
            {
                slice = new BuildLayerSlice();

                if (!string.IsNullOrEmpty(e.GetAttribute("min_range")))
                    slice.setMinRange(float.Parse(e.GetAttribute("min_range")));
                if (!string.IsNullOrEmpty(e.GetAttribute("max_range")))
                    slice.setMaxRange(float.Parse(e.GetAttribute("max_range")));

            #if TODO_DANI
                // required filter graph:
                string graph = e.GetAttribute("graph");
                slice.setFilterGraph(proj.getFilterGraph(graph)); //TODO: warning?
            #endif

                // optional source:
                slice.setSource(proj.getSource(e.GetAttribute("source")));

            #if TODO_DANI
                // properties particular to this slice:
                XmlNodeList props = e.GetElementsByTagName("property");
                foreach (XmlNode i in props)
                {
                    XmlElement k_e = (XmlElement)i;
                    string name = k_e.GetAttribute("name");
                    string value = k_e.GetAttribute("value");
                    slice.getProperties().Add(new Property(name, value));
                }
            #endif

                // now decode sub-slices:
                XmlNodeList slices = e.GetElementsByTagName("slice");
                foreach (XmlNode i in slices)
                {
                    BuildLayerSlice child = decodeSlice((XmlElement)i, proj);
                    if (child != null)
                        slice.getSubSlices().Add(child);
                }
            }
            return slice;
        }