Exemple #1
0
        /// <summary>
        /// Adds a NVG element to this view model.
        /// </summary>
        /// <param name="nvgElement">The NVG element which should be added.</param>
        public void AddElement(INvgElement nvgElement)
        {
            if (null == nvgElement)
            {
                throw new ArgumentNullException(nameof(nvgElement));
            }

            _nvgElements.Add(nvgElement);
        }
Exemple #2
0
 /// <summary>
 /// Creates a new element position.
 /// </summary>
 /// <param name="element">The current element.</param>
 /// <param name="elementTag">The element tag of the specified element.</param>
 /// <param name="elementPosition">The previous element position.</param>
 /// <returns>A new element position.</returns>
 private static NvgElementPosition CreateElementPosition(INvgElement element, NvgElementTag elementTag, NvgElementPosition elementPosition)
 {
     return(new NvgElementPosition
     {
         Element = element,
         ElementTag = elementTag,
         PreviousElementPosition = elementPosition
     });
 }
Exemple #3
0
        /// <summary>
        /// Reads the next NVG element from the stream.
        /// </summary>
        /// <returns>The next NVG element or <code>null</code> when there are no more NVG elements.</returns>
        public INvgElement ReadNextElement()
        {
            NvgElementPosition elementPosition = null;
            INvgElement        element         = null;

            while (_xmlTextReader.Read())
            {
                switch (_xmlTextReader.NodeType)
                {
                case XmlNodeType.Element:
                    var startTag = new NvgElementTag(_xmlTextReader.LocalName);
                    if (startTag.IsNvgTag)
                    {
                        // Read the NVG element
                        element = new NvgElement();
                        element.ConstructFromReader(_xmlTextReader);
                        elementPosition = CreateElementPosition(element, startTag, elementPosition);
                    }
                    else if (startTag.IsGroupTag)
                    {
                        // Read the NVG group element
                        element = new NvgGroupElement();
                        element.ConstructFromReader(_xmlTextReader);
                        elementPosition = CreateElementPosition(element, startTag, elementPosition);
                    }
                    else if (startTag.IsPointTag)
                    {
                        // Read the NVG point element
                        element = new NvgPointElement();
                        element.ConstructFromReader(_xmlTextReader);
                        elementPosition = CreateElementPosition(element, startTag, elementPosition);
                    }
                    break;

                case XmlNodeType.EndElement:
                    var endTag = new NvgElementTag(_xmlTextReader.LocalName);

                    // Add children and reset the position to the matching start tag
                    elementPosition = AddChildren(elementPosition, endTag);
                    if (null != elementPosition)
                    {
                        // Reset the current element to the start tag
                        element = elementPosition.Element;
                    }
                    if (endTag.IsNvgTag)
                    {
                        return(element);
                    }
                    break;
                }
            }
            return(null);
        }
Exemple #4
0
        private ulong ProcessAllMessages(INvgElement nvgElement, MessageLayer messageLayer)
        {
            ulong messageCount    = 0;
            var   nvgPointElement = nvgElement as NvgPointElement;

            if (TryProcessMessage(nvgPointElement, messageLayer))
            {
                messageCount++;
            }
            foreach (var nvgChildElement in nvgElement.Children)
            {
                messageCount += ProcessAllMessages(nvgChildElement, messageLayer);
            }
            return(messageCount);
        }