Beispiel #1
0
        private static List <EpubNavigationItemRef> GetNavigationItems(EpubBookRef bookRef, Epub3NavOl epub3NavOl)
        {
            List <EpubNavigationItemRef> result = new List <EpubNavigationItemRef>();

            if (epub3NavOl != null && epub3NavOl.Lis != null)
            {
                foreach (Epub3NavLi epub3NavLi in epub3NavOl.Lis)
                {
                    if (epub3NavLi != null && (epub3NavLi.Anchor != null || epub3NavLi.Span != null))
                    {
                        if (epub3NavLi.Anchor != null)
                        {
                            Epub3NavAnchor        navAnchor         = epub3NavLi.Anchor;
                            EpubNavigationItemRef navigationItemRef = EpubNavigationItemRef.CreateAsLink();
                            navigationItemRef.Title = GetFirstNonEmptyHeader(navAnchor.Text, navAnchor.Title, navAnchor.Alt);
                            navigationItemRef.Link  = new EpubNavigationItemLink(navAnchor.Href);
                            navigationItemRef.HtmlContentFileRef = GetHtmlContentFileRef(bookRef, navigationItemRef.Link.ContentFileName);
                            navigationItemRef.NestedItems        = GetNavigationItems(bookRef, epub3NavLi.ChildOl);
                            result.Add(navigationItemRef);
                        }
                        else if (epub3NavLi.Span != null)
                        {
                            Epub3NavSpan          navSpan           = epub3NavLi.Span;
                            EpubNavigationItemRef navigationItemRef = EpubNavigationItemRef.CreateAsHeader();
                            navigationItemRef.Title       = GetFirstNonEmptyHeader(navSpan.Text, navSpan.Title, navSpan.Alt);
                            navigationItemRef.NestedItems = GetNavigationItems(bookRef, epub3NavLi.ChildOl);
                            result.Add(navigationItemRef);
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #2
0
        private static List <EpubNavigationItemRef> GetNavigationItems(EpubBookRef bookRef, Epub3Nav epub3Nav)
        {
            List <EpubNavigationItemRef> result;

            if (epub3Nav != null)
            {
                if (epub3Nav.Head != null)
                {
                    result = new List <EpubNavigationItemRef>();
                    EpubNavigationItemRef navigationItemRef = EpubNavigationItemRef.CreateAsHeader();
                    navigationItemRef.Title       = epub3Nav.Head;
                    navigationItemRef.NestedItems = GetNavigationItems(bookRef, epub3Nav.Ol);
                    result.Add(navigationItemRef);
                }
                else
                {
                    result = GetNavigationItems(bookRef, epub3Nav.Ol);
                }
            }
            else
            {
                result = new List <EpubNavigationItemRef>();
            }
            return(result);
        }