示例#1
0
 public BookTransfer(BloomParseClient bloomParseClient, BloomS3Client bloomS3Client, HtmlThumbNailer htmlThumbnailer, BookDownloadStartingEvent bookDownloadStartingEvent)
 {
     this._parseClient          = bloomParseClient;
     this._s3Client             = bloomS3Client;
     _htmlThumbnailer           = htmlThumbnailer;
     _bookDownloadStartingEvent = bookDownloadStartingEvent;
 }
示例#2
0
        public PageListView(PageSelection pageSelection,  RelocatePageEvent relocatePageEvent, EditingModel model,
			HtmlThumbNailer thumbnailProvider, NavigationIsolator isolator, ControlKeyEvent controlKeyEvent)
        {
            _pageSelection = pageSelection;
            _model = model;
            this.Font= SystemFonts.MessageBoxFont;
            InitializeComponent();

            _thumbNailList.Thumbnailer = thumbnailProvider;
            _thumbNailList.CanSelect = true;
            _thumbNailList.PreferPageNumbers = true;
            _thumbNailList.KeepShowingSelection = true;
            _thumbNailList.RelocatePageEvent = relocatePageEvent;
            _thumbNailList.PageSelectedChanged+=new EventHandler(OnPageSelectedChanged);
            _thumbNailList.Isolator = isolator;
            _thumbNailList.ControlKeyEvent = controlKeyEvent;
            // First action determines whether the menu item is enabled, second performs it.
            var menuItems = new List<WebThumbNailList.MenuItemSpec>();
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec() {
                    Label = LocalizationManager.GetString("EditTab.DuplicatePageButton", "Duplicate Page"), // same ID as button in toolbar));
                    EnableFunction = (page) => page != null && !page.Required && !_model.CurrentBook.LockedDown,
                    ExecuteCommand = (page) => _model.DuplicatePage(page)});
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec() {
                    Label = LocalizationManager.GetString("EditTab.DeletePageButton", "Remove Page"),  // same ID as button in toolbar));
                    EnableFunction = (page) => page != null && !page.Required && !_model.CurrentBook.LockedDown,
                    ExecuteCommand = (page) =>
                    {
                        if (ConfirmRemovePageDialog.Confirm())
                            _model.DeletePage(page);
                    }});
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec() {
                    Label = LocalizationManager.GetString("EditTab.ChooseLayoutButton", "Choose Different Layout"),
                    EnableFunction = (page) => page != null && !page.Required && !_model.CurrentBook.LockedDown,
                    ExecuteCommand = (page) => _model.ChangePageLayout(page)});
            // This adds the desired menu items to the Gecko context menu that happens when we right-click
            _thumbNailList.ContextMenuProvider = args =>
            {
                var page = _thumbNailList.GetPageContaining(args.TargetNode);
                if (page == null)
                    return true; // no page-related commands if we didn't click on one.
                if(page != _pageSelection.CurrentSelection)
                {
                    return true; //it's too dangerous to let users do thing to a page they aren't seeing
                }
                foreach (var item in menuItems)
                {
                    var menuItem = new MenuItem(item.Label, (sender, eventArgs) => item.ExecuteCommand(page));
                    args.ContextMenu.MenuItems.Add(menuItem);
                    menuItem.Enabled = item.EnableFunction(page);
                }
                return true;
            };
            // This sets up the context menu items that will be shown when the user clicks the
            // arrow in the thumbnail list.
            _thumbNailList.ContextMenuItems = menuItems;
        }
示例#3
0
        public BloomServer(CollectionSettings collectionSettings, BookCollection booksInProjectLibrary,
						   SourceCollectionsList sourceCollectionsesList, HtmlThumbNailer thumbNailer)
        {
            _collectionSettings = collectionSettings;
            _booksInProjectLibrary = booksInProjectLibrary;
            _sourceCollectionsesList = sourceCollectionsesList;
            _thumbNailer = thumbNailer;
        }
示例#4
0
 public BloomServer(CollectionSettings collectionSettings, BookCollection booksInProjectLibrary,
                    SourceCollectionsList sourceCollectionsesList, HtmlThumbNailer thumbNailer)
 {
     _collectionSettings      = collectionSettings;
     _booksInProjectLibrary   = booksInProjectLibrary;
     _sourceCollectionsesList = sourceCollectionsesList;
     _thumbNailer             = thumbNailer;
 }
 public BloomServer(CollectionSettings collectionSettings, BookCollection booksInProjectLibrary,
                    SourceCollectionsList sourceCollectionsesList, HtmlThumbNailer thumbNailer)
     : base(new LowResImageCache(new BookRenamedEvent()))
 {
     _collectionSettings      = collectionSettings;
     _booksInProjectLibrary   = booksInProjectLibrary;
     _sourceCollectionsesList = sourceCollectionsesList;
     _thumbNailer             = thumbNailer;
 }
        //autofac uses this
        public TemplatePagesView(BookSelection bookSelection, TemplateInsertionCommand templateInsertionCommand, HtmlThumbNailer thumbnailProvider)
        {
            _bookSelection = bookSelection;
            _templateInsertionCommand = templateInsertionCommand;

            this.Font = SystemFonts.MessageBoxFont;
            InitializeComponent();
            _thumbNailList.PageSelectedChanged += new EventHandler(OnPageClicked);
            _thumbNailList.Thumbnailer = thumbnailProvider;
        }
示例#7
0
 public PageListView(PageSelection pageSelection,  RelocatePageEvent relocatePageEvent, EditingModel model,HtmlThumbNailer thumbnailProvider)
 {
     _pageSelection = pageSelection;
     _model = model;
     this.Font= SystemFonts.MessageBoxFont;
     InitializeComponent();
     _thumbNailList.Thumbnailer = thumbnailProvider;
     _thumbNailList.CanSelect = true;
     _thumbNailList.PreferPageNumbers = true;
     _thumbNailList.KeepShowingSelection = true;
     _thumbNailList.RelocatePageEvent = relocatePageEvent;
     _thumbNailList.PageSelectedChanged+=new EventHandler(OnPageSelectedChanged);
 }
 public void Setup()
 {
     _workFolder     = new TemporaryFolder("unittest-" + _thisTestId);
     _workFolderPath = _workFolder.FolderPath;
     Assert.AreEqual(0, Directory.GetDirectories(_workFolderPath).Count(), "Some stuff was left over from a previous test");
     Assert.AreEqual(0, Directory.GetFiles(_workFolderPath).Count(), "Some stuff was left over from a previous test");
     // Todo: Make sure the S3 unit test bucket is empty.
     // Todo: Make sure the parse.com unit test book table is empty
     _parseClient              = new BloomParseClientDouble(_thisTestId);
     _htmlThumbNailer          = new HtmlThumbNailer(new NavigationIsolator());
     _transfer                 = new BookTransfer(_parseClient, new BloomS3Client(BloomS3Client.UnitTestBucketName), new BookThumbNailer(_htmlThumbNailer), new BookDownloadStartingEvent());
     _transfer.BookDownLoaded += (sender, args) => _downloadedBooks.Add(args.BookDetails);
 }
 public PublishModel(BookSelection bookSelection, PdfMaker pdfMaker, CurrentEditableCollectionSelection currentBookCollectionSelection, CollectionSettings collectionSettings, BookServer bookServer, HtmlThumbNailer htmlThumbNailer)
 {
     BookSelection = bookSelection;
     _pdfMaker     = pdfMaker;
     //_pdfMaker.EngineChoice = collectionSettings.PdfEngineChoice;
     _currentBookCollectionSelection = currentBookCollectionSelection;
     ShowCropMarks                   = false;
     _collectionSettings             = collectionSettings;
     _bookServer                     = bookServer;
     _htmlThumbNailer                = htmlThumbNailer;
     bookSelection.SelectionChanged += new EventHandler(OnBookSelectionChanged);
     //we don't want to default anymore: BookletPortion = BookletPortions.BookletPages;
 }
 public void Setup()
 {
     _workFolder     = new TemporaryFolder("unittest");
     _workFolderPath = _workFolder.FolderPath;
     Assert.AreEqual(0, Directory.GetDirectories(_workFolderPath).Count(), "Some stuff was left over from a previous test");
     Assert.AreEqual(0, Directory.GetFiles(_workFolderPath).Count(), "Some stuff was left over from a previous test");
     // Todo: Make sure the S3 unit test bucket is empty.
     // Todo: Make sure the parse.com unit test book table is empty
     _parseClient = new BloomParseClient();
     // These substitute keys target the "silbloomlibraryunittests" application so testing won't interfere with the real one.
     _parseClient.ApiKey         = "HuRkXoF5Z3hv8f3qHE4YAIrDjwNk4VID9gFxda1U";
     _parseClient.ApplicationKey = "r1H3zle1Iopm1IB30S4qEtycvM4xYjZ85kRChjkM";
     _htmlThumbNailer            = new HtmlThumbNailer(new NavigationIsolator());
     _transfer = new BookTransfer(_parseClient, new BloomS3Client(BloomS3Client.UnitTestBucketName), _htmlThumbNailer, new BookDownloadStartingEvent());
     _transfer.BookDownLoaded += (sender, args) => _downloadedBooks.Add(args.BookDetails);
 }
示例#11
0
        public Book(BookInfo info, IBookStorage storage, ITemplateFinder templateFinder,
		   CollectionSettings collectionSettings, HtmlThumbNailer thumbnailProvider,
			PageSelection pageSelection,
			PageListChangedEvent pageListChangedEvent,
			BookRefreshEvent bookRefreshEvent)
        {
            BookInfo = info;

            Guard.AgainstNull(storage,"storage");

            // This allows the _storage to
            storage.MetaData = info;

            _storage = storage;

            //this is a hack to keep these two in sync (in one direction)
            _storage.FolderPathChanged +=(x,y)=>BookInfo.FolderPath = _storage.FolderPath;

            _templateFinder = templateFinder;

            _collectionSettings = collectionSettings;

            _thumbnailProvider = thumbnailProvider;
            _pageSelection = pageSelection;
            _pageListChangedEvent = pageListChangedEvent;
            _bookRefreshEvent = bookRefreshEvent;
            _bookData = new BookData(OurHtmlDom,
                    _collectionSettings, UpdateImageMetadataAttributes);

            if (IsEditable && !HasFatalError)
            {
                _bookData.SynchronizeDataItemsThroughoutDOM();

                WriteLanguageDisplayStyleSheet(); //NB: if you try to do this on a file that's in program files, access will be denied
                OurHtmlDom.AddStyleSheet(@"languageDisplay.css");
            }

            FixBookIdAndLineageIfNeeded();
            _storage.Dom.RemoveExtraContentTypesMetas();
            Guard.Against(OurHtmlDom.RawDom.InnerXml=="","Bloom could not parse the xhtml of this document");
        }
示例#12
0
        public PageListView(PageSelection pageSelection, RelocatePageEvent relocatePageEvent, EditingModel model,
                            HtmlThumbNailer thumbnailProvider, NavigationIsolator isolator, ControlKeyEvent controlKeyEvent, PageListApi pageListApi, BloomWebSocketServer webSocketServer)
        {
            _pageSelection = pageSelection;
            _model         = model;
            this.Font      = SystemFonts.MessageBoxFont;
            InitializeComponent();
            _thumbNailList.PageListApi     = pageListApi;
            _thumbNailList.WebSocketServer = webSocketServer;
            this.BackColor = Palette.SidePanelBackgroundColor;

            _thumbNailList.Thumbnailer          = thumbnailProvider;
            _thumbNailList.RelocatePageEvent    = relocatePageEvent;
            _thumbNailList.PageSelectedChanged += new EventHandler(OnPageSelectedChanged);
            _thumbNailList.ControlKeyEvent      = controlKeyEvent;
            _thumbNailList.Model = model;
            _thumbNailList.BringToFront();             // needed to get DockStyle.Fill to work right.
            // First action determines whether the menu item is enabled, second performs it.
            var menuItems = new List <WebThumbNailList.MenuItemSpec>();

            menuItems.Add(
                new WebThumbNailList.MenuItemSpec()
            {
                Label          = LocalizationManager.GetString("EditTab.DuplicatePageButton", "Duplicate Page"),
                EnableFunction = (page) => page != null && _model.CanDuplicatePage,
                ExecuteCommand = (page) => _model.DuplicatePage(page)
            });
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec()
            {
                Label          = LocalizationManager.GetString("EditTab.CopyPage", "Copy Page"),
                EnableFunction = (page) => page != null && _model.CanCopyPage,
                ExecuteCommand = (page) => _model.CopyPage(page)
            });
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec()
            {
                Label          = LocalizationManager.GetString("EditTab.PastePage", "Paste Page"),
                EnableFunction = (page) => page != null && _model.CanAddPages && _model.GetClipboardHasPage(),
                ExecuteCommand = (page) => _model.PastePage(page)
            });
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec()
            {
                Label          = LocalizationManager.GetString("EditTab.DeletePageButton", "Remove Page"),
                EnableFunction = (page) => page != null && _model.CanDeletePage,
                ExecuteCommand = (page) =>
                {
                    if (ConfirmRemovePageDialog.Confirm())
                    {
                        _model.DeletePage(page);
                    }
                }
            });
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec()
            {
                Label          = LocalizationManager.GetString("EditTab.ChooseLayoutButton", "Choose Different Layout"),
                EnableFunction = (page) => page != null && !page.Required && !_model.CurrentBook.LockedDown,
                ExecuteCommand = (page) => _model.ChangePageLayout(page)
            });
            // This adds the desired menu items to the Gecko context menu that happens when we right-click
            _thumbNailList.ContextMenuProvider = args =>
            {
                var page = _thumbNailList.GetPageContaining(args.TargetNode);
                if (page == null)
                {
                    return(true);                    // no page-related commands if we didn't click on one.
                }
                if (page != _pageSelection.CurrentSelection)
                {
                    return(true);                    //it's too dangerous to let users do thing to a page they aren't seeing
                }
                foreach (var item in menuItems)
                {
                    var menuItem = new MenuItem(item.Label, (sender, eventArgs) => item.ExecuteCommand(page));
                    args.ContextMenu.MenuItems.Add(menuItem);
                    menuItem.Enabled = item.EnableFunction(page);
                }
                return(true);
            };
            // This sets up the context menu items that will be shown when the user clicks the
            // arrow in the thumbnail list.
            _thumbNailList.ContextMenuItems = menuItems;
        }
示例#13
0
 public PageListView(PageSelection pageSelection, RelocatePageEvent relocatePageEvent, EditingModel model, HtmlThumbNailer thumbnailProvider)
 {
     _pageSelection = pageSelection;
     _model         = model;
     this.Font      = SystemFonts.MessageBoxFont;
     InitializeComponent();
     _thumbNailList.Thumbnailer          = thumbnailProvider;
     _thumbNailList.CanSelect            = true;
     _thumbNailList.PreferPageNumbers    = true;
     _thumbNailList.KeepShowingSelection = true;
     _thumbNailList.RelocatePageEvent    = relocatePageEvent;
     _thumbNailList.PageSelectedChanged += new EventHandler(OnPageSelectedChanged);
 }
示例#14
0
 public void GetThumbnailAsync(int width, int height, HtmlDom dom,Action<Image> onReady ,Action<Exception> onError )
 {
     var thumbnailer = new HtmlThumbNailer(width, height);//enhance some way to cache this
     thumbnailer.GetThumbnailAsync(String.Empty, string.Empty, dom.RawDom, Color.White, false, onReady, onError);
 }
示例#15
0
 public void UpdateThumbnailAsync(Book.Book book, HtmlThumbNailer.ThumbnailOptions thumbnailOptions, Action<Book.BookInfo, Image> callback, Action<Book.BookInfo, Exception> errorCallback)
 {
     if (!(book is ErrorBook))
     {
         _thumbNailer.RebuildThumbNailAsync(book, thumbnailOptions, callback, errorCallback);
     }
 }
示例#16
0
        public delegate TemplatePagesView Factory();        //autofac uses this

        public TemplatePagesView(BookSelection bookSelection, TemplateInsertionCommand templateInsertionCommand, HtmlThumbNailer thumbnailProvider)
        {
            _bookSelection            = bookSelection;
            _templateInsertionCommand = templateInsertionCommand;

            this.Font = SystemFonts.MessageBoxFont;
            InitializeComponent();
            _thumbNailList.PageSelectedChanged += new EventHandler(OnPageClicked);
            _thumbNailList.Thumbnailer          = thumbnailProvider;
        }