private XmlElement BuildHeadSection() { XmlElement headSection = xmlDocument.CreateXmlElement("head"); var items = new List <Dictionary <string, string> > { new Dictionary <string, string> { { "name", "dtb:depth" }, { "content", "1" } }, new Dictionary <string, string> { { "name", "dtb:totalPageCount" }, { "content", "1" } }, new Dictionary <string, string> { { "name", "dtb:uid" }, { "content", GetBookId } }, new Dictionary <string, string> { { "name", "dtb:maxPageNumber" }, { "content", "0" } } }; foreach (var valuePair in items) { headSection.AppendElement("meta", valuePair); } return(headSection); }
private XmlElement BuildManifestSection() { XmlElement manifestSection = xmlDocument.CreateXmlElement("manifest"); //adding ncx file link Dictionary <string, string> attributes = new Dictionary <string, string>(); attributes["id"] = "ncx"; attributes["href"] = structure.Files.NcxFile; attributes["media-type"] = Resources.NcxMediaType; manifestSection.AppendElement("item", attributes); //adding content files links attributes["media-type"] = Resources.ContentMediaType; foreach (ZipEntry entry in file.GetContentFiles(structure.Directories.ContentFolder)) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(entry.FileName); contentItems.Add(fileNameWithoutExtension); attributes["id"] = "cnt_" + fileNameWithoutExtension; attributes["href"] = EpubHelper.GetRelativePath(structure.Directories.ContentFolder, entry.FileName); manifestSection.AppendElement("item", attributes); } //adding css files links attributes["media-type"] = Resources.CssMediaType; foreach (ZipEntry entry in file.SelectEntries("*.css", structure.Directories.CssFolderFullPath)) { attributes["id"] = "style_" + Path.GetFileNameWithoutExtension(entry.FileName); attributes["href"] = EpubHelper.GetRelativePath(structure.Directories.ContentFolder, entry.FileName); manifestSection.AppendElement("item", attributes); } //adding images files links foreach (ZipEntry entry in file.GetImageFiles(structure.Directories.ImageFolderFullPath)) { attributes["id"] = "img_" + Path.GetFileNameWithoutExtension(entry.FileName); attributes["href"] = EpubHelper.GetRelativePath(structure.Directories.ContentFolder, entry.FileName); attributes["media-type"] = EpubHelper.GetImageMediaType(entry.FileName); manifestSection.AppendElement("item", attributes); } return(manifestSection); }
private XmlElement BuildSpineSection() { Dictionary <string, string> attributes = new Dictionary <string, string>(); attributes["toc"] = "ncx"; XmlElement spineSection = xmlDocument.CreateXmlElement("spine", attributes); attributes.Clear(); if (contentItems.Count > 0) { attributes["linear"] = "yes"; foreach (string item in contentItems) { attributes["idref"] = "cnt_" + item; spineSection.AppendElement("itemref", attributes); } } return(spineSection); }
private XmlElement BuildNavMapSection() { XmlElement navMapSection = xmlDocument.CreateXmlElement("navMap"); Dictionary <string, string> attributes = new Dictionary <string, string>(); int id = 0; foreach (ZipEntry entry in file.GetContentFiles(structure.Directories.ContentFolder)) { id++; attributes["playOrder"] = id.ToString(); attributes["id"] = "id" + id; navMapSection .AppendElement(xmlDocument.CreateXmlElement("navPoint", attributes) .AppendElement(xmlDocument.CreateXmlElement("navLabel") .AppendTextElement("text", option == TocOptions.ByTitleTag ? entry.Comment : Path.GetFileNameWithoutExtension(entry.FileName))) .AppendElement("content", new KeyValuePair <string, string>("src", Path.GetFileName(entry.FileName)))); } return(navMapSection); }