Ejemplo n.º 1
0
 public EnhancedImageServer(RuntimeImageProcessor cache, BookThumbNailer thumbNailer, BookSelection bookSelection,  BloomFileLocator fileLocator = null)
     : base(cache)
 {
     _thumbNailer = thumbNailer;
     _bookSelection = bookSelection;
     _fileLocator = fileLocator;
 }
Ejemplo n.º 2
0
        //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>();
        }
Ejemplo n.º 3
0
        //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;
        }
Ejemplo n.º 4
0
        //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;
        }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
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;
 }
Ejemplo n.º 9
0
        public BookCollection(string path, CollectionType collectionType,
			BookSelection bookSelection)
        {
            _path = path;
            _bookSelection = bookSelection;

            Type = collectionType;

            if (collectionType == CollectionType.TheOneEditableCollection)
            {
                MakeCollectionCSSIfMissing();
            }
        }
Ejemplo n.º 10
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;
        }
Ejemplo n.º 11
0
        //HistoryAndNotesDialog.Factory historyAndNotesDialogFactory)
        public LibraryListView(LibraryModel model, BookSelection bookSelection, SelectedTabChangedEvent selectedTabChangedEvent, LocalizationChangedEvent localizationChangedEvent)
        {
            _model = model;
            _bookSelection = bookSelection;
            localizationChangedEvent.Subscribe(unused=>LoadSourceCollectionButtons());
            //_historyAndNotesDialogFactory = historyAndNotesDialogFactory;
            _buttonsNeedingSlowUpdate = new ConcurrentQueue<ButtonRefreshInfo>();
            selectedTabChangedEvent.Subscribe(OnSelectedTabChanged);
            InitializeComponent();
            _primaryCollectionFlow.HorizontalScroll.Visible = false;

            _primaryCollectionFlow.Controls.Clear();
            _primaryCollectionFlow.HorizontalScroll.Visible = false;
            _sourceBooksFlow.Controls.Clear();
            _sourceBooksFlow.HorizontalScroll.Visible = false;

            if (!_model.ShowSourceCollections)
            {
                splitContainer1.Panel2Collapsed = true;
            }

            _headerFont = new Font(SystemFonts.DialogFont.FontFamily, (float)10.0, FontStyle.Bold);
            _editableBookFont = new Font(SystemFonts.DialogFont.FontFamily, (float)9.0);//, FontStyle.Bold);
            _collectionBookFont = new Font(SystemFonts.DialogFont.FontFamily, (float)9.0);

            //enhance: move to model
            bookSelection.SelectionChanged += new EventHandler(OnBookSelectionChanged);

            _settingsProtectionHelper.ManageComponent(_openFolderOnDisk);

            _showHistoryMenu.Visible = _showNotesMenu.Visible = Settings.Default.ShowSendReceive;

            if(Settings.Default.ShowExperimentalCommands)
                _settingsProtectionHelper.ManageComponent(_exportToXMLForInDesignToolStripMenuItem);//we are restricting it because it opens a folder from which the user could do damage
            _exportToXMLForInDesignToolStripMenuItem.Visible = Settings.Default.ShowExperimentalCommands;

            SetupBookDropdownIcon();
            _bookContextMenu.Closed += _bookContextMenu_Closed;
            _bookContextMenu.Opening += _bookContextMenu_Opening;
        }
Ejemplo n.º 12
0
        public LibraryModel(string pathToLibrary, CollectionSettings collectionSettings,
			SendReceiver sendReceiver,
			BookSelection bookSelection,
			SourceCollectionsList sourceCollectionsList,
			BookCollection.Factory bookCollectionFactory,
			EditBookCommand editBookCommand,
			CreateFromSourceBookCommand createFromSourceBookCommand,
			BookServer bookServer,
			CurrentEditableCollectionSelection currentEditableCollectionSelection)
        {
            _bookSelection = bookSelection;
            _pathToLibrary = pathToLibrary;
            _collectionSettings = collectionSettings;
            _sendReceiver = sendReceiver;
            _sourceCollectionsList = sourceCollectionsList;
            _bookCollectionFactory = bookCollectionFactory;
            _editBookCommand = editBookCommand;
            _bookServer = bookServer;
            _currentEditableCollectionSelection = currentEditableCollectionSelection;

            createFromSourceBookCommand.Subscribe(CreateFromSourceBook);
        }
Ejemplo n.º 13
0
 public CurrentBookHandler(BookSelection bookSelection, PageRefreshEvent pageRefreshEvent)
 {
     _bookSelection = bookSelection;
     _pageRefreshEvent = pageRefreshEvent;
 }
Ejemplo n.º 14
0
 public BookSettingsApi(BookSelection bookSelection, PageRefreshEvent pageRefreshEvent)
 {
     _bookSelection = bookSelection;
     _pageRefreshEvent = pageRefreshEvent;
 }
Ejemplo n.º 15
0
 public WorkspaceModel(BookSelection bookSelection, string directoryPath)
 {
     _bookSelection = bookSelection;
     _directoryPath = directoryPath;
     _bookSelection.SelectionChanged += new EventHandler(OnSelectionChanged);
 }
 private EnhancedImageServer CreateImageServer()
 {
     var bookSelection = new BookSelection();
     bookSelection.SelectBook(new Bloom.Book.Book());
     return new EnhancedImageServer(new RuntimeImageProcessor(new BookRenamedEvent()), null, bookSelection, _fileLocator);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// This is only used in a few special cases where we need one to pass as an argument but it won't be fully used.
 /// </summary>
 internal EnhancedImageServer(BookSelection bookSelection)
     : this(new RuntimeImageProcessor(new BookRenamedEvent()), null, bookSelection)
 {
 }
 public ProblemReporterDialog(Control targetOfScreenshot, BookSelection bookSelection)
     : this(targetOfScreenshot)
 {
     Book = bookSelection.CurrentSelection;
 }
Ejemplo n.º 19
0
 public ImageApi(BookSelection bookSelection)
 {
     _bookSelection = bookSelection;
 }
Ejemplo n.º 20
0
 public void CurrentSelection_AfterPageIsInserted_GoesToNewPage()
 {
     var bs = new BookSelection();
     var ps = new PageSelection();//bs);
      //   ps.
 }
Ejemplo n.º 21
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, _thumbnailer, null);
                publishModel.PageLayout = book.GetLayout();
                var view = new PublishView(publishModel, new SelectedTabChangedEvent(), new LocalizationChangedEvent(), this, null, null);
                string dummy;
                // Normally we let the user choose which languages to upload. Here, just the ones that have complete information.
                var langDict = book.AllLanguages;
                var languagesToUpload = langDict.Keys.Where(l => langDict[l]).ToArray();
                if (languagesToUpload.Any())
                    FullUpload(book, dlg.Progress, view, languagesToUpload, out dummy, dlg);
                return;
            }
            foreach (var sub in Directory.GetDirectories(folder))
                UploadInternal(sub, dlg, container, ref context);
        }
Ejemplo n.º 22
0
        //autofac uses this
        public EditingModel(BookSelection bookSelection, PageSelection pageSelection,
			TemplateInsertionCommand templateInsertionCommand,
			PageListChangedEvent pageListChangedEvent,
			RelocatePageEvent relocatePageEvent,
			BookRefreshEvent bookRefreshEvent,
			PageRefreshEvent pageRefreshEvent,
			DuplicatePageCommand duplicatePageCommand,
			DeletePageCommand deletePageCommand,
			SelectedTabChangedEvent selectedTabChangedEvent,
			SelectedTabAboutToChangeEvent selectedTabAboutToChangeEvent,
			LibraryClosing libraryClosingEvent,
			LocalizationChangedEvent localizationChangedEvent,
			CollectionSettings collectionSettings,
			//SendReceiver sendReceiver,
			EnhancedImageServer server,
			BloomWebSocketServer webSocketServer)
        {
            _bookSelection = bookSelection;
            _pageSelection = pageSelection;
            _duplicatePageCommand = duplicatePageCommand;
            _deletePageCommand = deletePageCommand;
            _collectionSettings = collectionSettings;
            //_sendReceiver = sendReceiver;
            _server = server;
            _webSocketServer = webSocketServer;
            _templatePagesDict = null;

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

            bookRefreshEvent.Subscribe((book) => OnBookSelectionChanged(null, null));
            pageRefreshEvent.Subscribe((PageRefreshEvent.SaveBehavior behavior) =>
            {
                switch (behavior)
                {
                    case PageRefreshEvent.SaveBehavior.SaveBeforeRefresh:
                        RethinkPageAndReloadIt(null);
                        break;

                    case PageRefreshEvent.SaveBehavior.JustRedisplay:
                        RefreshDisplayOfCurrentPage();
                        break;
                }
            });

            selectedTabChangedEvent.Subscribe(OnTabChanged);
            selectedTabAboutToChangeEvent.Subscribe(OnTabAboutToChange);
            duplicatePageCommand.Implementer = OnDuplicatePage;
            deletePageCommand.Implementer = OnDeletePage;
            pageListChangedEvent.Subscribe(x => _view.UpdatePageList(false));
            relocatePageEvent.Subscribe(OnRelocatePage);
            libraryClosingEvent.Subscribe(o =>
            {
                if (Visible)
                    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);
                }
                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;
        }