Inheritance: TitledResourceReference
 /// <summary>
 /// Adds the given Resources to the TableOfContents at the location specified by
 /// the pathElements.  Example: Calling this method with a Resource and new int[]
 /// {0, 0} will result in the following:
 ///            <ul>
 ///            <li>a TOCReference at the root level.<br/> If this TOCReference did
 /// not yet exist it will have been created with a title of "" and does not point
 /// to any resource</li>
 ///            <li>A TOCReference that points to the given resource and is a child
 /// of the previously created TOCReference.<br/> If this TOCReference didn't exist
 /// yet it will be created and have a title of ""</li>
 ///            </ul>
 /// </summary>
 /// <param name="resource"></param>
 /// <param name="pathElements"></param>
 /// <param name="sectionTitlePrefix"></param>
 /// <param name="sectionNumberSeparator"></param>
 public TOCReference addSection(Resource resource, int[] pathElements, string sectionTitlePrefix, string sectionNumberSeparator)
 {
     if (pathElements == null || pathElements.Length == 0)
     {
         return null;
     }
     TOCReference result = null;
     List<TOCReference> currentTocReferences = this.tocReferences;
     for (int i = 0; i < pathElements.Length; i++)
     {
         int currentIndex = pathElements[i];
         if (currentIndex > 0 && currentIndex < (currentTocReferences.Count - 1))
         {
             result = currentTocReferences[currentIndex];
         }
         else
         {
             result = null;
         }
         if (result == null)
         {
             paddTOCReferences(currentTocReferences, pathElements, i, sectionTitlePrefix, sectionNumberSeparator);
             result = currentTocReferences[currentIndex];
         }
         currentTocReferences = result.getChildren();
     }
     result.setResource(resource);
     return result;
 }
 /// 
 /// <param name="tocReference"></param>
 public TOCReference addTOCReference(TOCReference tocReference)
 {
     if (tocReferences == null)
     {
         tocReferences = new List<TOCReference>();
     }
     tocReferences.Add(tocReference);
     return tocReference;
 }
Example #3
0
 /// <summary>
 /// Adds the resource to the table of contents of the book as a child section of
 /// the given parentSection
 /// </summary>
 /// <param name="parentSection"></param>
 /// <param name="sectionTitle"></param>
 /// <param name="resource"></param>
 public TOCReference addSection(TOCReference parentSection, string sectionTitle, Resource resource)
 {
     getResources().add(resource);
     if (spine.findFirstResourceById(resource.getId()) < 0)
     {
         spine.addSpineReference(new SpineReference(resource));
     }
     return parentSection.addChildSection(new TOCReference(sectionTitle, resource));
 }
Example #4
0
 /// <summary>
 /// Adds the resource to the table of contents of the book as a child section of
 /// the given parentSection
 /// </summary>
 /// <param name="parentSection"></param>
 /// <param name="sectionTitle"></param>
 /// <param name="resource"></param>
 public TOCReference addSection(TOCReference parentSection, string sectionTitle, Resource resource)
 {
     getResources().add(resource);
     if (spine.findFirstResourceById(resource.getId()) < 0)
     {
         spine.addSpineReference(new SpineReference(resource));
     }
     return parentSection.addChildSection(new TOCReference(sectionTitle, resource));
 }
Example #5
0
 /// <summary>
 /// Adds a resource to the book's set of resources, table of contents and if there
 /// is no resource with the id in the spine also adds it to the spine.
 /// </summary>
 /// <param name="title"></param>
 /// <param name="resource"></param>
 public TOCReference addSection(string title, Resource resource)
 {
     getResources().add(resource);
     TOCReference tocReference = tableOfContents.addTOCReference(new TOCReference(title, resource));
     if (spine.findFirstResourceById(resource.getId()) < 0)
     {
         spine.addSpineReference(new SpineReference(resource));
     }
     return tocReference;
 }
 /// <summary>
 /// Adds the given Resources to the TableOfContents at the location specified by
 /// the pathElements.  Example: Calling this method with a Resource and new
 /// String[] {"chapter1", "paragraph1"} will result in the following:
 ///            <ul>
 ///            <li>a TOCReference with the title "chapter1" at the root level.<br/>
 /// If this TOCReference did not yet exist it will have been created and does not
 /// point to any resource</li>
 ///            <li>A TOCReference that has the title "paragraph1". This
 /// TOCReference will be the child of TOCReference "chapter1" and will point to the
 /// given Resource</li>
 ///            </ul>
 /// </summary>
 /// <param name="resource"></param>
 /// <param name="pathElements"></param>
 public TOCReference addSection(Resource resource, String[] pathElements)
 {
     if (pathElements == null || pathElements.Length == 0)
     {
         return null;
     }
     TOCReference result = null;
     List<TOCReference> currentTocReferences = this.tocReferences;
     for (int i = 0; i < pathElements.Length; i++)
     {
         String currentTitle = pathElements[i];
         result = findTocReferenceByTitle(currentTitle, currentTocReferences);
         if (result == null)
         {
             result = new TOCReference(currentTitle, null);
             currentTocReferences.Add(result);
         }
         currentTocReferences = result.getChildren();
     }
     result.setResource(resource);
     return result;
 }
 /// 
 /// <param name="tocReference"></param>
 public TOCReference addTOCReference(TOCReference tocReference)
 {
     if (tocReferences == null)
     {
         tocReferences = new List<TOCReference>();
     }
     tocReferences.Add(tocReference);
     return tocReference;
 }
 /// <summary>
 /// Adds the given Resources to the TableOfContents at the location specified by
 /// the pathElements.  Example: Calling this method with a Resource and new
 /// String[] {"chapter1", "paragraph1"} will result in the following:
 ///            <ul>
 ///            <li>a TOCReference with the title "chapter1" at the root level.<br/>
 /// If this TOCReference did not yet exist it will have been created and does not
 /// point to any resource</li>
 ///            <li>A TOCReference that has the title "paragraph1". This
 /// TOCReference will be the child of TOCReference "chapter1" and will point to the
 /// given Resource</li>
 ///            </ul>
 /// </summary>
 /// <param name="resource"></param>
 /// <param name="pathElements"></param>
 public TOCReference addSection(Resource resource, String[] pathElements)
 {
     if (pathElements == null || pathElements.Length == 0)
     {
         return null;
     }
     TOCReference result = null;
     List<TOCReference> currentTocReferences = this.tocReferences;
     for (int i = 0; i < pathElements.Length; i++)
     {
         String currentTitle = pathElements[i];
         result = findTocReferenceByTitle(currentTitle, currentTocReferences);
         if (result == null)
         {
             result = new TOCReference(currentTitle, null);
             currentTocReferences.Add(result);
         }
         currentTocReferences = result.getChildren();
     }
     result.setResource(resource);
     return result;
 }
Example #9
0
 ///
 /// <param name="childSection"></param>
 public TOCReference addChildSection(TOCReference childSection)
 {
     this.children.Add(childSection);
     return(childSection);
 }
Example #10
0
 /// 
 /// <param name="childSection"></param>
 public TOCReference addChildSection(TOCReference childSection)
 {
     this.children.Add(childSection);
     return childSection;
 }