Exemplo n.º 1
0
 /// <summary>
 /// Removes a page from the list describing the order of pages in the document.
 /// </summary>
 /// <param name="page">The page to remove.</param>
 public void RemovePageFromPageOrder(Page page)
 {
     if (PageOrder.IndexOf(page) != -1)
     {
         PageOrder.Remove(page);
     }
     else
     {
         throw new Exception("Page must be in the page index.");
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Adds a page to the list describing the order of pages in the document.
 /// </summary>
 /// <param name="page">The page to add.</param>
 /// <param name="after">The page to add <paramref name="page"/> after, or <c>null</c> to add
 /// the page to the end of the order.</param>
 public void AddPageToPageOrder(Page page, Page after = null)
 {
     if (PageOrder.IndexOf(page) == -1)
     {
         int insertIndex = after == null ? PageOrder.Count : PageOrder.IndexOf(after);
         PageOrder.Insert(insertIndex, page);
     }
     else
     {
         throw new Exception("Page must not already be in the page order.");
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Swaps the order of two pages in the list describing the order of pages in the document.
        /// </summary>
        /// <param name="page1">The pages to swap.</param>
        /// <param name="page2">The pages to swap.</param>
        public void SwapPages(Page page1, Page page2)
        {
            int page1Index = PageOrder.IndexOf(page1),
                page2Index = PageOrder.IndexOf(page2);

            if (page1Index == -1 || page2Index == -1)
            {
                throw new Exception("Both pages must be in the page order.");
            }
            else
            {
                PageOrder.RemoveAt(page1Index);
                PageOrder.Insert(page1Index, page2);
                PageOrder.RemoveAt(page2Index);
                PageOrder.Insert(page2Index, page1);
            }
        }