예제 #1
0
        public delegate LibraryBookView Factory();        //autofac uses this

        public LibraryBookView(BookSelection bookSelection,
                               SendReceiver sendReceiver,
                               CreateFromSourceBookCommand createFromSourceBookCommand,
                               EditBookCommand editBookCommand,
                               SelectedTabChangedEvent selectedTabChangedEvent,
                               NavigationIsolator isolator)
        {
            InitializeComponent();
            _previewBrowser.Isolator        = isolator;
            _readmeBrowser.Isolator         = isolator;
            _bookSelection                  = bookSelection;
            _sendReceiver                   = sendReceiver;
            _createFromSourceBookCommand    = createFromSourceBookCommand;
            _editBookCommand                = editBookCommand;
            bookSelection.SelectionChanged += new EventHandler(OnBookSelectionChanged);

            selectedTabChangedEvent.Subscribe(c =>
            {
                _visible = c.To is LibraryView;
                if (_reshowPending)
                {
                    ShowBook();
                }
            });
            _editBookButton.Visible = false;
        }
예제 #2
0
 public ImageApi(BookSelection bookSelection)
 {
     _bookSelection = bookSelection;
     // The following is a list of image files that we don't want to paste image credits for.
     // It includes CC license image, placeholder and branding images.
     _doNotPasteArray = GetImageFilesToNotPasteCreditsFor().ToArray();
 }
예제 #3
0
        public delegate EditingModel Factory();        //autofac uses this

        public EditingModel(BookSelection bookSelection, PageSelection pageSelection,
                            LanguageSettings languageSettings,
                            TemplateInsertionCommand templateInsertionCommand,
                            PageListChangedEvent pageListChangedEvent,
                            RelocatePageEvent relocatePageEvent,
                            BookRefreshEvent bookRefreshEvent,
                            DuplicatePageCommand duplicatePageCommand,
                            DeletePageCommand deletePageCommand,
                            SelectedTabChangedEvent selectedTabChangedEvent,
                            SelectedTabAboutToChangeEvent selectedTabAboutToChangeEvent,
                            LibraryClosing libraryClosingEvent,
                            LocalizationChangedEvent localizationChangedEvent,
                            CollectionSettings collectionSettings,
                            SendReceiver sendReceiver,
                            EnhancedImageServer server)
        {
            _bookSelection        = bookSelection;
            _pageSelection        = pageSelection;
            _languageSettings     = languageSettings;
            _duplicatePageCommand = duplicatePageCommand;
            _deletePageCommand    = deletePageCommand;
            _collectionSettings   = collectionSettings;
            _sendReceiver         = sendReceiver;
            _server = server;

            bookSelection.SelectionChanged      += new EventHandler(OnBookSelectionChanged);
            pageSelection.SelectionChanged      += new EventHandler(OnPageSelectionChanged);
            templateInsertionCommand.InsertPage += new EventHandler(OnInsertTemplatePage);

            bookRefreshEvent.Subscribe((book) => OnBookSelectionChanged(null, null));
            selectedTabChangedEvent.Subscribe(OnTabChanged);
            selectedTabAboutToChangeEvent.Subscribe(OnTabAboutToChange);
            duplicatePageCommand.Implementer = OnDuplicatePage;
            deletePageCommand.Implementer    = OnDeletePage;
            pageListChangedEvent.Subscribe(x => _view.UpdatePageList(false));
            relocatePageEvent.Subscribe(OnRelocatePage);
            libraryClosingEvent.Subscribe(o => SaveNow());
            localizationChangedEvent.Subscribe(o =>
            {
                //this is visible was added for https://jira.sil.org/browse/BL-267, where the edit tab has never been
                //shown so the view has never been full constructed, so we're not in a good state to do a refresh
                if (Visible)
                {
                    SaveNow();
                    _view.UpdateButtonLocalizations();
                    RefreshDisplayOfCurrentPage();
                    //_view.UpdateDisplay();
                    _view.UpdatePageList(false);
                    _view.UpdateTemplateList();
                }
                else if (_view != null)
                {
                    // otherwise changing UI language in Publish tab (for instance) won't update these localizations
                    _view.UpdateButtonLocalizations();
                }
            });
            _contentLanguages = new List <ContentLanguage>();
            _server.CurrentCollectionSettings = _collectionSettings;
            _server.CurrentBook = CurrentBook;
        }
예제 #4
0
        public AppApi(BookSelection bookSelection, EditBookCommand editBookCommand, CreateFromSourceBookCommand createFromSourceBookCommand)

        {
            _bookSelection               = bookSelection;
            _editBookCommand             = editBookCommand;
            _createFromSourceBookCommand = createFromSourceBookCommand;
        }
예제 #5
0
        public delegate EditingModel Factory();        //autofac uses this

        public EditingModel(BookSelection bookSelection, PageSelection pageSelection,
                            LanguageSettings languageSettings,
                            TemplateInsertionCommand templateInsertionCommand,
                            PageListChangedEvent pageListChangedEvent,
                            RelocatePageEvent relocatePageEvent,
                            BookRefreshEvent bookRefreshEvent,
                            DeletePageCommand deletePageCommand,
                            SelectedTabChangedEvent selectedTabChangedEvent,
                            SelectedTabAboutToChangeEvent selectedTabAboutToChangeEvent,
                            LibraryClosing libraryClosingEvent,
                            CollectionSettings collectionSettings,
                            SendReceiver sendReceiver)
        {
            _bookSelection      = bookSelection;
            _pageSelection      = pageSelection;
            _languageSettings   = languageSettings;
            _deletePageCommand  = deletePageCommand;
            _collectionSettings = collectionSettings;
            _sendReceiver       = sendReceiver;

            bookSelection.SelectionChanged      += new EventHandler(OnBookSelectionChanged);
            pageSelection.SelectionChanged      += new EventHandler(OnPageSelectionChanged);
            templateInsertionCommand.InsertPage += new EventHandler(OnInsertTemplatePage);

            bookRefreshEvent.Subscribe((book) => OnBookSelectionChanged(null, null));
            selectedTabChangedEvent.Subscribe(OnTabChanged);
            selectedTabAboutToChangeEvent.Subscribe(OnTabAboutToChange);
            deletePageCommand.Implementer = OnDeletePage;
            pageListChangedEvent.Subscribe(x => _view.UpdatePageList(false));
            relocatePageEvent.Subscribe(OnRelocatePage);
            libraryClosingEvent.Subscribe(o => SaveNow());
            _contentLanguages = new List <ContentLanguage>();
        }
예제 #6
0
        public CollectionModel(string pathToCollection, CollectionSettings collectionSettings,
                               BookSelection bookSelection,
                               SourceCollectionsList sourceCollectionsList,
                               BookCollection.Factory bookCollectionFactory,
                               EditBookCommand editBookCommand,
                               CreateFromSourceBookCommand createFromSourceBookCommand,
                               BookServer bookServer,
                               CurrentEditableCollectionSelection currentEditableCollectionSelection,
                               BookThumbNailer thumbNailer,
                               TeamCollectionManager tcManager,
                               BloomWebSocketServer webSocketServer,
                               BookCollectionHolder bookCollectionHolder,
                               LocalizationChangedEvent localizationChangedEvent)
        {
            _bookSelection         = bookSelection;
            _pathToCollection      = pathToCollection;
            _collectionSettings    = collectionSettings;
            _sourceCollectionsList = sourceCollectionsList;
            _bookCollectionFactory = bookCollectionFactory;
            _editBookCommand       = editBookCommand;
            _bookServer            = bookServer;
            _currentEditableCollectionSelection = currentEditableCollectionSelection;
            _thumbNailer              = thumbNailer;
            _tcManager                = tcManager;
            _webSocketServer          = webSocketServer;
            _bookCollectionHolder     = bookCollectionHolder;
            _localizationChangedEvent = localizationChangedEvent;

            createFromSourceBookCommand.Subscribe(CreateFromSourceBook);
        }
        private EnhancedImageServer CreateImageServer()
        {
            var bookSelection = new BookSelection();

            bookSelection.SelectBook(new Bloom.Book.Book());
            return(new EnhancedImageServer(new RuntimeImageProcessor(new BookRenamedEvent()), null, bookSelection, _fileLocator));
        }
예제 #8
0
        public LibraryModel(string pathToLibrary, CollectionSettings collectionSettings,
                            //SendReceiver sendReceiver,
                            BookSelection bookSelection,
                            SourceCollectionsList sourceCollectionsList,
                            BookCollection.Factory bookCollectionFactory,
                            EditBookCommand editBookCommand,
                            CreateFromSourceBookCommand createFromSourceBookCommand,
                            BookServer bookServer,
                            CurrentEditableCollectionSelection currentEditableCollectionSelection,
                            BookThumbNailer thumbNailer,
                            TeamCollectionManager tcManager)
        {
            _bookSelection      = bookSelection;
            _pathToLibrary      = pathToLibrary;
            _collectionSettings = collectionSettings;
            //_sendReceiver = sendReceiver;
            _sourceCollectionsList = sourceCollectionsList;
            _bookCollectionFactory = bookCollectionFactory;
            _editBookCommand       = editBookCommand;
            _bookServer            = bookServer;
            _currentEditableCollectionSelection = currentEditableCollectionSelection;
            _thumbNailer = thumbNailer;
            _tcManager   = tcManager;

            createFromSourceBookCommand.Subscribe(CreateFromSourceBook);
        }
예제 #9
0
        /// <summary>
        /// Sets up the Bloom server and registers the Problem Report API handler to it
        /// </summary>
        private void SetupApiHandler(BookSelection bookSelection)
        {
            _server = new BloomServer(bookSelection);
            var controller = new ProblemReportApi(bookSelection);

            controller.RegisterWithApiHandler(_server.ApiHandler);
        }
예제 #10
0
        /// <summary>
        /// Handles the recursion through directories: if a folder looks like a Bloom book upload it; otherwise, try its children.
        /// Invisible folders like .hg are ignored.
        /// </summary>
        /// <param name="folder"></param>
        /// <param name="dlg"></param>
        /// <param name="container"></param>
        /// <param name="context"></param>
        private void UploadInternal(string folder, BulkUploadProgressDlg dlg, ApplicationContainer container, ref ProjectContext context)
        {
            if (Path.GetFileName(folder).StartsWith("."))
            {
                return;                 // secret folder, probably .hg
            }
            if (Directory.GetFiles(folder, "*.htm").Count() == 1)
            {
                // Exactly one htm file, assume this is a bloom book folder.
                dlg.Progress.WriteMessage("Starting to upload " + folder);

                // Make sure the files we want to upload are up to date.
                // Unfortunately this requires making a book object, which requires making a ProjectContext, which must be created with the
                // proper parent book collection if possible.
                var parent         = Path.GetDirectoryName(folder);
                var collectionPath = Directory.GetFiles(parent, "*.bloomCollection").FirstOrDefault();
                if (collectionPath == null && context == null)
                {
                    collectionPath = Settings.Default.MruProjects.Latest;
                }
                if (context == null || context.SettingsPath != collectionPath)
                {
                    if (context != null)
                    {
                        context.Dispose();
                    }
                    // optimise: creating a context seems to be quite expensive. Probably the only thing we need to change is
                    // the collection. If we could update that in place...despite autofac being told it has lifetime scope...we would save some time.
                    // Note however that it's not good enough to just store it in the project context. The one that is actually in
                    // the autofac object (_scope in the ProjectContext) is used by autofac to create various objects, in particular, books.
                    context = container.CreateProjectContext(collectionPath);
                }
                var server = context.BookServer;
                var book   = server.GetBookFromBookInfo(new BookInfo(folder, true));
                book.BringBookUpToDate(new NullProgress());

                // Assemble the various arguments needed to make the objects normally involved in an upload.
                // We leave some constructor arguments not actually needed for this purpose null.
                var bookSelection = new BookSelection();
                bookSelection.SelectBook(book);
                var currentEditableCollectionSelection = new CurrentEditableCollectionSelection();
                if (collectionPath != null)
                {
                    var collection = new BookCollection(collectionPath, BookCollection.CollectionType.SourceCollection,
                                                        bookSelection);
                    currentEditableCollectionSelection.SelectCollection(collection);
                }
                var publishModel = new PublishModel(bookSelection, new PdfMaker(), currentEditableCollectionSelection, null, server, _htmlThumbnailer);
                publishModel.PageLayout = book.GetLayout();
                var    view = new PublishView(publishModel, new SelectedTabChangedEvent(), new LocalizationChangedEvent(), this, null);
                string dummy;
                FullUpload(book, dlg.Progress, view, out dummy, dlg);
                return;
            }
            foreach (var sub in Directory.GetDirectories(folder))
            {
                UploadInternal(sub, dlg, container, ref context);
            }
        }
예제 #11
0
 public void Setup()
 {
     _selection       = new BookSelection();
     _apiObject       = new ImageApi(_selection);
     _creditsToFormat = new Dictionary <string, List <string> >();
     // Ensure only English UI strings (the default value).
     L10NSharp.LocalizationManager.SetUILanguage("en", false);
 }
예제 #12
0
 public WorkspaceModel(BookSelection bookSelection, string directoryPath, TeamCollectionManager tcManager, CollectionSettings collectionSettings)
 {
     _bookSelection                   = bookSelection;
     _directoryPath                   = directoryPath;
     _tcManager                       = tcManager;
     _collectionSettings              = collectionSettings;
     _bookSelection.SelectionChanged += OnSelectionChanged;
 }
예제 #13
0
        private BloomServer CreateBloomServer(BookInfo info = null)
        {
            var bookSelection      = new BookSelection();
            var collectionSettings = new CollectionSettings();

            bookSelection.SelectBook(new Bloom.Book.Book(info));
            return(new BloomServer(new RuntimeImageProcessor(new BookRenamedEvent()), bookSelection, collectionSettings, _fileLocator));
        }
예제 #14
0
        private string _previousTargetSaveAs;         // enhance: should this be shared with CollectionApi or other save as locations?

        public BookCommandsApi(CollectionModel collectionModel, BloomWebSocketServer webSocketServer, BookSelection bookSelection, SpreadsheetApi spreadsheetApi)
        {
            _collectionModel              = collectionModel;
            _webSocketServer              = webSocketServer;
            _bookSelection                = bookSelection;
            this._spreadsheetApi          = spreadsheetApi;
            _collectionModel.BookCommands = this;
        }
예제 #15
0
 public void WithDefaultValues()
 {
     this._collectionSettings    = new CollectionSettings();
     this._bookSelection         = new BookSelection();
     this._teamCollectionManager = null;                 // ENHANCE: This would be better off calling the builder for TeamCollectionManager, when it's implemented.
     this._bookServer            = null;
     this._bloomWebSocketServer  = null;
 }
예제 #16
0
 public CollectionApi(CollectionSettings settings, CollectionModel collectionModel, BookSelection bookSelection, EditBookCommand editBookCommand, BookThumbNailer thumbNailer, BloomWebSocketServer webSocketServer)
 {
     _settings        = settings;
     _collectionModel = collectionModel;
     _bookSelection   = bookSelection;
     _editBookCommand = editBookCommand;
     _thumbNailer     = thumbNailer;
     _webSocketServer = webSocketServer;
 }
예제 #17
0
 public AudioRecording(BookSelection bookSelection, BloomWebSocketServer bloomWebSocketServer)
 {
     _bookSelection                = bookSelection;
     _startRecordingTimer          = new Timer();
     _startRecordingTimer.Interval = 300;             //  ms from click to actual recording
     _startRecordingTimer.Tick    += OnStartRecordingTimer_Elapsed;
     _backupPath      = System.IO.Path.GetTempFileName();
     CurrentRecording = this;
     _webSocketServer = bloomWebSocketServer;
 }
예제 #18
0
 public PublishEpubApi(BookThumbNailer thumbNailer, NavigationIsolator isolator, BookServer bookServer,
                       BookSelection bookSelection, CollectionSettings collectionSettings, BloomWebSocketServer webSocketServer)
 {
     _thumbNailer        = thumbNailer;
     _bookServer         = bookServer;
     _bookSelection      = bookSelection;
     _collectionSettings = collectionSettings;
     _webSocketServer    = webSocketServer;
     _standardProgress   = new WebSocketProgress(_webSocketServer, kWebsocketContext);
 }
예제 #19
0
        public void Setup()
        {
            _bookSelection = new BookSelection();
            _bookSelection.SelectBook(new Bloom.Book.Book());
            _server = new BloomServer(_bookSelection);

            var controller = new ReadersApi(_bookSelection, null);

            controller.RegisterWithApiHandler(_server.ApiHandler);
        }
예제 #20
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;
        }
예제 #21
0
        private BookSelection GetDefaultBookSelection()
        {
            var bookSelection = new BookSelection();
            var mockBook      = new Mock <Bloom.Book.Book>();

            mockBook.Setup(x => x.TitleBestForUserDisplay).Returns("Fake Book Title");

            bookSelection.SelectBook(mockBook.Object);

            return(bookSelection);
        }
예제 #22
0
        public void InitialSetup()
        {
            var bookSelection = new BookSelection();

            bookSelection.SelectBook(new Bloom.Book.Book());
            _server = new BloomServer(bookSelection);

            var controller = new FileIOApi(bookSelection);

            controller.RegisterWithApiHandler(_server.ApiHandler);
        }
예제 #23
0
 // Called by autofac, which creates the one instance and registers it with the server.
 public TeamCollectionApi(CurrentEditableCollectionSelection currentBookCollectionSelection, CollectionSettings settings, BookSelection bookSelection, ITeamCollectionManager tcManager, BookServer bookServer, BloomWebSocketServer socketServer)
 {
     _currentBookCollectionSelection = currentBookCollectionSelection;
     _settings  = settings;
     _tcManager = tcManager;
     _tcManager.CurrentCollection?.SetupMonitoringBehavior();
     _bookSelection = bookSelection;
     _socketServer  = socketServer;
     _bookServer    = bookServer;
     TheOneInstance = this;
 }
예제 #24
0
 public PublishModel(BookSelection bookSelection, PdfMaker pdfMaker, CurrentEditableCollectionSelection currentBookCollectionSelection, CollectionSettings collectionSettings, BookServer bookServer)
 {
     BookSelection = bookSelection;
     _pdfMaker     = pdfMaker;
     //_pdfMaker.EngineChoice = collectionSettings.PdfEngineChoice;
     _currentBookCollectionSelection = currentBookCollectionSelection;
     ShowCropMarks                   = false;
     _collectionSettings             = collectionSettings;
     _bookServer                     = bookServer;
     bookSelection.SelectionChanged += new EventHandler(OnBookSelectionChanged);
     BookletPortion                  = BookletPortions.BookletPages;
 }
예제 #25
0
        public static bool ForPageLayout = false;         // set when most recent relevant command is ShowChangeLayoutDialog

        public PageTemplatesApi(SourceCollectionsList sourceCollectionsList, BookSelection bookSelection,
                                PageSelection pageSelection, TemplateInsertionCommand templateInsertionCommand,
                                BookThumbNailer thumbNailer, Book.Book.Factory bookFactory, BookStorage.Factory storageFactory)
        {
            _sourceCollectionsList    = sourceCollectionsList;
            _bookSelection            = bookSelection;
            _pageSelection            = pageSelection;
            _templateInsertionCommand = templateInsertionCommand;
            _thumbNailer    = thumbNailer;
            _bookFactory    = bookFactory;
            _storageFactory = storageFactory;
        }
예제 #26
0
        public BookCollection(string path, CollectionType collectionType,
                              BookSelection bookSelection)
        {
            _path          = path;
            _bookSelection = bookSelection;

            Type = collectionType;

            if (collectionType == CollectionType.TheOneEditableCollection)
            {
                MakeCollectionCSSIfMissing();
            }
        }
예제 #27
0
        public void Setup()
        {
            var bookSelection = new BookSelection();

            bookSelection.SelectBook(new Bloom.Book.Book());
            _server = new EnhancedImageServer(bookSelection);

            //needed to avoid a check in the server
            _server.CurrentCollectionSettings = new CollectionSettings();
            var controller = new ReadersApi(bookSelection);

            controller.RegisterWithServer(_server);
        }
예제 #28
0
 public AudioRecording(BookSelection bookSelection, BloomWebSocketServer bloomWebSocketServer)
 {
     _bookSelection                 = bookSelection;
     _startRecordingTimer           = new Timer();
     _startRecordingTimer.Interval  = 300;            //  ms from click to actual recording
     _startRecordingTimer.Tick     += OnStartRecordingTimer_Elapsed;
     _backupPathForRecordableAudio  = Path.GetTempFileName();
     _backupPathForPublishableAudio = Path.GetTempFileName();
     CurrentRecording               = this;
     _webSocketServer               = bloomWebSocketServer;
     // We create the ManualResetEvent in the "set" (non-blocking) state initially. The idea is to allow HandleEndRecord() to run,
     // but then block functions like HandleAudioFileRequest() which relies on the contents of the audio folder until Recorder_Stopped() has reported finishing saving the audio file.
     _completingRecording = new ManualResetEvent(true);
 }
예제 #29
0
 public PublishModel(BookSelection bookSelection, PdfMaker pdfMaker, CurrentEditableCollectionSelection currentBookCollectionSelection, CollectionSettings collectionSettings,
                     BookServer bookServer, BookThumbNailer thumbNailer, NavigationIsolator isolator)
 {
     BookSelection = bookSelection;
     _pdfMaker     = pdfMaker;
     //_pdfMaker.EngineChoice = collectionSettings.PdfEngineChoice;
     _currentBookCollectionSelection = currentBookCollectionSelection;
     ShowCropMarks                   = false;
     _collectionSettings             = collectionSettings;
     _bookServer                     = bookServer;
     _thumbNailer                    = thumbNailer;
     bookSelection.SelectionChanged += new EventHandler(OnBookSelectionChanged);
     _isoloator = isolator;
     //we don't want to default anymore: BookletPortion = BookletPortions.BookletPages;
 }
예제 #30
0
 public PublishModel(BookSelection bookSelection, PdfMaker pdfMaker, CurrentEditableCollectionSelection currentBookCollectionSelection, CollectionSettings collectionSettings,
                     BookServer bookServer, BookThumbNailer thumbNailer)
 {
     BookSelection         = bookSelection;
     _pdfMaker             = pdfMaker;
     _pdfMaker.CompressPdf = true;               // See http://issues.bloomlibrary.org/youtrack/issue/BL-3721.
     //_pdfMaker.EngineChoice = collectionSettings.PdfEngineChoice;
     _currentBookCollectionSelection = currentBookCollectionSelection;
     ShowCropMarks                   = false;
     _collectionSettings             = collectionSettings;
     _bookServer                     = bookServer;
     _thumbNailer                    = thumbNailer;
     bookSelection.SelectionChanged += OnBookSelectionChanged;
     //we don't want to default anymore: BookletPortion = BookletPortions.BookletPages;
 }