Example #1
0
        /// <summary>
        /// Builds the list of pages
        /// </summary>
        private void BuildPageList()
        {
            Queue <DirmComponent> pageHeaders = new Queue <DirmComponent>(Directory.Components.Where(x => x.IsPage));
            Queue <TH44Chunk>     thumbnail   = new Queue <TH44Chunk>(FormChunk.GetChildrenItems <TH44Chunk>());

            DjviChunk[] sharedItems = FormChunk.GetChildrenItems <DjviChunk>();

            List <DjvuPage> pages = new List <DjvuPage>();

            int pageCount = 1;

            foreach (IFFChunk child in FormChunk.Children)
            {
                if (child is FormChunk)
                {
                    FormChunk form = (FormChunk)child;

                    if (form.Children.Any(x => x.ChunkType == ChunkTypes.Form_Djvu))
                    {
                        DirmComponent currentHeader    = pageHeaders.Count() > 0 ? pageHeaders.Dequeue() : null;
                        TH44Chunk     currentThumbnail = thumbnail.Count() > 0 ? thumbnail.Dequeue() : null;
                        DjvuPage      newPage          = new DjvuPage(pageCount++, this, currentHeader, currentThumbnail, sharedItems, form);

                        pages.Add(newPage);
                    }
                }
            }

            Pages = pages.ToArray();
        }
Example #2
0
        /// <summary>
        /// Gets a chunk type by the given ID
        /// </summary>
        /// <typeparam name="TItem"></typeparam>
        /// <param name="ID"></param>
        /// <returns></returns>
        public TItem GetChunkByID <TItem>(string ID) where TItem : IFFChunk
        {
            if (Directory == null)
            {
                return(null);
            }

            DirmComponent component = Directory.Components.FirstOrDefault(x => x.ID == ID);

            if (component == null)
            {
                return(null);
            }

            TItem[] children = FormChunk.GetChildrenItems <TItem>().ToArray();
            TItem   child    = children.Where(x => x.Offset - 8 == component.Offset).FirstOrDefault();

            return(child);
        }