Beispiel #1
0
        public NewCollectionWizard(bool showWelcome)
        {
            InitializeComponent();

            Icon = Resources.BloomIcon;

            if (ReallyDesignMode)
            {
                return;
            }

            _collectionInfo           = new NewCollectionSettings();
            _kindOfCollectionPage.Tag = kindOfCollectionControl1;
            kindOfCollectionControl1.Init(SetNextButtonState, _collectionInfo);

            _languageLocationPage.Tag = _languageLocationControl;
            _languageLocationControl.Init(_collectionInfo);

            _collectionNamePage.Tag = _collectionNameControl;
            _collectionNameControl.Init(SetNextButtonState, _collectionInfo, DefaultParentDirectoryForCollections);

            _vernacularLanguagePage.Tag = _vernacularLanguageIdControl;
            _vernacularLanguageIdControl.Init(SetNextButtonState, _collectionInfo);

            _welcomePage.Suppress = !showWelcome;

            //The L10NSharpExtender and this wizard don't get along (they conspire to crash Visual Studio with a stack overflow)
            //so we do all of this by hand
            SetLocalizedStrings();

            _wizardControl.AfterInitialization();
        }
Beispiel #2
0
        public BookDownloadSupport()
        {
            // We need the download folder to exist if we are asked to download a book.
            // We also want it to exist, to show the (planned) link that offers to launch the web site.
            // Another advantage of creating it early is that we don't have to create it in the UI when we want to add
            // a downloaded book to the UI.
            // So, we just make sure it exists here at startup.
            string downloadFolder = BookTransfer.DownloadFolder;

            if (!Directory.Exists(downloadFolder))
            {
                var pathToSettingsFile = CollectionSettings.GetPathForNewSettings(Path.GetDirectoryName(downloadFolder),
                                                                                  Path.GetFileName(downloadFolder));
                var settings = new NewCollectionSettings()
                {
                    Language1Iso639Code = "en",
                    Language1Name       = "English",
                    IsSourceCollection  = true,
                    PathToSettingsFile  = pathToSettingsFile
                                          // All other defaults are fine
                };
                CollectionSettings.CreateNewCollection(settings);
            }

            // Make the OS run Bloom when it sees bloom://somebooktodownload
            RegisterForBloomUrlProtocol();
        }
        public static void EnsureDownloadFolderExists()
        {
            // We need the download folder to exist if we are asked to download a book.
            // We also want it to exist, to show the (planned) link that offers to launch the web site.
            // Another advantage of creating it early is that we don't have to create it in the UI when we want to add
            // a downloaded book to the UI.
            // So, we just make sure it exists here at startup.
            string downloadFolder = BookDownload.DownloadFolder;

            if (!Directory.Exists(downloadFolder))
            {
                var pathToSettingsFile = CollectionSettings.GetPathForNewSettings(Path.GetDirectoryName(downloadFolder),
                                                                                  Path.GetFileName(downloadFolder));
                var settings = new NewCollectionSettings()
                {
                    IsSourceCollection = true,
                    PathToSettingsFile = pathToSettingsFile
                                         // All other defaults are fine
                };
                settings.Language1.Iso639Code = "en";
                settings.Language1.SetName("English", false);
                CollectionSettings.CreateNewCollection(settings);
                ProjectContext.ClearUserInstalledDirectoriesCache();
            }
        }
Beispiel #4
0
        public void OneTimeSetup()
        {
            _testFolder = new TemporaryFolder("SpreadsheetImporterWithBookTests");
            // We need 2 layers of temp folder because BringBookUpToDate will change the name of the book
            // folder to match an imported title.
            _bookFolder = new TemporaryFolder(_testFolder, "Book");
            var settings = new NewCollectionSettings();

            settings.Language1.Iso639Code = "en";
            settings.Language1.SetName("English", false);
            settings.SettingsFilePath = Path.Combine(_bookFolder.FolderPath, "dummy");

            var fileLocator = new BloomFileLocator(settings, new XMatterPackFinder(new string[] { }), ProjectContext.GetFactoryFileLocations(),
                                                   ProjectContext.GetFoundFileLocations(), ProjectContext.GetAfterXMatterFileLocations());
            var bookFilePath = Path.Combine(_bookFolder.FolderPath, "testBook.htm");

            if (File.Exists(bookFilePath))             // Shouldn't ever happen, but... just being careful.
            {
                RobustFile.Delete(bookFilePath);
            }
            _dom = SetupTestDom();
            // Write out our test book
            File.WriteAllText(bookFilePath, _dom.RawDom.OuterXml.ToString());
            var storage = new BookStorage(_bookFolder.FolderPath, fileLocator, new BookRenamedEvent(), settings);

            var book = new Bloom.Book.Book(new BookInfo(_bookFolder.FolderPath, true), storage, null,
                                           settings, new Bloom.Edit.PageSelection(),
                                           new PageListChangedEvent(), new BookRefreshEvent());

            // Create the regular production importer
            _importer = new SpreadsheetImporter(null, book, _bookFolder.FolderPath);

            // Set up the internal spreadsheet rows directly.
            var ss             = new InternalSpreadsheet();
            var columnForEn    = ss.AddColumnForLang("en", "English");
            var columnForImage = ss.GetColumnForTag(InternalSpreadsheet.ImageSourceColumnLabel);

            var newTitle = "My new book title";
            var titleRow = new ContentRow(ss);

            titleRow.AddCell(InternalSpreadsheet.BookTitleRowLabel);
            titleRow.SetCell(columnForEn, newTitle);

            var coverImageRow = new ContentRow(ss);

            coverImageRow.AddCell(InternalSpreadsheet.CoverImageRowLabel);
            coverImageRow.SetCell(columnForImage, Path.Combine("images", "Othello 199.jpg"));

            _importer.Import(ss);

            _resultElement = ReadResultingBookToXml(newTitle);
        }
Beispiel #5
0
        private static void MakeCollection(string root, string language, string language1Iso639Code)
        {
            var spec = new NewCollectionSettings()
            {
                PathToSettingsFile       = CollectionSettings.GetPathForNewSettings(root, language + " P1 Teacher's Guide"),
                AllowNewBooks            = false,
                Country                  = "Uganda",
                DefaultLanguage1FontName = language,
                Language1Iso639Code      = language1Iso639Code,
                IsSourceCollection       = false,
                Language2Iso639Code      = "en"
            };

            var collectionSettings = new CollectionSettings(spec);

            collectionSettings.DefaultLanguage1FontName = "Calibri";
            collectionSettings.Save();

            var folio = MakeBook(collectionSettings, kpathToSHRPTemplates + "UgandaSHARP-P1GuideFolio");

            //The Teacher's Guide has a set of vernacular labels that are inserted via custom style sheets. This copies
            //and renames the one for this language.
            File.Copy(kpathToSHRPTemplates + "UgandaSHARP-P1TeacherGuide/" + language + "Labels.css", Path.Combine(collectionSettings.FolderPath, "customCollectionStyles.css"));

            var themes = "Human body and health,Weather,Weather,Weather,Accidents and safety,Accidents and safety,Accidents and safety,Living together,Living together,Living together,Food and Nutrition,Food and Nutrition,Transport,Transport,Transport,Things we make,Things we make,Things we make,Our environment,Our environment,Our environment,Peace and security,Peace and security"
                         .Split(new[] { ',' });

            var themeNumbers    = "4,5,5,5,6,6,6,7,7,7,8,8,9,9,9,10,10,10,11,11,11,12,12".Split(new[] { ',' });
            var subThemes       = "Personal hygiene,Elements and types of weather,Activities for different seasons,Effects and management of weather,Accidents and safety at home,Accidents and safety on the way,Accidents and safety at school,The family,Ways of living together in the school,Ways of living together in the community,Names and sources of food,Uses of food,Types and means of transport,Importance of transport,Measures related to transport,Things we make at home and school,Materials we use and their sources,Importance of things we make,Components and importance of things in our environment,Factors that damage our environment,Conservation of our environment,Peace and security in our home,Peace and security in our school".Split(new[] { ',' });
            var subThemeNumbers = "2,1,2,3,1,2,3,1,2,3,1,2,1,2,3,1,2,3,1,2,3,1,2".Split(new[] { ',' });

            var bookCount = 0;

            for (int term = 1; term < 4; term++)
            {
                var termIntro = MakeBook(collectionSettings, kpathToSHRPTemplates + "UgandaSHARP-P1TeacherGuideTermIntro");
                termIntro.SetDataItem("term", term.ToString(), "en");
                termIntro.Save();

                for (int week = 2; week < 3; week++)
                {
                    var weekBook = MakeBook(collectionSettings, kpathToSHRPTemplates + "UgandaSHARP-P1TeacherGuide");
                    weekBook.SetDataItem("term", term.ToString(), "*");
                    weekBook.SetDataItem("week", week.ToString(), "*");

                    SetThemeStuff(weekBook, themes[bookCount], themeNumbers[bookCount], subThemes[bookCount], subThemeNumbers[bookCount]);
                    weekBook.Save();
                    ++bookCount;
                }
            }
        }
Beispiel #6
0
        public NewCollectionWizard(bool showWelcome)
        {
            InitializeComponent();

            if (ReallyDesignMode)
            {
                return;
            }

            _collectionInfo           = new NewCollectionSettings();
            _kindOfCollectionPage.Tag = kindOfCollectionControl1;
            kindOfCollectionControl1.Init(SetNextButtonState, _collectionInfo);

            _languageLocationPage.Tag = _languageLocationControl;
            _languageLocationControl.Init(_collectionInfo);

            _collectionNamePage.Tag = _collectionNameControl;
            _collectionNameControl.Init(SetNextButtonState, _collectionInfo, DefaultParentDirectoryForCollections);

            _vernacularLanguagePage.Tag = _vernacularLanguageIdControl;
            _vernacularLanguageIdControl.Init(SetNextButtonState, _collectionInfo);

            _welcomePage.Suppress = !showWelcome;

            //The L10NSharpExtender and this wizard don't get along (they conspire to crash Visual Studio with a stack overflow)
            //so we do all of this by hand
            var chooser = new Button();            // new L10NSharp.UI.UILanguageComboBox() { ShowOnlyLanguagesHavingLocalizations = false };

            chooser.Location = new Point(100, 100);
            chooser.Size     = new Size(50, 50);
            chooser.Visible  = true;
            chooser.Anchor   = AnchorStyles.Top | AnchorStyles.Right;
            //chooser.SelectedValueChanged += new EventHandler(chooser_SelectedValueChanged);
            wizardControl1.Controls.Add(chooser);

            SetLocalizedStrings();

            wizardControl1.AfterInitialization();
        }
Beispiel #7
0
 public void Init(Action <UserControl, bool> SetButtonState, NewCollectionSettings collectionInfo, string destinationDirectory)
 {
     _setNextButtonState   = SetButtonState;
     _collectionInfo       = collectionInfo;
     _destinationDirectory = destinationDirectory;
 }
Beispiel #8
0
 private void OnCancel(object sender, EventArgs e)
 {
     DialogResult = DialogResult.Cancel;
     Close();
     _collectionInfo = null;
 }
Beispiel #9
0
 public void Init(NewCollectionSettings collectionInfo)
 {
     _collectionInfo = collectionInfo;
 }