Beispiel #1
0
        private TocItem FindItem(int pagenumber)
        {
            DirectoryInfo dataFolder = DataFolder;
            FileInfo      tocDki     = dataFolder.GetFileIgnoreCase(TreeDki);
            FileInfo      tocDka     = dataFolder.GetFileIgnoreCase(TreeDka);
            TocItem       item       = TocUtil.LoadTree(tocDki, tocDka);

            while (item.Pagenumber != pagenumber || item.Pagecount == 0)
            {
                List <TocItem> childrenReverse = item.ChildrenConcrete.AsEnumerable().Reverse().ToList();
                TocItem        child           = childrenReverse.Find(c => c.Pagenumber <= pagenumber);
                if (child == null)
                {
                    break;
                }

                item = child;
            }

            while (item.Pagecount == 0 && item.ParentConcrete != null)
            {
                item = item.ParentConcrete;
            }

            return(item);
        }
Beispiel #2
0
        public Task <ITocItem> QueryToc(string pattern, IEnumerable <ICategoryItem> categories)
        {
            DirectoryInfo dataFolder = DataFolder;
            FileInfo      treeDki    = dataFolder.GetFileIgnoreCase(TreeDki);
            FileInfo      treeDka    = dataFolder.GetFileIgnoreCase(TreeDka);
            TocItem       root       = TocUtil.LoadTree(treeDki, treeDka);

            return(Task.FromResult <ITocItem>(root));
        }
Beispiel #3
0
        public Task <bool> Html(int pagenumber, DirectoryInfo folder, string highlight)
        {
            string filename = Path.Combine(folder.FullName,
                                           Path.ChangeExtension(pagenumber.ToString(), html.ToString()));
            ISet <int> highlightedOffsets = string.IsNullOrWhiteSpace(highlight)
                ? new HashSet <int>()
                : SearchUtil.HighlightedOffsets(pagenumber, highlight, DataFolder);

            using (HtmlWriter writer = new HtmlWriter(new FileStream(filename, FileMode.Create, FileAccess.Write),
                                                      pagenumber, highlightedOffsets))
            {
                TocItem            item  = FindItem(pagenumber);
                IEnumerable <Page> pages = PageUtil.LoadPages(DataFolder.GetFileIgnoreCase(TextDki), item.Pagenumber,
                                                              item.Pagecount);
                foreach (Page page in pages)
                {
                    PageUtil.Parse(page, writer);
                }

                DumpImages(writer.ImageIdsToExtensions, folder);
            }

            return(Task.FromResult(true));
        }
Beispiel #4
0
 public void AddChild(TocItem item)
 {
     item.ParentConcrete = this;
     ChildrenConcrete.Add(item);
 }