Beispiel #1
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>();
        }
        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;
        }
Beispiel #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,
                            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>();
        }
Beispiel #4
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");
        }
Beispiel #5
0
        public Book(BookInfo info, IBookStorage storage, ITemplateFinder templateFinder,
		   CollectionSettings collectionSettings,
			PageSelection pageSelection,
			PageListChangedEvent pageListChangedEvent,
			BookRefreshEvent bookRefreshEvent)
        {
            BookInfo = info;
            UserPrefs = UserPrefs.LoadOrMakeNew(Path.Combine(info.FolderPath, "book.userPrefs"));

            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 += _storage_FolderPathChanged;

            _templateFinder = templateFinder;

            _collectionSettings = collectionSettings;

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

            InjectStringListingActiveLanguagesOfBook();

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

            //if we're showing the user a shell/template book, pick a color for it
            //If it is editable, then we don't want to change to the next color, we
            //want to use the color that we used for the sample shell/template we
            //showed them previously.
            if (!info.IsEditable)
            {
                Book.SelectNextCoverColor(); // we only increment when showing a template or shell
                InitCoverColor();
            }

            // If it doesn't already have a cover color give it one.
            if (OurHtmlDom.SafeSelectNodes("//head/style/text()[contains(., 'coverColor')]").Count == 0)
            {
                InitCoverColor(); // should use the same color as what they saw in the preview of the template/shell
            }
            FixBookIdAndLineageIfNeeded();
            _storage.Dom.RemoveExtraBookTitles();
            _storage.Dom.RemoveExtraContentTypesMetas();
            Guard.Against(OurHtmlDom.RawDom.InnerXml=="","Bloom could not parse the xhtml of this document");
        }
        //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;
        }