Exemplo n.º 1
0
        private void OnFinishClick(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;

            // The progress dialog takes a few seconds to appear. Disable all controls so the user doesn't think they can click anything.
            Enabled = false;

            using (new WaitCursor(this))
                using (var threadHelper = new ThreadHelper())
                    using (var progressDialog = new ProgressDialogWithTask(threadHelper))
                    {
                        m_dbFile = m_model.CreateNewLangProj(progressDialog, threadHelper);
                    }
            Close();
        }
Exemplo n.º 2
0
        private static void CreateDb(string dbName, string vernWs = "fr")
        {
            var testProject = new FwNewLangProjectModel(true)
            {
                LoadProjectNameSetup = () => { },
                LoadVernacularSetup  = () => { },
                LoadAnalysisSetup    = () => { },
                ProjectName          = dbName,
                AnthroModel          = new FwChooseAnthroListModel {
                    CurrentList = FwChooseAnthroListModel.ListChoice.UserDef
                }
            };

            testProject.Next();
            testProject.SetDefaultWs(new LanguageInfo {
                LanguageTag = vernWs
            });
            testProject.Next();
            using (var threadHelper = new ThreadHelper())
            {
                testProject.CreateNewLangProj(new DummyProgressDlg(), threadHelper);
            }
        }
Exemplo n.º 3
0
        public void FwNewLangProjectModel_VerifyCreateNewLangProject()
        {
            LcmCache cache = null;

            var testProject = new FwNewLangProjectModel(true)
            {
                LoadProjectNameSetup = () => { },
                LoadVernacularSetup  = () => { },
                LoadAnalysisSetup    = () => { },
                AnthroModel          = new FwChooseAnthroListModel {
                    CurrentList = FwChooseAnthroListModel.ListChoice.UserDef
                }
            };

            try
            {
                testProject.ProjectName = DbName;
                testProject.Next();
                testProject.SetDefaultWs(new LanguageInfo {
                    LanguageTag = "fr"
                });
                testProject.Next();
                testProject.SetDefaultWs(new LanguageInfo {
                    LanguageTag = "de"
                });
                using (var threadHelper = new ThreadHelper())
                {
                    testProject.CreateNewLangProj(new DummyProgressDlg(), threadHelper);
                }

                Assert.IsTrue(DbExists(DbName));

                // despite of the name is DummyProgressDlg no real dialog (doesn't derive from Control), so
                // we don't need a 'using'
                cache = LcmCache.CreateCacheFromExistingData(
                    new TestProjectId(BackendProviderType.kXMLWithMemoryOnlyWsMgr, DbFilename(DbName)), "en", new DummyLcmUI(),
                    FwDirectoryFinder.LcmDirectories, new LcmSettings(), new DummyProgressDlg());
                CheckInitialSetOfPartsOfSpeech(cache);

                Assert.AreEqual(2, cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.Count);
                Assert.AreEqual("German", cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.First().LanguageName);
                Assert.AreEqual("English", cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.Last().LanguageName);
                Assert.AreEqual(2, cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Count);
                Assert.AreEqual("German", cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.LanguageName);
                Assert.AreEqual("English", cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Last().LanguageName,
                                "English should be selected as an analysis writing system even if the user tried to remove it");
                Assert.AreEqual(1, cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Count);
                Assert.AreEqual("French", cache.ServiceLocator.WritingSystems.VernacularWritingSystems.First().LanguageName);
                Assert.AreEqual(1, cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Count);
                Assert.AreEqual("French", cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.LanguageName);
            }
            finally
            {
                // Blow away the database to clean things up
                if (cache != null)
                {
                    cache.Dispose();
                }
                DestroyDb(DbName, false);
            }
        }