Пример #1
0
        /// <summary> Add a new page to this collection. </summary>
        /// <param name="Page"> Template_Page object for this new page </param>
        /// <returns> The index for this new page </returns>
        public int Add(Template_Page Page)
        {
            // Add the page to the list and keep the index
            int returnVal = List.Add(Page);

            // Return the index
            return(returnVal);
        }
Пример #2
0
        /// <summary> Remove an existing page from this collection. </summary>
        /// <param name="Page"> Page to remove from this collection. </param>
        /// <exception cref="ApplicationException"> Throws a <see cref="ApplicationException"/> if the specified
        /// <see cref="Template_Page"/> object to remove is not in this collection. </exception>
        public void Remove(Template_Page Page)
        {
            // Check to see if this page exists in this collection
            if (!Contains(Page))
            {
                throw new ApplicationException("The specified page does not exist in this collection.");
            }

            // Remove the page which does exist
            List.Remove(Page);
        }
Пример #3
0
 /// <summary> Check to see if a page currently exists in this collection.  </summary>
 /// <param name="Page"> Page to check for existence in this collection. </param>
 /// <returns>TRUE if the provided page is already part of this Collection </returns>
 public bool Contains(Template_Page Page)
 {
     return(List.Contains(Page));
 }
        private void process_inputs(XmlNodeReader nodeReader, Template thisTemplate)
        {
            // Keep track of the current pages and panels
            Template_Page  currentPage  = null;
            Template_Panel currentPanel = null;
            bool           inPanel      = false;

            // Read all the nodes
            while (nodeReader.Read())
            {
                // Get the node name, trimmed and to upper
                string nodeName = nodeReader.Name.Trim().ToUpper();

                // If this is the inputs or constant start tag, return
                if (((nodeReader.NodeType == XmlNodeType.EndElement) && (nodeName == "INPUTS")) ||
                    ((nodeReader.NodeType == XmlNodeType.Element) && (nodeReader.Name == "CONSTANTS")))
                {
                    return;
                }

                // If this is the beginning tag for an element, assign the next values accordingly
                if (nodeReader.NodeType == XmlNodeType.Element)
                {
                    // Does this start a new page?
                    if (nodeName == "PAGE")
                    {
                        // Set the inPanel flag to false
                        inPanel = false;

                        // Create the new page and add to this template
                        currentPage = new Template_Page();
                        thisTemplate.InputPages.Add(currentPage);
                    }

                    // Does this start a new panel?
                    if (nodeName == "PANEL")
                    {
                        // Set the inPanel flag to true
                        inPanel = true;

                        // Create the new panel and add to the current page
                        currentPanel = new Template_Panel();
                        if (currentPage != null)
                        {
                            currentPage.Panels.Add(currentPanel);
                        }
                    }

                    // Is this a name element?
                    if (nodeName == "NAME")
                    {
                        // Determine the language
                        Template_Language language;
                        if (nodeReader.HasAttributes)
                        {
                            nodeReader.MoveToFirstAttribute();
                            language = Template_Language_Convertor.ToEnum(nodeReader.Value);
                        }
                        else
                        {
                            language = DEFAULT_LANGUAGE;
                        }

                        // Get the text
                        string title = read_text_node(nodeReader);

                        // Set the name for either the page or panel
                        if (inPanel)
                        {
                            currentPanel.Set_Title(language, title);
                        }
                        else
                        {
                            if (currentPage != null)
                            {
                                currentPage.Set_Title(language, title);
                            }
                        }
                    }

                    // Is this a new element?
                    if ((nodeName == "ELEMENT") && (nodeReader.HasAttributes))
                    {
                        abstract_Element currentElement = process_element(nodeReader);
                        if ((currentElement != null) && (currentPanel != null))
                        {
                            currentPanel.Elements.Add(currentElement);
                        }
                    }
                }
            }
        }