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; }
public void ViewVisibleNowDoSlowStuff() { if (_currentlyDisplayedBook != CurrentBook) { CurrentBook.PrepareForEditing(); } _currentlyDisplayedBook = CurrentBook; var errors = _bookSelection.CurrentSelection.GetErrorsIfNotCheckedBefore(); if (!string.IsNullOrEmpty(errors)) { Palaso.Reporting.ErrorReport.NotifyUserOfProblem(errors); return; } var page = _bookSelection.CurrentSelection.FirstPage; if (page != null) { _pageSelection.SelectPage(page); } if (_view != null) { if (ShowTemplatePanel) { _view.UpdateTemplateList(); } _view.UpdatePageList(false); } }