public AccessibilityCheckApi(BloomWebSocketServer webSocketServer, BookSelection bookSelection,
                                     BookRenamedEvent bookRenamedEvent, BookSavedEvent bookSavedEvent, EpubMaker.Factory epubMakerFactory,
                                     PublishEpubApi epubApi)
        {
            _webSocketServer = webSocketServer;
            var progress = new WebSocketProgress(_webSocketServer, kWebSocketContext);

            _webSocketProgress              = progress.WithL10NPrefix("AccessibilityCheck.");
            _epubApi                        = epubApi;
            bookSelection.SelectionChanged += (unused1, unused2) =>
            {
                _webSocketServer.SendEvent(kWebSocketContext, kBookSelectionChanged);
            };
            // we get this when the book is renamed
            bookRenamedEvent.Subscribe((book) =>
            {
                RefreshClient();
            });
            // we get this when the contents of the page might have changed
            bookSavedEvent.Subscribe((book) =>
            {
                RefreshClient();
            });
        }
예제 #2
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();
        }