Ejemplo n.º 1
0
        public string GetContentFile(ePUBNavPoint point)
        {
            string result = GetRoot();

            result = Path.Combine(result, point.Content);
            return(result);
        }
Ejemplo n.º 2
0
        private void ParseTOC(ePUB docPUB, Stream content)
        {
            try
            {
                //reading
                XmlDocument doc = GetDocumentWithNoValidation(content);

                XmlNode root = doc.DocumentElement;                 //<ncx>

                // resolve <ncx>
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
                ResolveNamespaces(nsmgr, root);

                ePUBTableNCX toc = docPUB.Container.Package.TableOfContent;
                toc.Title = root.SelectSingleNode("//ROOT:docTitle/ROOT:text", nsmgr).InnerText;

                XmlNodeList listNode;
                listNode = root.SelectNodes("child::ROOT:navMap/ROOT:navPoint", nsmgr);

                List <ePUBNavPoint> navMapList = new List <ePUBNavPoint>();
                foreach (XmlNode navPoint in listNode)
                {
                    ePUBNavPoint item = new ePUBNavPoint()
                    {
                        Id        = TryGetAttributeString(navPoint, "id"),
                        PlayOrder = TryGetAttributeInt(navPoint, "playOrder"),
                        Label     = navPoint.SelectSingleNode("child::ROOT:navLabel/ROOT:text", nsmgr).InnerText,
                        Content   = TryGetAttributeString(navPoint.SelectSingleNode("child::ROOT:content", nsmgr), "src")
                    };
                    string[] parts = item.Content.Split('#');
                    item.PageSource = parts[0];
                    if (parts.Count() == 2)
                    {
                        item.TargetId = parts[2];
                    }
                    item.XamlId = docPUB.Container.Package.Manifest.Items.Single(p => p.hRef == item.PageSource).XamlId;

                    //is there any bookmark?
                    if (item.Content.IndexOf('#') != -1)
                    {
                        item.Content = item.Content.Split('#')[1];
                    }

                    navMapList.Add(item);

                    item.Items = ParseNavRecursif(docPUB, navPoint, nsmgr);
                }
                toc.Items = navMapList;
            }
            catch (Exception err)
            {
                LogHelper.Manage("ePUBManager:ParseTOC", err);
            }
        }
Ejemplo n.º 3
0
        private List <ePUBNavPoint> ParseNavRecursif(ePUB docPUB, XmlNode node, XmlNamespaceManager nsmgr)
        {
            try
            {
                XmlNodeList listNode = node.SelectNodes("child::ROOT:navPoint", nsmgr);

                List <ePUBNavPoint> navMapList = new List <ePUBNavPoint>();
                foreach (XmlNode navPoint in listNode)
                {
                    ePUBNavPoint item = new ePUBNavPoint()
                    {
                        Id        = TryGetAttributeString(navPoint, "id"),
                        PlayOrder = TryGetAttributeInt(navPoint, "playOrder"),
                        Label     = navPoint.SelectSingleNode("child::ROOT:navLabel/ROOT:text", nsmgr).InnerText,
                        Content   = TryGetAttributeString(navPoint.SelectSingleNode("child::ROOT:content", nsmgr), "src")
                    };

                    //is there any bookmark?
                    if (item.Content.IndexOf('#') != -1)
                    {
                        item.Content = item.Content.Split('#')[1];
                    }

                    navMapList.Add(item);

                    item.Items = ParseNavRecursif(docPUB, navPoint, nsmgr);
                }

                return(navMapList);
            }
            catch (Exception err)
            {
                LogHelper.Manage("ePUBManager:ParseNavRecursif", err);
                return(null);
            }
        }