/// <summary> /// Swap constructor, takes a generic BblLibraryNode (normal directory, not book) that is to be replaced with a BblBook /// Happens when the node for an empty directory is promoted to book status because there's now an image in it. /// </summary> protected BblBook(BblLibraryNode node, BookType type) : base(node) { Type = type; BblBook b = node as BblBook; if (b != null) { Root.OnBookOperation(new BookOperationData(this, BookOperations.Replace, node as BblBook)); Index = b.Index; _pages = b._pages; } else { Root.OnBookOperation(new BookOperationData(this, BookOperations.Add, null)); Index = Root.BookIndex++; Root.BookCount++; } }
public void OnBookOperation(BookOperationData data) { BblBook b = data.b; BookOperations operation = data.operation; BblBook replace = data.replace; if (operation == BookOperations.Add) { lock (b.NodeLock) _books.Add(b); } else if (operation == BookOperations.Replace) { lock (b.NodeLock) _books[_books.IndexOf(replace)] = b; } else if (operation == BookOperations.Remove) { lock (b.NodeLock) _books.Remove(b); } }
public BblLibraryNode RenameFile(string newPath, string oldPath) { var old = new FileInfoEx(oldPath); var f = new FileInfoEx(newPath); if (IsArchiveFileExtension(old.Extension) || BblBook.IsPDF(old.Extension)) { var node = FindChild(old); if (node != null) { return(node.OnFileSystemEntryRenamed(f)); } } else if (IsImageFileExtension(old.Extension)) { var node = FindChild(old.Parent); if (node != null && node is BblBookDirectory) { (node as BblBookDirectory).OnPageFileRenamed(old, f); return(node); } } return(null); }
public BblPage(BblBook book) { Book = book; }
public BookOperationData(BblBook b, BookOperations operation, BblBook replace) { this.b = b; this.operation = operation; this.replace = replace; }