Example #1
0
        public delegate EditingView Factory();        //autofac uses this


        public EditingView(EditingModel model, PageListView pageListView, TemplatePagesView templatePagesView,
                           CutCommand cutCommand, CopyCommand copyCommand, PasteCommand pasteCommand, UndoCommand undoCommand, DuplicatePageCommand duplicatePageCommand,
                           DeletePageCommand deletePageCommand, NavigationIsolator isolator)
        {
            _model                = model;
            _pageListView         = pageListView;
            _templatePagesView    = templatePagesView;
            _cutCommand           = cutCommand;
            _copyCommand          = copyCommand;
            _pasteCommand         = pasteCommand;
            _undoCommand          = undoCommand;
            _duplicatePageCommand = duplicatePageCommand;
            _deletePageCommand    = deletePageCommand;
            InitializeComponent();
            _browser1.Isolator   = isolator;
            _splitContainer1.Tag = _splitContainer1.SplitterDistance;            //save it
            //don't let it grow automatically
//            _splitContainer1.SplitterMoved+= ((object sender, SplitterEventArgs e) => _splitContainer1.SplitterDistance = (int)_splitContainer1.Tag);
            SetupThumnailLists();
            _model.SetView(this);
            _browser1.SetEditingCommands(cutCommand, copyCommand, pasteCommand, undoCommand);

            _browser1.GeckoReady += new EventHandler(OnGeckoReady);

            _menusToolStrip.Renderer = new FixedToolStripRenderer();

            //we're giving it to the parent control through the TopBarControls property
            Controls.Remove(_topBarPanel);
        }
 /// <summary>
 /// Show an html form, prepopulating it with saved values, and returning the new values when they click "OK"
 /// </summary>
 /// <param name="configurationHtmlPath"></param>
 /// <param name="libraryJsonData">Values saved previously</param>
 public ConfigurationDialog(string configurationHtmlPath, string libraryJsonData, NavigationIsolator isolator)
 {
     _filePath = configurationHtmlPath;
     _libraryJsonData = libraryJsonData;
     InitializeComponent();
     _browser.Isolator = isolator;
 }
        public void SpuriousNavigatedEvents_AreIgnored()
        {
            var    browser  = new BrowserStub();
            string target   = "http://any old web address";
            var    isolator = new NavigationIsolator();

            isolator.Navigate(browser, target);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target));

            var    browser2 = new BrowserStub();
            string target2  = "http://some other web address";

            isolator.Navigate(browser2, target2);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target), "Second navigation should not have proceeded at once");
            Assert.That(browser2.NavigateTarget, Is.EqualTo(null), "Second navigation should not have proceeded at once");

            browser.RaiseNavigated(this, new EventArgs());             // got the event notification, but still busy.
            Assert.That(browser.NavigateTarget, Is.EqualTo(target), "Second navigation should not have proceeded even on Navigated while browser still busy");
            Assert.That(browser2.NavigateTarget, Is.EqualTo(null), "Second navigation should not have proceeded even on Navigated while browser still busy");

            browser.NormalTermination();
            Assert.That(browser2.NavigateTarget, Is.EqualTo(target2), "Second navigation should have proceeded when first completed (and browser no longer busy)");

            browser2.NormalTermination();
            Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed");
            Assert.That(browser2.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed");
        }
        public void Isolation_AfterLongDelay_GivesUpAndMovesOn()
        {
            var    browser  = new BrowserStub();
            string target   = "http://any old web address";
            var    isolator = new NavigationIsolator();

            isolator.Navigate(browser, target);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target));

            var    browser2 = new BrowserStub();
            string target2  = "http://some other web address";

            isolator.Navigate(browser2, target2);
            var    browser3 = new BrowserStub();
            string target3  = "http://yet another web address";

            isolator.Navigate(browser3, target3);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target), "Second navigation should not have proceeded at once");
            var start = DateTime.Now;

            while (DateTime.Now - start < new TimeSpan(0, 0, 0, 2, 300))
            {
                Application.DoEvents();                 // allow timer to tick.
            }
            Assert.That(() => browser2.NavigateTarget, Is.EqualTo(target2), "Second navigation should have proceeded eventually");

            browser2.NormalTermination();             // the second request.
            Assert.That(() => browser3.NavigateTarget, Is.EqualTo(target3), "Third navigation should have proceeded when second finished");

            browser3.NormalTermination();             // hopefully from the third.
            Assert.That(browser3.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed");
        }
        public void NoLongerBusy_EvenWithoutEvent_IsNoticed()
        {
            var    browser  = new BrowserStub();
            string target   = "http://any old web address";
            var    isolator = new NavigationIsolator();

            isolator.Navigate(browser, target);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target));
            var    browser2 = new BrowserStub();
            string target2  = "http://some other web address";

            isolator.Navigate(browser2, target2);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target), "Second navigation should not have proceeded at once");
            Assert.That(browser2.NavigateTarget, Is.EqualTo(null), "Second navigation should not have proceeded at once");
            browser.IsBusy = false;             // finished but did not raise event.
            var start = DateTime.Now;

            while (DateTime.Now - start < new TimeSpan(0, 0, 0, 0, 150))
            {
                Application.DoEvents();                 // allow timer to tick.
            }
            Assert.That(() => browser2.NavigateTarget, Is.EqualTo(target2), "Second navigation should have proceeded soon after first no longer busy");

            browser.NormalTermination();
            browser2.NormalTermination();
            Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed");
            Assert.That(browser2.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed");
        }
        //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;
        }
        public void TwoPendingNavigations_WithNavigatedEvents_AreHandledCorrectly()
        {
            var    browser  = new BrowserStub();
            string target   = "http://any old web address";
            var    isolator = new NavigationIsolator();

            isolator.Navigate(browser, target);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target));
            var    browser2 = new BrowserStub();
            string target2  = "http://some other web address";

            isolator.Navigate(browser2, target2);
            var    browser3 = new BrowserStub();
            string target3  = "http://yet another other web address";

            isolator.Navigate(browser3, target3);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target), "Second and third navigation should not have proceeded at once");

            browser.NormalTermination();
            Assert.That(browser2.NavigateTarget, Is.EqualTo(target2), "Second navigation should have proceeded when first completed (but third should not)");

            browser2.NormalTermination();
            Assert.That(browser3.NavigateTarget, Is.EqualTo(target3), "Third navigation should have proceeded when second completed");

            browser3.NormalTermination();
            Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed");
        }
Example #8
0
        public delegate LibraryBookView Factory();        //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;
        }
Example #9
0
        //autofac uses this
        public EditingView(EditingModel model, PageListView pageListView,
			CutCommand cutCommand, CopyCommand copyCommand, PasteCommand pasteCommand, UndoCommand undoCommand,
			DuplicatePageCommand duplicatePageCommand,
			DeletePageCommand deletePageCommand, NavigationIsolator isolator, ControlKeyEvent controlKeyEvent)
        {
            _model = model;
            _pageListView = pageListView;
            _cutCommand = cutCommand;
            _copyCommand = copyCommand;
            _pasteCommand = pasteCommand;
            _undoCommand = undoCommand;
            _duplicatePageCommand = duplicatePageCommand;
            _deletePageCommand = deletePageCommand;
            InitializeComponent();
            _browser1.Isolator = isolator;
            _splitContainer1.Tag = _splitContainer1.SplitterDistance; //save it
            //don't let it grow automatically
            //            _splitContainer1.SplitterMoved+= ((object sender, SplitterEventArgs e) => _splitContainer1.SplitterDistance = (int)_splitContainer1.Tag);
            SetupThumnailLists();
            _model.SetView(this);
            _browser1.SetEditingCommands(cutCommand, copyCommand, pasteCommand, undoCommand);

            _browser1.GeckoReady += new EventHandler(OnGeckoReady);

            _browser1.ControlKeyEvent = controlKeyEvent;

            if(SIL.PlatformUtilities.Platform.IsMono)
            {
                RepositionButtonsForMono();
                BackgroundColorsForLinux();
            }

            controlKeyEvent.Subscribe(HandleControlKeyEvent);

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

            //we're giving it to the parent control through the TopBarControls property
            Controls.Remove(_topBarPanel);
            SetupBrowserContextMenu();
            #if __MonoCS__
            // The inactive button images look garishly pink on Linux/Mono, but look okay on Windows.
            // Merely introducing an "identity color matrix" to the image attributes appears to fix
            // this problem.  (The active form looks okay with or without this fix.)
            // See http://issues.bloomlibrary.org/youtrack/issue/BL-3714.
            float[][] colorMatrixElements = {
                new float[] {1,  0,  0,  0,  0},		// red scaling factor of 1
                new float[] {0,  1,  0,  0,  0},		// green scaling factor of 1
                new float[] {0,  0,  1,  0,  0},		// blue scaling factor of 1
                new float[] {0,  0,  0,  1,  0},		// alpha scaling factor of 1
                new float[] {0,  0,  0,  0,  1}};		// three translations of 0.0
            var colorMatrix = new ColorMatrix(colorMatrixElements);
            _duplicatePageButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _deletePageButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _undoButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _cutButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _pasteButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            _copyButton.ImageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            #endif
        }
Example #10
0
        public PageListView(PageSelection pageSelection,  RelocatePageEvent relocatePageEvent, EditingModel model,
			HtmlThumbNailer thumbnailProvider, NavigationIsolator isolator, ControlKeyEvent controlKeyEvent)
        {
            _pageSelection = pageSelection;
            _model = model;
            this.Font= SystemFonts.MessageBoxFont;
            InitializeComponent();

            _thumbNailList.Thumbnailer = thumbnailProvider;
            _thumbNailList.CanSelect = true;
            _thumbNailList.PreferPageNumbers = true;
            _thumbNailList.KeepShowingSelection = true;
            _thumbNailList.RelocatePageEvent = relocatePageEvent;
            _thumbNailList.PageSelectedChanged+=new EventHandler(OnPageSelectedChanged);
            _thumbNailList.Isolator = isolator;
            _thumbNailList.ControlKeyEvent = controlKeyEvent;
            // First action determines whether the menu item is enabled, second performs it.
            var menuItems = new List<WebThumbNailList.MenuItemSpec>();
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec() {
                    Label = LocalizationManager.GetString("EditTab.DuplicatePageButton", "Duplicate Page"), // same ID as button in toolbar));
                    EnableFunction = (page) => page != null && !page.Required && !_model.CurrentBook.LockedDown,
                    ExecuteCommand = (page) => _model.DuplicatePage(page)});
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec() {
                    Label = LocalizationManager.GetString("EditTab.DeletePageButton", "Remove Page"),  // same ID as button in toolbar));
                    EnableFunction = (page) => page != null && !page.Required && !_model.CurrentBook.LockedDown,
                    ExecuteCommand = (page) =>
                    {
                        if (ConfirmRemovePageDialog.Confirm())
                            _model.DeletePage(page);
                    }});
            menuItems.Add(
                new WebThumbNailList.MenuItemSpec() {
                    Label = LocalizationManager.GetString("EditTab.ChooseLayoutButton", "Choose Different Layout"),
                    EnableFunction = (page) => page != null && !page.Required && !_model.CurrentBook.LockedDown,
                    ExecuteCommand = (page) => _model.ChangePageLayout(page)});
            // This adds the desired menu items to the Gecko context menu that happens when we right-click
            _thumbNailList.ContextMenuProvider = args =>
            {
                var page = _thumbNailList.GetPageContaining(args.TargetNode);
                if (page == null)
                    return true; // no page-related commands if we didn't click on one.
                if(page != _pageSelection.CurrentSelection)
                {
                    return true; //it's too dangerous to let users do thing to a page they aren't seeing
                }
                foreach (var item in menuItems)
                {
                    var menuItem = new MenuItem(item.Label, (sender, eventArgs) => item.ExecuteCommand(page));
                    args.ContextMenu.MenuItems.Add(menuItem);
                    menuItem.Enabled = item.EnableFunction(page);
                }
                return true;
            };
            // This sets up the context menu items that will be shown when the user clicks the
            // arrow in the thumbnail list.
            _thumbNailList.ContextMenuItems = menuItems;
        }
Example #11
0
 //autofac uses this
 public Configurator(string folderInWhichToReadAndSaveLibrarySettings, NavigationIsolator isolator)
 {
     _folderInWhichToReadAndSaveLibrarySettings = folderInWhichToReadAndSaveLibrarySettings;
     _isolator = isolator;
     PathToLibraryJson = _folderInWhichToReadAndSaveLibrarySettings.CombineForPath("configuration.txt");
     RequireThat.Directory(folderInWhichToReadAndSaveLibrarySettings).Exists();
     LocalData = string.Empty;
 }
Example #12
0
        public delegate Configurator Factory(string folderInWhichToReadAndSaveLibrarySettings);        //autofac uses this

        public Configurator(string folderInWhichToReadAndSaveLibrarySettings, NavigationIsolator isolator)
        {
            _folderInWhichToReadAndSaveLibrarySettings = folderInWhichToReadAndSaveLibrarySettings;
            _isolator         = isolator;
            PathToLibraryJson = _folderInWhichToReadAndSaveLibrarySettings.CombineForPath("configuration.txt");
            RequireThat.Directory(folderInWhichToReadAndSaveLibrarySettings).Exists();
            LocalData = string.Empty;
        }
Example #13
0
        public void GetAllData_LocalOnly_ReturnLocal()
        {
            var     c = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator());
            dynamic j = new DynamicJson();

            j.one = 1;
            c.CollectJsonData(j.ToString());
            Assert.AreEqual(j, DynamicJson.Parse(c.GetAllData()));
        }
Example #14
0
        public void GetLibraryData_NoGlobalData_Empty()
        {
            var     first = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator());
            dynamic j     = new DynamicJson();

            j.one = 1;
            first.CollectJsonData(j.ToString());
            Assert.AreEqual("{}", first.GetLibraryData());
        }
Example #15
0
        public void WhenCollectedNoGlobalDataThenGlobalDataIsEmpty()
        {
            var     first = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator());
            dynamic j     = new DynamicJson();

            j.one = 1;
            first.CollectJsonData(j.ToString());
            Assert.AreEqual(j, DynamicJson.Parse(first.LocalData));
        }
Example #16
0
 public PublishEpubApi(BookThumbNailer thumbNailer, NavigationIsolator isolator, BookServer bookServer,
                       BookSelection bookSelection, CollectionSettings collectionSettings, BloomWebSocketServer webSocketServer)
 {
     _thumbNailer        = thumbNailer;
     _bookServer         = bookServer;
     _bookSelection      = bookSelection;
     _collectionSettings = collectionSettings;
     _webSocketServer    = webSocketServer;
     _standardProgress   = new WebSocketProgress(_webSocketServer, kWebsocketContext);
 }
Example #17
0
 //autofac uses this
 public WebLibraryView(NavigationIsolator isolator)
 {
     InitializeComponent();
     //_browser.GeckoReady += new EventHandler(OnLod);
     b = new Browser();
     b.Isolator = isolator;
     b.Parent = this;
     b.Dock = DockStyle.Fill;
     Controls.Add(b);
     Load+=new EventHandler(WebLibraryView_Load);
 }
Example #18
0
        public void WhenCollectedNoLocalDataThenLocalDataIsEmpty()
        {
            var first     = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator());
            var stringRep = DynamicJson.Serialize(new
            {
                library = new { librarystuff = "foo" }
            });

            first.CollectJsonData(stringRep.ToString());
            AssertEmpty(first.LocalData);
        }
Example #19
0
        public delegate WebLibraryView Factory();        //autofac uses this

        public WebLibraryView(NavigationIsolator isolator)
        {
            InitializeComponent();
            //_browser.GeckoReady += new EventHandler(OnLod);
            b          = new Browser();
            b.Isolator = isolator;
            b.Parent   = this;
            b.Dock     = DockStyle.Fill;
            Controls.Add(b);
            Load += new EventHandler(WebLibraryView_Load);
        }
        public void IdleNavigation_WhenNothingHappening_ProceedsAtOnce()
        {
            var    browser  = new BrowserStub();
            string target   = "http://any old web address";
            var    isolator = new NavigationIsolator();

            Assert.That(isolator.NavigateIfIdle(browser, target), Is.True);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target));
            browser.NormalTermination();
            Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed after navigation completes");
        }
        public void SimpleNavigation_JustHappens()
        {
            var    browser  = new BrowserStub();
            string target   = "http://any old web address";
            var    isolator = new NavigationIsolator();

            isolator.Navigate(browser, target);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target));
            browser.NormalTermination();
            Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed after navigation completes");
        }
Example #22
0
        public void ShowConfigureDialog()
        {
            var c = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator());

            var stringRep = DynamicJson.Serialize(new
            {
                library = new { calendar = new { year = "2088" } }
            });

            c.CollectJsonData(stringRep);

            c.ShowConfigurationDialog(Get_NotYetConfigured_CalendardBookStorage().FolderPath);
            Assert.IsTrue(c.GetLibraryData().Contains("year"));
        }
Example #23
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;
 }
Example #24
0
        public void LibrarySettingsAreRoundTriped()
        {
            var first     = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator());
            var stringRep = DynamicJson.Serialize(new
            {
                library = new { stuff = "foo" }
            });

            first.CollectJsonData(stringRep.ToString());

            var     second = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator());
            dynamic j      = (DynamicJson)DynamicJson.Parse(second.GetLibraryData());

            Assert.AreEqual("foo", j.library.stuff);
        }
Example #25
0
        public void Setup()
        {
            _thisTestId = Guid.NewGuid().ToString().Replace('-', '_');

            _workFolder     = new TemporaryFolder("unittest-" + _thisTestId);
            _workFolderPath = _workFolder.FolderPath;
            Assert.AreEqual(0, Directory.GetDirectories(_workFolderPath).Count(), "Some stuff was left over from a previous test");
            Assert.AreEqual(0, Directory.GetFiles(_workFolderPath).Count(), "Some stuff was left over from a previous test");
            // Todo: Make sure the S3 unit test bucket is empty.
            // Todo: Make sure the parse.com unit test book table is empty
            _parseClient              = new BloomParseClientDouble(_thisTestId);
            _htmlThumbNailer          = new HtmlThumbNailer(NavigationIsolator.GetOrCreateTheOneNavigationIsolator());
            _transfer                 = new BookTransfer(_parseClient, new BloomS3Client(BloomS3Client.UnitTestBucketName), new BookThumbNailer(_htmlThumbNailer), new BookDownloadStartingEvent());
            _transfer.BookDownLoaded += (sender, args) => _downloadedBooks.Add(args.BookDetails);
        }
Example #26
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;
        }
        public void IdleNavigation_NavigationInProgress_ReturnsFalse_NeverProceeds()
        {
            var    browser  = new BrowserStub();
            string target   = "http://any old web address";
            var    isolator = new NavigationIsolator();

            isolator.Navigate(browser, target);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target));
            string target2 = "http://some other web address";

            Assert.That(isolator.NavigateIfIdle(browser, target2), Is.False);
            browser.NormalTermination();
            Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed after navigation completes");
            Assert.That(browser.NavigateTarget, Is.EqualTo(target), "failed idle navigation should not happen");
        }
Example #28
0
 public PublishModel(BookSelection bookSelection, PdfMaker pdfMaker, CurrentEditableCollectionSelection currentBookCollectionSelection, CollectionSettings collectionSettings,
                     BookServer bookServer, BookThumbNailer thumbNailer, NavigationIsolator isolator)
 {
     BookSelection         = bookSelection;
     _pdfMaker             = pdfMaker;
     _pdfMaker.CompressPdf = true;               // See http://issues.bloomlibrary.org/youtrack/issue/BL-3721.
     //_pdfMaker.EngineChoice = collectionSettings.PdfEngineChoice;
     _currentBookCollectionSelection = currentBookCollectionSelection;
     ShowCropMarks                   = false;
     _collectionSettings             = collectionSettings;
     _bookServer                     = bookServer;
     _thumbNailer                    = thumbNailer;
     bookSelection.SelectionChanged += OnBookSelectionChanged;
     _isoloator = isolator;
     //we don't want to default anymore: BookletPortion = BookletPortions.BookletPages;
 }
Example #29
0
        public void CollectJsonData_HasArrayValue_DataMerged()
        {
            var firstData  = "{\"library\":{\"days\":[\"1\",\"2\"]}}";
            var secondData = "{\"library\":{\"days\":[\"o:e\",\"two\"]}}";

            var first = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator());

            first.CollectJsonData(firstData.ToString());
            first.CollectJsonData(secondData.ToString());

            var     second = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator());
            dynamic j      = (DynamicJson)DynamicJson.Parse(second.GetLibraryData());

            Assert.AreEqual("o:e", j.library.days[0]);
            Assert.AreEqual("two", j.library.days[1]);
        }
        public void SecondNavigation_OnSameBrowser_HappensAtOnce()
        {
            var    browser  = new BrowserStub();
            string target   = "http://any old web address";
            var    isolator = new NavigationIsolator();

            isolator.Navigate(browser, target);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target));
            string target2 = "http://some other web address";

            isolator.Navigate(browser, target2);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target2), "Second navigation should have proceeded at once");

            browser.NormalTermination();
            Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed");
        }
Example #31
0
        public AndroidView(NavigationIsolator isolator)
        {
            InitializeComponent();

            _browser          = new Browser();
            _browser.Isolator = isolator;
            _browser.Dock     = DockStyle.Fill;
            Controls.Add(_browser);
            // Has to be in front of the panel docked top for Fill to work.
            _browser.BringToFront();
            BloomFileLocator.GetBrowserFile(false, "gulpfile.js");
            var path = BloomFileLocator.GetBrowserFile(false, "publish", "android", "androidPublishUI.html");

            _browser.Navigate(path.ToLocalhost() + GetUrlParams(), false);

            VisibleChanged += OnVisibleChanged;
        }
        public void SecondRequest_WhenFirstNoLongerBusy_ProceedsAtOnce()
        {
            var    browser  = new BrowserStub();
            string target   = "http://any old web address";
            var    isolator = new NavigationIsolator();

            isolator.Navigate(browser, target);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target));
            browser.IsBusy = false;             // clear state without raising event
            string target2 = "http://some other web address";

            isolator.Navigate(browser, target2);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target2), "Second navigation should have proceeded since browser is already not busy");

            browser.NormalTermination();
            Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed");
        }
        public EpubView SetupEpubControl(EpubView view, NavigationIsolator _isolator, Action updateSaveButton)
        {
            if (view == null)
            {
                view = new EpubView();
                _epubPreviewBrowser          = new Browser();
                _epubPreviewBrowser.Isolator = _isolator;
                _epubPreviewBrowser.Dock     = DockStyle.Fill;
                view.Controls.Add(_epubPreviewBrowser);
                // Has to be in front of the panel docked top for Fill to work.
                _epubPreviewBrowser.BringToFront();
            }
            _model.PrepareToStageEpub();
            Action setupElectronicPublicationControlMethod = SetupEpubControlContent;

            HandleAudioSituation(setupElectronicPublicationControlMethod, _epubPreviewBrowser, updateSaveButton);
            updateSaveButton();
            return(view);
        }
        public void RegularNavigation_DelayedProperlyByIdleNavigation()
        {
            var    browser  = new BrowserStub();
            string target   = "http://any old web address";
            var    isolator = new NavigationIsolator();

            Assert.That(isolator.NavigateIfIdle(browser, target), Is.True);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target));

            string target2 = "http://some other web address";

            isolator.Navigate(browser, target2);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target), "Second navigation should not have proceeded at once");

            browser.NormalTermination();
            Assert.That(browser.NavigateTarget, Is.EqualTo(target2), "Second navigation should have proceeded when first completed");

            browser.NormalTermination();
            Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed");
        }
        public delegate LibraryBookView Factory();        //autofac uses this

        public LibraryBookView(BookSelection bookSelection,
                               //SendReceiver sendReceiver,
                               CreateFromSourceBookCommand createFromSourceBookCommand,
                               EditBookCommand editBookCommand,
                               SelectedTabChangedEvent selectedTabChangedEvent,
                               SelectedTabAboutToChangeEvent selectedTabAboutToChangeEvent,
                               NavigationIsolator isolator)
        {
            InitializeComponent();
            _previewBrowser.Isolator = isolator;
            _readmeBrowser.Isolator  = isolator;
            _bookSelection           = bookSelection;
            //_sendReceiver = sendReceiver;
            _createFromSourceBookCommand    = createFromSourceBookCommand;
            _editBookCommand                = editBookCommand;
            bookSelection.SelectionChanged += OnBookSelectionChanged;

            selectedTabAboutToChangeEvent.Subscribe(c =>
            {
                if (!(c.To is LibraryView))
                {
                    // We're becoming invisible. Stop any work in progress to generate a preview
                    // (thus allowing other browsers, like the ones in the Edit view, to navigate
                    // to their destinations.)
                    HidePreview();
                }
            });

            selectedTabChangedEvent.Subscribe(c =>
            {
                var wasVisible = _visible;
                _visible       = c.To is LibraryView;
                if (_reshowPending || wasVisible != _visible)
                {
                    ShowBook();
                }
            });

            _editBookButton.Visible = false;
        }
        public void TwoPendingNavigationsOnDifferentBrowsers_WithNavigatedEvents_AreHandledCorrectly()
        {
            var    browser  = new BrowserStub();
            string target   = "http://any old web address";
            var    isolator = NavigationIsolator.GetOrCreateTheOneNavigationIsolator();

            isolator.Navigate(browser, target);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target));
            string target2  = "http://some other web address";
            var    browser2 = new BrowserStub();

            isolator.Navigate(browser2, target2);
            string target3  = "http://yet another other web address";
            var    browser3 = new BrowserStub();

            isolator.Navigate(browser3, target3);
            Assert.That(browser.NavigateTarget, Is.EqualTo(target), "Second and third navigation should not have proceeded at once");
            Assert.That(browser2.NavigateTarget, Is.Null, "browser 2 should not have navigated anywhere yet");
            Assert.That(browser3.NavigateTarget, Is.Null, "browser 3 should not have navigated anywhere yet");

            browser.NormalTermination();
            Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed");
            Assert.That(browser2.NavigateTarget, Is.EqualTo(target2), "Second navigation should have proceeded (on second browser) first completed");
            Assert.That(browser.NavigateTarget, Is.EqualTo(target), "First browser should not have navigated again");
            Assert.That(browser3.NavigateTarget, Is.Null, "browser 3 should not have navigated anywhere when first completed");

            browser2.NormalTermination();
            Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "nothing new should have happened to browser 1");
            Assert.That(browser2.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed");
            Assert.That(browser3.NavigateTarget, Is.EqualTo(target3), "Third navigation should have proceeded when second completed");
            Assert.That(browser2.NavigateTarget, Is.EqualTo(target2), "Second browser should not have navigated again");
            Assert.That(browser.NavigateTarget, Is.EqualTo(target), "First browser should not have navigated again");

            browser3.NormalTermination();
            Assert.That(browser3.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed");
            Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "nothing new should have happened to browser 1");
            Assert.That(browser2.EventHandlerCount, Is.EqualTo(0), "nothing new should have happened to browser 2");
        }
Example #37
0
        public void CollectJsonData_NewTopLevelData_DataMerged()
        {
            var firstData = DynamicJson.Serialize(new
            {
                library = new { one = "1", color = "red" }
            });
            var secondData = DynamicJson.Serialize(new
            {
                library = new { two = "2", color = "blue" }
            });

            var first = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator());

            first.CollectJsonData(firstData.ToString());
            first.CollectJsonData(secondData.ToString());

            var     second = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator());
            dynamic j      = (DynamicJson)DynamicJson.Parse(second.GetLibraryData());

            Assert.AreEqual("2", j.library.two);
            Assert.AreEqual("1", j.library.one);
            Assert.AreEqual("blue", j.library.color);
        }
Example #38
0
 public EpubMaker(BookThumbNailer thumbNailer, NavigationIsolator _isolator)
 {
     _thumbNailer = thumbNailer;
     _browser.Isolator = _isolator;
 }
Example #39
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();
        }
Example #40
0
 public FeedbackDialog(IChangeableFileLocator fileLocator, NavigationIsolator _isolator)
 {
     _fileLocator = fileLocator;
     InitializeComponent();
     _browser.Isolator = _isolator;
 }