Example #1
0
        protected override void Populate()
        {
            try
            {
                if (_pages == null)
                {
                    DirectoryEntries files = new DirectoryEntries(this.Path, "*");
                    var pages = new List <BblPage>();
                    using (FastDirectoryEnumerator fde = (FastDirectoryEnumerator)files.GetEnumerator())
                    {
                        while (fde.MoveNext())
                        {
                            _cancelPopulateTask.Token.ThrowIfCancellationRequested();

                            var data = fde.Current;
                            if ((data.dwFileAttributes & FileAttributes.Directory) == FileAttributes.Directory)
                            {
                                continue;
                            }
                            string path = System.IO.Path.Combine(Path, data.cFileName);
                            string ext  = System.IO.Path.GetExtension(path);
                            if (IsImageFileExtension(ext))
                            {
                                BblPage page = new BblPage(this);
                                page.Filename       = data.cFileName;
                                page.Path           = System.IO.Path.Combine(Path, data.cFileName);
                                page.Size           = data.Length;
                                page.CreationTime   = data.CreationTime;
                                page.LastAccessTime = data.LastAccessTime;
                                page.LastWriteTime  = data.LastWriteTime;


                                lock (_lock) { pages.Add(page); }
                            }
                        }
                    }
                    if (pages.Count == 0)
                    {
                        return;
                    }
                    pages.Sort();
                    lock (_lock) { _pages = new ObservableCollection <BblPage>(pages); }
                }
            }
            catch { UnPopulate(); }
        }
Example #2
0
        protected void EnumerateChildren()
        {
            DirectoryEntries files = new DirectoryEntries(this.Path, "*");

            if (Path == "D:\\pix\\mixes weekly\\Nouveau dossier")
            {
            }
            bool img = false;

            using (FastDirectoryEnumerator e = (FastDirectoryEnumerator)files.GetEnumerator())
            {
                while (e.MoveNext())
                {
                    var data = e.Current;
                    if (data.cFileName == "." || data.cFileName == "..")
                    {
                        continue;
                    }
                    string path = System.IO.Path.Combine(Path, data.cFileName);

                    bool   isfolder = ((data.dwFileAttributes & FileAttributes.Directory) == FileAttributes.Directory);
                    string ext      = System.IO.Path.GetExtension(path);
                    if (isfolder)
                    {
                        if (IsBblBookDirectoryExtension(ext))
                        {
                            AddChild(new BblBookDirectory(Root, this, data));
                        }
                        else
                        {
                            AddChild(new BblLibraryNode(Root, this, data));
                        }
                    }
                    else
                    {
                        if (!img && IsImageFileExtension(ext))
                        {
                            var lastWrite = data.LastWriteTime;
                            LastWriteTime = lastWrite;
                            if (!IsBook)
                            {
                                Root.AddPromotable(this);
                            }
                            img        = true;
                            FirstImage = path;
                        }
                        else if (IsArchiveFileExtension(ext))
                        {
                            AddChild(new BblBookArchive(Root, this, data));
                        }
                        else if (IsPDF(ext))
                        {
                            AddChild(new BblBookPdf(Root, this, data));
                        }
                    }
                }
            }
            if (!IsBook && IsFolder && (_children == null || _children.Count == 0))
            {
            }
        }