예제 #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);
        }
예제 #2
0
        private static List <EpubNavigationItemRef> GetNavigationItems(EpubBookRef bookRef, List <Epub2NcxNavigationPoint> navigationPoints)
        {
            List <EpubNavigationItemRef> result = new List <EpubNavigationItemRef>();

            if (navigationPoints != null)
            {
                foreach (Epub2NcxNavigationPoint navigationPoint in navigationPoints)
                {
                    EpubNavigationItemRef navigationItemRef = EpubNavigationItemRef.CreateAsLink();
                    navigationItemRef.Title = navigationPoint.NavigationLabels.First().Text;
                    navigationItemRef.Link  = new EpubNavigationItemLink(navigationPoint.Content.Source);
                    navigationItemRef.HtmlContentFileRef = GetHtmlContentFileRef(bookRef, navigationItemRef.Link.ContentFileName);
                    navigationItemRef.NestedItems        = GetNavigationItems(bookRef, navigationPoint.ChildNavigationPoints);
                    result.Add(navigationItemRef);
                }
            }
            return(result);
        }