Beispiel #1
0
        /// <summary>
        /// Check for segment error for a specific segment.
        /// </summary>
        /// <param name="errors">Error list.</param>
        /// <param name="itemID">Script ID.</param>
        /// <param name="nodePath">Path of the node.</param>
        /// <param name="segmentInterval">Segment interval.</param>
        /// <param name="preSegEnd">Preivous segment end point.</param>
        private static void CheckSegment(ErrorSet errors, string itemID, string nodePath,
            SegmentInterval segmentInterval, ref int preSegEnd)
        {
            if (segmentInterval.Begin < preSegEnd)
            {
                string errorPath = string.Format(CultureInfo.InvariantCulture, "{0}.Acoustics", nodePath);
                errors.Add(ScriptError.SegmentSequenceError, itemID, errorPath,
                    segmentInterval.Begin.ToString(CultureInfo.InvariantCulture),
                    preSegEnd.ToString(CultureInfo.InvariantCulture));
            }

            preSegEnd = segmentInterval.End;
        }
        /// <summary>
        /// Generate the ScriptAcoustics object from the xml doc indicated by reader.
        /// </summary>
        /// <param name="reader">Xml text reader.</param>
        public void ParseFromXml(XmlTextReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            string dura = reader.GetAttribute("dura");

            if (string.IsNullOrEmpty(dura))
            {
                _duration = 0;
            }
            else
            {
                _duration = int.Parse(dura, CultureInfo.InvariantCulture);
            }

            string qdura = reader.GetAttribute("qdura");

            if (string.IsNullOrEmpty(qdura))
            {
                _quanDuration = 0;
            }
            else
            {
                _quanDuration = int.Parse(qdura, CultureInfo.InvariantCulture);
            }

            _scriptUvSegs = new Collection<ScriptUvSeg>();

            if (!reader.IsEmptyElement)
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "segment")
                    {
                        SegmentInterval segmentInterval = new SegmentInterval();
                        segmentInterval.ParseFromXml(reader);
                        _segmentIntervals.Add(segmentInterval);
                    }
                    else if (reader.NodeType == XmlNodeType.Element && reader.Name == "uvseg")
                    {
                        ScriptUvSeg uvSeg = new ScriptUvSeg();
                        uvSeg.ParseFromXml(reader);

                        _scriptUvSegs.Add(uvSeg);
                    }
                    else if (reader.NodeType == XmlNodeType.Element && reader.Name == "pow")
                    {
                        _powContour = new ScriptPowerContour(reader.Name);
                        _powContour.ParseFromXml(reader);
                    }
                    else if (reader.NodeType == XmlNodeType.Element && reader.Name == "qpow")
                    {
                        _powContourQuantized = new ScriptPowerContour(reader.Name);
                        _powContourQuantized.ParseFromXml(reader);
                    }
                    else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "acoustics")
                    {
                        break;
                    }
                }
            }
        }