Bloom.Book.SizeAndOrientation.UpdatePageSizeAndOrientationClasses C# (CSharp) Method

UpdatePageSizeAndOrientationClasses() public static method

public static UpdatePageSizeAndOrientationClasses ( XmlNode node, Layout layout ) : void
node System.Xml.XmlNode
layout Layout
return void
        public static void UpdatePageSizeAndOrientationClasses(XmlNode node, Layout layout)
        {
            foreach (XmlElement pageDiv in node.SafeSelectNodes("descendant-or-self::div[contains(@class,'bloom-page')]"))
            {
                RemoveClassesContaining(pageDiv, "layout-");
                RemoveClassesContaining(pageDiv, "Landscape");
                RemoveClassesContaining(pageDiv, "Portrait");

                foreach (var cssClassName in layout.ClassNames)
                {
                    AddClass(pageDiv, cssClassName);
                }
            }
        }

Usage Example

        /// <summary>
        /// Some book layouts rely on the first page facing the second page. A Wall Calendar is one example.
        /// Here we check if the first content page has this requirement and, if so, we insert a blank "flyleaf"
        /// page.
        /// </summary>
        private void InjectFlyleafIfNeeded(Layout layout)
        {
            // the "inside" here means "not counting the cover"
            var numberOfFrontMatterPagesInside   = XMatterDom.SafeSelectNodes("//div[contains(@class,'bloom-frontMatter')]").Count - 1;
            var firstPageWouldNotBePartOfASpread = numberOfFrontMatterPagesInside % 2 != 0;

            if (firstPageWouldNotBePartOfASpread)
            {
                var lastFrontMatterPage = _bookDom.SelectSingleNode("//div[contains(@class,'bloom-frontMatter')][last()]");

                var firstContentPageAndAlsoStartsSpread = _bookDom.SelectSingleNode(
                    "//div[contains(@class,'bloom-frontMatter')][last()]"                     // last frontmatter page
                    + "/following-sibling::div[contains(@data-page, 'spread-start')]");
                // page after that says it needs to be facing the next page
                if (firstContentPageAndAlsoStartsSpread != null)
                {
                    var flyDom = new XmlDocument();
                    flyDom.LoadXml(@"
						<div class='bloom-flyleaf bloom-frontMatter bloom-page' data-page='required singleton'>
							<div class='pageLabel'>Flyleaf</div>
							<div style='height: 100px; width:100%'
								data-hint='This page was automatically inserted because the following page is marked as part of a two page spread.'>
							</div>
						</div>"                        );
                    var flyleaf = _bookDom.RawDom.ImportNode(flyDom.FirstChild, true) as XmlElement;
                    flyleaf.SetAttribute("id", Guid.NewGuid().ToString());
                    lastFrontMatterPage.ParentNode.InsertAfter(flyleaf, lastFrontMatterPage);
                    SizeAndOrientation.UpdatePageSizeAndOrientationClasses(flyleaf, layout);
                }
            }
        }
All Usage Examples Of Bloom.Book.SizeAndOrientation::UpdatePageSizeAndOrientationClasses