예제 #1
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;
        }
예제 #2
0
 // If given the localization changed event, the control will automatically reload
 // when the event is raised.
 public void SetLocalizationChangedEvent(LocalizationChangedEvent localizationChangedEvent)
 {
     localizationChangedEvent.Subscribe(unused =>
     {
         Reload();
     });
 }
예제 #3
0
        private void SetupChangeNotifications(BookCollection collection)
        {
            collection.CollectionChanged += (sender, args) =>
            {
                _webSocketServer.SendEvent("editableCollectionList", "reload:" + collection.PathToDirectory);
            };

            _localizationChangedEvent?.Subscribe(unused =>
            {
                if (collection.IsFactoryInstalled)
                {
                    _webSocketServer.SendEvent("editableCollectionList", "reload:" + collection.PathToDirectory);
                }
                else
                {
                    // This is tricky. Reloading the collection won't do it, because nothing has changed that would cause
                    // the buttons to re-render. But some of them may be showing a string like "Missing title" that
                    // is localizable. This is not very efficient, as we may process updates for many books that
                    // don't need it or don't even have buttons due to laziness. But changing UI language is really rare.
                    foreach (var info in collection.GetBookInfos())
                    {
                        BookCommands.RequestButtonLabelUpdate(collection.PathToDirectory, info.Id);
                    }
                }
            });
        }
예제 #4
0
        public delegate PublishView Factory();        //autofac uses this

        public PublishView(PublishModel model,
                           SelectedTabChangedEvent selectedTabChangedEvent, LocalizationChangedEvent localizationChangedEvent, BookTransfer bookTransferrer, LoginDialog login)
        {
            _bookTransferrer = bookTransferrer;
            _loginDialog     = login;

            InitializeComponent();

            if (this.DesignMode)
            {
                return;
            }

            _model      = model;
            _model.View = this;

            _makePdfBackgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(_makePdfBackgroundWorker_RunWorkerCompleted);

            //NB: just triggering off "VisibilityChanged" was unreliable. So now we trigger
            //off the tab itself changing, either to us or away from us.
            selectedTabChangedEvent.Subscribe(c =>
            {
                if (c.To == this)
                {
                    Activate();
                }
                else if (c.To != this && IsMakingPdf)
                {
                    _makePdfBackgroundWorker.CancelAsync();
                }
            });

            //TODO: find a way to call this just once, at the right time:

            //			DeskAnalytics.Track("Publish");

//#if DEBUG
//          var linkLabel = new LinkLabel() {Text = "DEBUG"};
//			linkLabel.Click+=new EventHandler((x,y)=>_model.DebugCurrentPDFLayout());
//          tableLayoutPanel1.Controls.Add(linkLabel);
//#endif

            _menusToolStrip.Renderer = new EditingView.FixedToolStripRenderer();
            GeckoPreferences.Default["pdfjs.disabled"] = false;
            SetupLocalization();
            localizationChangedEvent.Subscribe(o => SetupLocalization());
        }
예제 #5
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;
        }
        public LibraryListView(LibraryModel model, BookSelection bookSelection, SelectedTabChangedEvent selectedTabChangedEvent, LocalizationChangedEvent localizationChangedEvent,
                               HistoryAndNotesDialog.Factory historyAndNotesDialogFactory, BookTransfer bookTransferrer)
        {
            _model         = model;
            _bookSelection = bookSelection;
            localizationChangedEvent.Subscribe(unused => LoadSourceCollectionButtons());
            _historyAndNotesDialogFactory = historyAndNotesDialogFactory;
            _bookTransferrer          = bookTransferrer;
            _buttonsNeedingSlowUpdate = new ConcurrentQueue <Button>();
            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 restriting it because it opens a folder from which the user could do damage
            }
            _exportToXMLForInDesignToolStripMenuItem.Visible = Settings.Default.ShowExperimentalCommands;
        }
예제 #7
0
        public delegate PublishView Factory();        //autofac uses this

        public PublishView(PublishModel model,
                           SelectedTabChangedEvent selectedTabChangedEvent, LocalizationChangedEvent localizationChangedEvent, BookTransfer bookTransferrer, LoginDialog login, NavigationIsolator isolator,
                           PublishToAndroidApi publishApi, PublishEpubApi publishEpubApi, BloomWebSocketServer webSocketServer)
        {
            _bookTransferrer = bookTransferrer;
            _loginDialog     = login;
            _isolator        = isolator;
            _publishApi      = publishApi;
            _publishEpubApi  = publishEpubApi;
            _webSocketServer = webSocketServer;

            InitializeComponent();

            if (this.DesignMode)
            {
                return;
            }

            _model      = model;
            _model.View = this;

            _makePdfBackgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(_makePdfBackgroundWorker_RunWorkerCompleted);
            _pdfViewer.PrintProgress += new System.EventHandler <PdfPrintProgressEventArgs>(OnPrintProgress);

            // BL-625: With mono, if a RadioButton group has its AutoCheck properties set to true, the default RadioButton.OnEnter
            //         event checks to make sure one of the RadioButtons is checked. If none are checked, the one the mouse pointer
            //         is over is checked, causing the CheckChanged event to fire.
            if (SIL.PlatformUtilities.Platform.IsMono)
            {
                SetAutoCheck(false);
            }

            //NB: just triggering off "VisibilityChanged" was unreliable. So now we trigger
            //off the tab itself changing, either to us or away from us.
            selectedTabChangedEvent.Subscribe(c =>
            {
                if (c.To == this)
                {
                    Activate();
                }
                else if (c.To != this)
                {
                    Deactivate();
                }
            });

            //TODO: find a way to call this just once, at the right time:

            //			DeskAnalytics.Track("Publish");

//#if DEBUG
//          var linkLabel = new LinkLabel() {Text = "DEBUG"};
//			linkLabel.Click+=new EventHandler((x,y)=>_model.DebugCurrentPDFLayout());
//          tableLayoutPanel1.Controls.Add(linkLabel);
//#endif
            _menusToolStrip.BackColor = _layoutChoices.BackColor = tableLayoutPanel1.BackColor = Palette.GeneralBackground;
            if (SIL.PlatformUtilities.Platform.IsMono)
            {
                BackgroundColorsForLinux();
            }

            // Adding this renderer prevents a white line from showing up under the components.
            _menusToolStrip.Renderer = new EditingView.FixedToolStripRenderer();

            // As far as I can tell, this is not needed anymore, and its presence,
            // at least in this place in the code, causes errors when running command-line tools
            // like UploadCommand which needs a PublishView but must not have something fully initialized.
            //GeckoPreferences.Default["pdfjs.disabled"] = false;
            SetupLocalization();
            localizationChangedEvent.Subscribe(o =>
            {
                SetupLocalization();
                UpdateLayoutChoiceLabels();
                UpdateSaveButton();
            });

            // Make this extra box available to show when wanted.
            _previewBox         = new PictureBox();
            _previewBox.Visible = false;
            Controls.Add(_previewBox);
            _previewBox.BringToFront();
        }
예제 #8
0
        private bool _publishWithoutAudio = false; // True if the user has said to go ahead without audio

        #endregion Fields

        #region Constructors

        //autofac uses this
        public PublishView(PublishModel model,
			SelectedTabChangedEvent selectedTabChangedEvent, LocalizationChangedEvent localizationChangedEvent, BookTransfer bookTransferrer, LoginDialog login, NavigationIsolator isolator)
        {
            _bookTransferrer = bookTransferrer;
            _loginDialog = login;
            _isolator = isolator;

            InitializeComponent();

            if (this.DesignMode)
                return;

            _model = model;
            _model.View = this;

            _makePdfBackgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(_makePdfBackgroundWorker_RunWorkerCompleted);
            _pdfViewer.PrintProgress += new System.EventHandler<PdfPrintProgressEventArgs>(OnPrintProgress);

            // BL-625: With mono, if a RadioButton group has its AutoCheck properties set to true, the default RadioButton.OnEnter
            //         event checks to make sure one of the RadioButtons is checked. If none are checked, the one the mouse pointer
            //         is over is checked, causing the CheckChanged event to fire.
            if (SIL.PlatformUtilities.Platform.IsMono)
                SetAutoCheck(false);

            //NB: just triggering off "VisibilityChanged" was unreliable. So now we trigger
            //off the tab itself changing, either to us or away from us.
            selectedTabChangedEvent.Subscribe(c=>
                                                {
                                                    if (c.To == this)
                                                    {
                                                        Activate();
                                                    }
                                                    else if (c.To!=this && IsMakingPdf)
                                                        _makePdfBackgroundWorker.CancelAsync();
                                                });

            //TODO: find a way to call this just once, at the right time:

            //			DeskAnalytics.Track("Publish");

            //#if DEBUG
            //        	var linkLabel = new LinkLabel() {Text = "DEBUG"};
            //			linkLabel.Click+=new EventHandler((x,y)=>_model.DebugCurrentPDFLayout());
            //        	tableLayoutPanel1.Controls.Add(linkLabel);
            //#endif
            if (SIL.PlatformUtilities.Platform.IsMono)
            {
                BackgroundColorsForLinux();
            }

            // Adding this renderer prevents a white line from showing up under the components.
            _menusToolStrip.Renderer = new EditingView.FixedToolStripRenderer();

            GeckoPreferences.Default["pdfjs.disabled"] = false;
            SetupLocalization();
            localizationChangedEvent.Subscribe(o =>
            {
                SetupLocalization();
                UpdateLayoutChoiceLabels();
                UpdateSaveButton();
            });

            // Make this extra box available to show when wanted.
            _previewBox = new PictureBox();
            _previewBox.Visible = false;
            Controls.Add(_previewBox);
            _previewBox.BringToFront();
        }
예제 #9
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;
        }