Add_Page() private method

Adds a new template page to the collection of pages contained within this template
private Add_Page ( SobekCM.Library.Citation.Template.Template_Page NewPage ) : void
NewPage SobekCM.Library.Citation.Template.Template_Page New template page to add
return void
        private void process_inputs( XmlNodeReader nodeReader, CompleteTemplate ThisCompleteTemplate, bool exclude_divisions )
        {
            // 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 CompleteTemplate
                        currentPage = new Template_Page();
                        ThisCompleteTemplate.Add_Page( currentPage );
                    }

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

                        // Create the new panel and add to the current page
                        currentPanel = new Template_Panel();
                        currentPage.Add_Panel( currentPanel );
                    }

                    // Is this a name element?
                    if ((nodeName == "NAME") && (currentPage != null))
                    {
                        // Get the text
                        string title = read_text_node( nodeReader );

                        // Set the name for either the page or panel
                        if ( inPanel )
                        {
                            currentPanel.Title = title;
                        }
                        else
                        {
                            currentPage.Title = title;
                        }
                    }

                    // Is this a name element?
                    if ((nodeName == "INSTRUCTIONS") && (currentPage != null))
                    {
                        // Get the text
                        string instructions = read_text_node(nodeReader);

                        // Set the name for either the page or panel
                        if (!inPanel)
                        {
                            currentPage.Instructions = instructions;
                        }
                    }

                    // Is this a new element?
                    if ((nodeName == "ELEMENT") && (nodeReader.HasAttributes) && (currentPanel != null))
                    {
                        abstract_Element currentElement = process_element( nodeReader, ThisCompleteTemplate.InputPages.Count );
                        if (( currentElement != null ) && (( !exclude_divisions ) || ( currentElement.Type != Element_Type.Structure_Map )))
                            currentPanel.Add_Element( currentElement );
                    }
                }
            }
        }
示例#2
0
        private void process_inputs(XmlNodeReader nodeReader, CompleteTemplate ThisCompleteTemplate, bool exclude_divisions)
        {
            // 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 CompleteTemplate
                        currentPage = new Template_Page();
                        ThisCompleteTemplate.Add_Page(currentPage);
                    }

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

                        // Create the new panel and add to the current page
                        currentPanel = new Template_Panel();
                        currentPage.Add_Panel(currentPanel);
                    }

                    // Is this a name element?
                    if ((nodeName == "NAME") && (currentPage != null))
                    {
                        // Get the text
                        string title = read_text_node(nodeReader);

                        // Set the name for either the page or panel
                        if (inPanel)
                        {
                            currentPanel.Title = title;
                        }
                        else
                        {
                            currentPage.Title = title;
                        }
                    }

                    // Is this a name element?
                    if ((nodeName == "INSTRUCTIONS") && (currentPage != null))
                    {
                        // Get the text
                        string instructions = read_text_node(nodeReader);

                        // Set the name for either the page or panel
                        if (!inPanel)
                        {
                            currentPage.Instructions = instructions;
                        }
                    }

                    // Is this a new element?
                    if ((nodeName == "ELEMENT") && (nodeReader.HasAttributes) && (currentPanel != null))
                    {
                        abstract_Element currentElement = process_element(nodeReader, ThisCompleteTemplate.InputPages.Count);
                        if (currentElement != null)
                        {
                            currentPanel.Add_Element(currentElement);
                        }
                    }
                }
            }
        }