Пример #1
0
        public void Setup()
        {
            _tempFolder = new TemporaryFolder();
            _filePath   = _tempFolder.GetTemporaryFile();

            WeSayProjectTestHelper.InitializeForTests();
            string[] vernacularWritingSystemIds = new string[]
            {
                WritingSystemsIdsForTests.VernacularIdForTest
            };
            _viewTemplate = new ViewTemplate();
            _viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(),
                                        "LexEntry",
                                        vernacularWritingSystemIds));
            _viewTemplate.Add(new Field("Note",
                                        "LexEntry",
                                        new string[] { "en" },
                                        Field.MultiplicityType.ZeroOr1,
                                        "MultiText"));
            _lexEntryRepository = new LexEntryRepository(_filePath);

            EntryViewControl.Factory entryViewFactory = (() => new EntryViewControl());
            _dictControlFactory = (memory => new DictionaryControl(entryViewFactory, _lexEntryRepository, _viewTemplate, memory, new StringLogger()));

            _taskMemoryRepository = new TaskMemoryRepository();
            _task = new DictionaryTask(_dictControlFactory, DictionaryBrowseAndEditConfiguration.CreateForTests("definition"), _lexEntryRepository,
                                       _taskMemoryRepository);

//            _task = new DictionaryTask( DictionaryBrowseAndEditConfiguration.CreateForTests(),  _lexEntryRepository,
//                _viewTemplate, new TaskMemoryRepository(),   new StringLogger())};//, new UserSettingsForTask());
        }
Пример #2
0
 private void SaveRecord()
 {
     if (_missingInfoControl != null && _missingInfoControl.CurrentEntry != null)
     {
         LexEntryRepository.SaveItem(_missingInfoControl.CurrentEntry);
     }
 }
Пример #3
0
        private static void SortLift(string outputPath, LexEntryRepository lexEntryRepository, ViewTemplate template)
        {
            using (var exporter = new LiftWriter(outputPath, LiftWriter.ByteOrderStyle.NoBOM))
            {
                IWritingSystemDefinition firstWs      = template.HeadwordWritingSystems[0];
                ResultSet <LexEntry>     recordTokens =
                    lexEntryRepository.GetAllEntriesSortedByHeadword(firstWs);
                int index = 0;
                foreach (RecordToken <LexEntry> token in recordTokens)
                {
                    int homographNumber = 0;
                    if ((bool)token["HasHomograph"])
                    {
                        homographNumber = (int)token["HomographNumber"];
                    }
                    LexEntry lexEntry = token.RealObject;
                    EmbeddedXmlCollection sortedAnnotation = new EmbeddedXmlCollection();
                    sortedAnnotation.Values.Add("<annotation name='sorted-index' value='" + (++index) + "'/>");

                    lexEntry.Properties.Add(new KeyValuePair <string, IPalasoDataObjectProperty>("SortedIndex", sortedAnnotation));

                    exporter.Add(lexEntry, homographNumber);
                }

                exporter.End();
            }
        }
Пример #4
0
        public void Setup()
        {
            _temporaryFolder = new TemporaryFolder();
            string filePath = _temporaryFolder.GetTemporaryFile();

            _lexEntryRepository = new LexEntryRepository(filePath);
        }
Пример #5
0
        public GatherBySemanticDomainTask(
            GatherBySemanticDomainConfig config,
            LexEntryRepository lexEntryRepository,
            ViewTemplate viewTemplate,
            TaskMemoryRepository taskMemoryRepository,
            ILogger logger
            ) :
            base(
                config,
                lexEntryRepository,
                viewTemplate, taskMemoryRepository
                )
        {
            ViewTemplate = viewTemplate;
            Guard.AgainstNull(config, "config");
            Guard.AgainstNull(viewTemplate, "viewTemplate");
            _config = config;
            _logger = logger;

            _taskMemory = taskMemoryRepository.FindOrCreateSettingsByTaskId(config.TaskName);


            _currentDomainIndex   = -1;
            _currentQuestionIndex = 0;
            _words = null;

            _semanticDomainField = viewTemplate.GetField(LexSense.WellKnownProperties.SemanticDomainDdp4);
            var definitionWsId = viewTemplate.GetField(LexSense.WellKnownProperties.Definition).WritingSystemIds.First();
            IWritingSystemDefinition writingSystemForDefinition = viewTemplate.WritingSystems.Get(definitionWsId);

            Guard.AgainstNull(writingSystemForDefinition, "Definition input System");
            DefinitionWritingSystem = writingSystemForDefinition;
        }
Пример #6
0
		public void Setup()
		{
			WeSayWordsProject.InitializeForTests();

			_filePath = Path.GetTempFileName();
			_lexEntryRepository = new LexEntryRepository(_filePath);
		}
Пример #7
0
		public void Setup()
		{
			_tempFolder = new TemporaryFolder();
			_wordListFilePath = _tempFolder.GetTemporaryFile();
			_filePath = _tempFolder.GetTemporaryFile();
			//Db4oLexModelHelper.InitializeForNonDbTests();
			WeSayWordsProject.InitializeForTests();

			_lexEntryRepository = new LexEntryRepository(_filePath); // InMemoryRecordListManager();
			_glossingLanguageWSId = BasilProject.Project.WritingSystems.TestWritingSystemAnalId;
			_vernacularLanguageWSId = BasilProject.Project.WritingSystems.TestWritingSystemVernId;

			File.WriteAllLines(_wordListFilePath, _words);
			_viewTemplate = new ViewTemplate();
			_viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(),
										"LexEntry",
										new string[]
											{
													BasilProject.Project.WritingSystems.
															TestWritingSystemVernId
											}));

			_task = new GatherWordListTask( GatherWordListConfig.CreateForTests( _wordListFilePath,_glossingLanguageWSId),
											_lexEntryRepository,
										   _viewTemplate);
		}
Пример #8
0
        public void Setup()
        {
            WeSayProjectTestHelper.InitializeForTests();

            _tempFolder         = new TemporaryFolder();
            _filePath           = _tempFolder.GetTemporaryFile();
            _lexEntryRepository = new LexEntryRepository(_filePath);

            _target = CreateEntry("one", "single item");
            _source = CreateEntry("single", "one item");

            CreateEntry("verde", "green");
            CreateEntry("amarelho", "yellow");
            CreateEntry("azul", "blue");

            _synonymsRelationField = new Field("synonyms",
                                               "LexEntry",
                                               new string[] { WritingSystemsIdsForTests.OtherIdForTest },
                                               Field.MultiplicityType.ZeroOrMore,
                                               "RelationToOneEntry");
            _synonymsRelationType = new LexRelationType("synonyms",
                                                        LexRelationType.Multiplicities.Many,
                                                        LexRelationType.TargetTypes.Sense);

            _singleSynonymRelationField = new Field("synonym",
                                                    "LexEntry",
                                                    new string[] { WritingSystemsIdsForTests.OtherIdForTest },
                                                    Field.MultiplicityType.ZeroOr1,
                                                    "RelationToOneEntry");
            _singleSynonymRelationType = new LexRelationType("synonym",
                                                             LexRelationType.Multiplicities.One,
                                                             LexRelationType.TargetTypes.Sense);
        }
Пример #9
0
        protected WordGatheringTaskBase(ITaskConfiguration config,
                                        LexEntryRepository lexEntryRepository,
                                        ViewTemplate viewTemplate,
                                        TaskMemoryRepository taskMemoryRepository)
            : base(config,
                   lexEntryRepository, taskMemoryRepository)
        {
            if (viewTemplate == null)
            {
                throw new ArgumentNullException("viewTemplate");
            }

            _viewTemplate             = viewTemplate;
            _lexicalFormWritingSystem =
                viewTemplate.GetDefaultWritingSystemForField(Field.FieldNames.EntryLexicalForm.ToString());

            var glossField = _viewTemplate.GetField(LexSense.WellKnownProperties.Gloss);

            if (glossField == null)
            {
                _glossMeaningField = false;
            }
            else
            {
                _glossMeaningField = glossField.IsMeaningField;
            }
        }
Пример #10
0
        protected string CreateFileToOpen(ProjectInfo projectInfo,
                                          bool linkToUserCss)
        {
            LexEntryRepository lexEntryRepository = projectInfo.ServiceProvider.GetService(typeof(LexEntryRepository)) as LexEntryRepository;
            var pliftPath = Path.Combine(projectInfo.PathToExportDirectory, projectInfo.Name + ".plift");


            var maker = new PLiftMaker();

            maker.MakePLiftTempFile(pliftPath, lexEntryRepository,
                                    projectInfo.ServiceProvider.GetService(typeof(ViewTemplate)) as
                                    ViewTemplate, LiftWriter.ByteOrderStyle.NoBOM);


            var pathToOutput = Path.Combine(projectInfo.PathToExportDirectory,
                                            projectInfo.Name + ".html");

            if (File.Exists(pathToOutput))
            {
                File.Delete(pathToOutput);
            }

            var htmWriter = new FLExCompatibleXhtmlWriter(linkToUserCss, ((WeSay.Project.WeSayWordsProject)projectInfo.Project).DefaultViewTemplate);

            SetupLetterGroups(projectInfo, htmWriter);

            using (var reader = new StreamReader(pliftPath))
            {
                using (var file = new StreamWriter(pathToOutput, false, new UTF8Encoding(false)))
                {
                    htmWriter.Write(reader, file);
                }
            }
            return(pathToOutput);
        }
Пример #11
0
		public void Setup()
		{
			WeSayWordsProject.InitializeForTests();

			_tempFolder = new TemporaryFolder();
			_filePath = _tempFolder.GetTemporaryFile();
			_lexEntryRepository = new LexEntryRepository(_filePath);

			_target = CreateEntry("one", "single item");
			_source = CreateEntry("single", "one item");

			CreateEntry("verde", "green");
			CreateEntry("amarelho", "yellow");
			CreateEntry("azul", "blue");

			_synonymsRelationField = new Field("synonyms",
											   "LexEntry",
											   new string[] {"vernacular"},
											   Field.MultiplicityType.ZeroOrMore,
											   "RelationToOneEntry");
			_synonymsRelationType = new LexRelationType("synonyms",
														LexRelationType.Multiplicities.Many,
														LexRelationType.TargetTypes.Sense);

			_singleSynonymRelationField = new Field("synonym",
											  "LexEntry",
											  new string[] {"vernacular"},
											  Field.MultiplicityType.ZeroOr1,
											  "RelationToOneEntry");
			_singleSynonymRelationType = new LexRelationType("synonym",
													   LexRelationType.Multiplicities.One,
													   LexRelationType.TargetTypes.Sense);
		}
Пример #12
0
		public PLiftExporter(string path,
							 LexEntryRepository lexEntryRepository,
							 ViewTemplate viewTemplate): base(path)
		{
			this._lexEntryRepository = lexEntryRepository;
			this._viewTemplate = viewTemplate;
		}
Пример #13
0
		public LiftUpdateService(LexEntryRepository lexEntryRepository)
		{
			_lexEntryRepository = lexEntryRepository;
			// todo LexEntryRepository owns a LiftUpdateService and manages it directly. e.g. on SaveItem
			//_lexEntryRepository.Db4oDataSource.DataCommitted += new EventHandler(liftUpdateService.OnDataCommitted);
			//_lexEntryRepository.Db4oDataSource.DataDeleted += new EventHandler<DeletedItemEventArgs>(liftUpdateService.OnDataDeleted);
		}
Пример #14
0
 protected Layouter(DetailList table,
                    int beginningRow,
                    ViewTemplate viewTemplate,
                    LexEntryRepository lexEntryRepository,
                    IServiceProvider serviceProvider,
                    PalasoDataObject pdoToLayout)
 {
     if (table == null)
     {
         throw new ArgumentNullException("table");
     }
     if (viewTemplate == null)
     {
         throw new ArgumentNullException("viewTemplate");
     }
     PdoToLayout         = pdoToLayout;
     FirstRow            = beginningRow;
     _detailList         = table;
     _viewTemplate       = viewTemplate;
     _lexEntryRepository = lexEntryRepository;
     _serviceProvider    = serviceProvider;
     //Set up the space for the delete icon
     _deleteButton.Click  += OnDeleteClicked;
     _deleteButton.Active  = false;
     _deleteButton.Visible = false;
     _deleteButton.ToolTip = StringCatalog.Get("Delete Meaning");
     DetailList.Controls.Add(_deleteButton, 2, beginningRow);
     DetailList.MouseEnteredBounds += OnMouseEnteredBounds;
     DetailList.MouseLeftBounds    += OnMouseLeftBounds;
     ChildLayouts       = new List <Layouter>();
     _glossMeaningField = null;
 }
Пример #15
0
		public void Setup()
		{
			BasilProject.InitializeForTests();

			_FilePath = Path.GetTempFileName();
			_lexEntryRepository = new LexEntryRepository(_FilePath);

			_outputPath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());

			_writingSystemIds = new List<string>(new string[] {"red", "green", "blue"});
			_headwordWritingSystem = new WritingSystem(_writingSystemIds[0],
													   new Font(FontFamily.GenericSansSerif, 10));

			_viewTemplate = new ViewTemplate();

			_viewTemplate.Add(new Field(LexEntry.WellKnownProperties.Citation,
										"LexEntry",
										new string[] {"blue", "red"}));
			_viewTemplate.Add(new Field(LexEntry.WellKnownProperties.LexicalUnit,
										"LexEntry",
										new string[] {"red", "green", "blue"}));
			_viewTemplate.Add(new Field(LexEntry.WellKnownProperties.BaseForm,
										"LexEntry",
										_writingSystemIds));

			Field visibleCustom = new Field("VisibleCustom",
											"LexEntry",
											_writingSystemIds,
											Field.MultiplicityType.ZeroOr1,
											"MultiText");
			visibleCustom.Visibility = CommonEnumerations.VisibilitySetting.Visible;
			visibleCustom.DisplayName = "VisibleCustom";
			_viewTemplate.Add(visibleCustom);
		}
Пример #16
0
            public TestEnvironment()
            {
                _temporaryFolder = new TemporaryFolder();
                string filePath = _temporaryFolder.GetTemporaryFile();

                _repository = new LexEntryRepository(filePath);
            }
Пример #17
0
        public void Setup()
        {
            _tempfolder = new TemporaryFolder();
            string persistedFilePath = _tempfolder.GetTemporaryFile();

            _repository = new LexEntryRepository(persistedFilePath);
        }
Пример #18
0
        private static void RenderHeadword(LexEntry entry,
                                           StringBuilder html,
                                           LexEntryRepository lexEntryRepository)
        {
            if (StartNewSpan(html, HeadWordWritingSystemId, true, false, 0))
            {
                LanguageForm headword = entry.GetHeadWord(HeadWordWritingSystemId);
                if (null != headword)
                {
                    var str = MakeSafeForHtmlAndFormat(headword.Form);
                    html.Append(str);

                    int homographNumber = lexEntryRepository.GetHomographNumber(
                        entry,
                        WeSayWordsProject.Project.DefaultViewTemplate.HeadwordWritingSystem
                        );
                    if (homographNumber > 0)
                    {
                        html.Append("<sub>" + homographNumber.ToString() + "</sub>");
                    }
                }
                else
                {
                    html.Append("??? ");
                }
                html.Append(" </span>");
            }
        }
Пример #19
0
        private static void RenderHeadword(LexEntry entry,
                                           StringBuilder rtf,
                                           LexEntryRepository lexEntryRepository)
        {
            rtf.Append(@"{\b ");
            LanguageForm headword = entry.GetHeadWord(HeadWordWritingSystemId);

            if (null != headword)
            {
                // rtf.Append(RenderField(headword, currentItem, 2, null));

                rtf.Append(SwitchToWritingSystem(headword.WritingSystemId, 2));
                rtf.Append(headword.Form);
                //   rtf.Append(" ");

                int homographNumber = lexEntryRepository.GetHomographNumber(
                    entry,
                    WeSayWordsProject.Project.DefaultViewTemplate.HeadwordWritingSystem
                    );
                if (homographNumber > 0)
                {
                    rtf.Append(@"{\sub " + homographNumber + "}");
                }
            }
            else
            {
                rtf.Append("??? ");
            }
            rtf.Append("}");
        }
Пример #20
0
		public PLiftExporter(StringBuilder builder,
							 bool produceFragmentOnly,
							 LexEntryRepository lexEntryRepository,
							 ViewTemplate viewTemplate): base(builder, produceFragmentOnly)
		{
			this._lexEntryRepository = lexEntryRepository;
			this._viewTemplate = viewTemplate;
		}
Пример #21
0
		public Dash(LexEntryRepository RecordListManager, ICurrentWorkTask currentWorkTaskProvider)//, UserSettingsForTask userSettings)
		{
			_oldFlowWidth = 0;
			_lexEntryRepository = RecordListManager;
			_currentWorkTaskProvider = currentWorkTaskProvider;
			InitializeContextMenu();
			Initialize();
		}
Пример #22
0
 public AddPicturesTask(AddPicturesConfig config,
                        LexEntryRepository lexEntryRepository,
                        TaskMemoryRepository taskMemoryRepository,
                        IFileLocator fileLocator)
     : base(config, lexEntryRepository, taskMemoryRepository)
 {
     _config = config;
 }
Пример #23
0
        public ResultSet <LexEntry> GetFilteredData()
        {
            ResultSet <LexEntry> data =
                LexEntryRepository.GetEntriesWithMissingFieldSortedByLexicalUnit(
                    GetQuery(), GetLexicalUnitWritingSystem());

            _dataHasBeenRetrieved = true;
            return(data);
        }
Пример #24
0
		public void Setup()
		{
			WeSayWordsProject.InitializeForTests();
			_filePath = Path.GetTempFileName();
			_lexEntryRepository = new LexEntryRepository(_filePath);
			_fieldToOptionListName = new Dictionary<string, string>();
			_stringBuilder = new StringBuilder();
			PrepWriterForFragment();
		}
Пример #25
0
 public PLiftExporter(StringBuilder builder,
                      bool produceFragmentOnly,
                      LexEntryRepository lexEntryRepository,
                      ViewTemplate viewTemplate) : base(builder, produceFragmentOnly)
 {
     _lexEntryRepository       = lexEntryRepository;
     _viewTemplate             = viewTemplate;
     _headwordWritingSystemIds = _viewTemplate.GetHeadwordWritingSystemIds();
 }
Пример #26
0
        public static string ToHtml(LexEntry entry,
                                    CurrentItemEventArgs currentItem,
                                    LexEntryRepository lexEntryRepository,
                                    System.Drawing.Color backColor)
        {
            _fontFamilies      = new List <string>();
            _fontFamiliesStyle = new StringBuilder();
            italicsOn          = false;
            if (lexEntryRepository == null)
            {
                throw new ArgumentNullException("lexEntryRepository");
            }
            if (entry == null)
            {
                return(string.Empty);
            }

            var html = new StringBuilder();

            // The {0} is filled in by the setHtml method that consumes the html generated here
            // The {1} is filled in by the font-face sections created by AddFontFamily which are required by some fonts on Windows
            html.Append("<html><header><meta charset=\"UTF-8\"><style>{1}</style></head><body style='background:{0}' id='mainbody'><div style='min-height:20px' id='main' name='textArea' contentEditable='false'>");
            RenderHeadword(entry, html, lexEntryRepository);

            int senseNumber = 1;

            foreach (LexSense sense in entry.Senses)
            {
                RenderSense(entry, sense, senseNumber, currentItem, html);

                ++senseNumber;
            }

            Field glossField = WeSayWordsProject.Project.GetFieldFromDefaultViewTemplate(LexSense.WellKnownProperties.Gloss);

            if (glossField.IsMeaningField)
            {
                html.Append(RenderGhostedField(null,
                                               LexSense.WellKnownProperties.Gloss,
                                               currentItem,
                                               entry.Senses.Count + 1));
            }
            else
            {
                html.Append(RenderGhostedField(null,
                                               LexSense.WellKnownProperties.Definition,
                                               currentItem,
                                               entry.Senses.Count + 1));
            }

            html.Append("</div></body></html>");
            String strHtmlColor = System.Drawing.ColorTranslator.ToHtml(backColor);
            var    finalHtml    = string.Format(html.ToString(), strHtmlColor, _fontFamiliesStyle);

            return(finalHtml.ToString());
        }
Пример #27
0
        public AdvancedHistoryTask(IAdvancedHistoryConfig config,
                                   LexEntryRepository lexEntryRepository,
                                   TaskMemoryRepository taskMemoryRepository,
                                   IComponentContext diContainer)

            : base(config, lexEntryRepository, taskMemoryRepository)
        {
            _config      = config;
            _diContainer = diContainer;
        }
Пример #28
0
        public void Setup()
        {
            WeSayProjectTestHelper.InitializeForTests();
            _filePath           = Path.GetTempFileName();
            _liftFilePath       = Path.GetTempFileName();
            _lexEntryRepository = new LexEntryRepository(_filePath);

            _addin = new HtmlTransformer();
            _addin.LaunchAfterTransform = false;
        }
Пример #29
0
		public void Setup()
		{
			WeSayWordsProject.InitializeForTests();
			_filePath = Path.GetTempFileName();
			_liftFilePath = Path.GetTempFileName();
			_lexEntryRepository = new LexEntryRepository(_filePath);

			_addin = new HtmlTransformer();
			_addin.LaunchAfterTransform = false;
		}
Пример #30
0
//        public ResultSet<LexEntry> NotifyOfAddedWord()
//        {
//            return
//                    LexEntryRepository.GetEntriesWithMatchingGlossSortedByLexicalForm(
//                            CurrentWordAsMultiText.Find(_preferredPromptingWritingSystemId),
//                            _lexicalUnitWritingSystem);
//        }

        public ResultSet <LexEntry> GetRecordsWithMatchingGloss()
        {
            //var form = CurrentWordAsMultiText.GetBestAlternative(new string[]{_preferredPromptingWritingSystemId});
            var form = CurrentPromptingLanguageForm;

            return
                (LexEntryRepository.GetEntriesWithMatchingGlossSortedByLexicalForm(
                     form,
                     _lexicalUnitWritingSystem));
        }
Пример #31
0
		public GatherBySemanticDomainTask(IGatherBySemanticDomainsConfig config,
										  LexEntryRepository lexEntryRepository,
										  ViewTemplate viewTemplate)
			: base(
			   config,
				lexEntryRepository,
				viewTemplate)
		{
			if (config == null)
			{
				throw new ArgumentNullException("config");
			}
			if (string.IsNullOrEmpty(config.semanticDomainsQuestionFileName))
			{
				throw new ArgumentNullException("config.semanticDomainsQuestionFileName");
			}
			if (viewTemplate == null)
			{
				throw new ArgumentNullException("viewTemplate");
			}

			_currentDomainIndex = -1;
			_currentQuestionIndex = 0;
			_words = null;
			_semanticDomainQuestionsFileName =
				DetermineActualQuestionsFileName(config.semanticDomainsQuestionFileName);
			if (!File.Exists(_semanticDomainQuestionsFileName))
			{
				string pathInProject =
					Path.Combine(
						WeSayWordsProject.Project.PathToWeSaySpecificFilesDirectoryInProject,
						_semanticDomainQuestionsFileName);
				if (File.Exists(pathInProject))
				{
					_semanticDomainQuestionsFileName = pathInProject;
				}
				else
				{
					string pathInProgramDir = Path.Combine(BasilProject.ApplicationCommonDirectory,
														   _semanticDomainQuestionsFileName);
					if (!File.Exists(pathInProgramDir))
					{
						throw new ApplicationException(
							string.Format(
								"Could not find the semanticDomainQuestions file {0}. Expected to find it at: {1} or {2}. The name of the file is influenced by the first enabled writing system for the Semantic Domain Field.",
								_semanticDomainQuestionsFileName,
								pathInProject,
								pathInProgramDir));
					}
					_semanticDomainQuestionsFileName = pathInProgramDir;
				}
			}

			_semanticDomainField = viewTemplate.GetField("SemanticDomainDdp4");
		}
Пример #32
0
        public NotesBrowserTask(INotesBrowserConfig config,
                                LexEntryRepository lexEntryRepository,
                                TaskMemoryRepository taskMemoryRepository,
                                System.Func <Chorus.UI.Notes.Browser.NotesBrowserPage> getBrowserPage
                                )

            : base(config, lexEntryRepository, taskMemoryRepository)
        {
            _getBrowserPage = getBrowserPage;
            //   _diContainer = diContainer;
        }
Пример #33
0
		public DictionaryTask(DictionaryBrowseAndEditConfiguration config,
								LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate)
			: base(config, lexEntryRepository)
		{
			if (viewTemplate == null)
			{
				throw new ArgumentNullException("viewTemplate");
			}
			_viewTemplate = viewTemplate;
			//  _userSettings = userSettings;
		}
Пример #34
0
		public DictionaryServiceProvider(LexEntryRepository lexEntryRepository,
										 WeSayApp app,
										 WeSayWordsProject project)
		{
			_app = app;
			_project = project;
			_registeredClientProcessIds = new List<int>();
			_lexEntryRepository = lexEntryRepository;
			_articleMaker = new HtmlArticleMaker(_project.LocateFile("WritingSystemPrefs.xml"),
												 _project.LocateFile("PartsOfSpeech.xml"));
		}
Пример #35
0
        public void Setup()
        {
            _repoFile = new TempLiftFile("");
            _repo     = new LexEntryRepository(_repoFile.Path);
            AddPicturesConfig config = new AddPicturesConfig(string.Format("<task taskName='AddMissingInfo' visible='true'><indexFileName>{0}</indexFileName></task>", "ArtOfReadingIndexV3_en.txt"));

            _task = new AddPicturesTask(config, _repo,
                                        new TaskMemoryRepository(),
                                        new FileLocator(new string[] { WeSay.Project.BasilProject.ApplicationCommonDirectory }));
            _task.Activate();
        }
Пример #36
0
        //        [Test]
        //        public void TabKeySkipsReadOnlyField()
        //        {
        //            while (true)
        //            {
        //                Application.DoEvents();
        //            }
        //        }

        public override void TearDown()
        {
            _window.Close();
            _window.Dispose();
            _window = null;
            _task.Deactivate();
            _lexEntryRepository.Dispose();
            _lexEntryRepository = null;
            _tempFolder.Delete();
            base.TearDown();
        }
Пример #37
0
 public PLiftExporter(string path,
                      LexEntryRepository lexEntryRepository,
                      ViewTemplate viewTemplate)
     : base(path, LiftWriter.ByteOrderStyle.BOM)
 {
     _path                     = path;
     _disposed                 = true; // In case we throw in the constructor
     _lexEntryRepository       = lexEntryRepository;
     _viewTemplate             = viewTemplate;
     _headwordWritingSystemIds = new List <string>(_viewTemplate.GetHeadwordWritingSystemIds());
     _disposed                 = false;
 }
Пример #38
0
 public Dash(LexEntryRepository RecordListManager, ICurrentWorkTask currentWorkTaskProvider)        //, UserSettingsForTask userSettings)
 {
     _buttonRows              = new List <List <DashboardButton> >();
     _oldPanelWidth           = 0;
     _buttonsPerRow           = 0;
     _buttonRowMargin         = new Padding(30, 0, 0, 15);
     _buttonMargin            = new Padding(3);
     _lexEntryRepository      = RecordListManager;
     _currentWorkTaskProvider = currentWorkTaskProvider;
     InitializeContextMenu();
     Initialize();
 }
Пример #39
0
        /// <summary>
        /// Adds this word and gloss, potentially adding the current semantic domain to multiple entriew with that word and gloss.
        /// </summary>
        /// <param name="lexicalForm"></param>
        /// <param name="gloss"></param>
        /// <returns>the entries that were modified </returns>
        public IList <LexEntry> AddWord(string lexicalForm, string gloss)
        {
            VerifyTaskActivated();

            if (string.IsNullOrEmpty(lexicalForm))
            {
                throw new ArgumentNullException();
            }
            var modifiedEntries = new List <LexEntry>();

            if (lexicalForm != string.Empty)
            {
                ResultSet <LexEntry> recordTokens =
                    LexEntryRepository.GetEntriesWithMatchingLexicalForm(lexicalForm,
                                                                         FormWritingSystem);
                if (recordTokens.Count == 0)                //no entries with a matching form
                {
                    LexEntry entry = LexEntryRepository.CreateItem();
                    entry.LexicalForm.SetAlternative(WordWritingSystemId, lexicalForm);
                    AddCurrentSemanticDomainToEntry(entry, gloss);
                    LexEntryRepository.SaveItem(entry);
                    modifiedEntries.Add(entry);

                    _logger.WriteConciseHistoricalEvent("SD-Added '{0}' with Domain to '{1}'", entry.GetSimpleFormForLogging(), CurrentDomainName);
                }
                else                // one or more matching entries
                {
                    var entriesMatchingWord = new List <LexEntry>(from RecordToken <LexEntry> x in recordTokens select x.RealObject);
                    foreach (var entry in entriesMatchingWord)
                    {
                        if (HasMatchingSense(entry, gloss))
                        {
                            modifiedEntries.Add(entry);
                            AddCurrentSemanticDomainToEntry(entry, gloss);
                            _logger.WriteConciseHistoricalEvent("SD-Added Domain to '{0}'", entry.GetSimpleFormForLogging());
                            break;
                        }
                    }
                    if (modifiedEntries.Count == 0)                     //didn't find any matching glosses
                    {
                        //NB: what to do IS NOT CLEAR. This just adds to the first entry,
                        // but it's just rolling the dice!  What to do???
                        var first = entriesMatchingWord.First();
                        modifiedEntries.Add(first);
                        AddCurrentSemanticDomainToEntry(first, gloss);
                        _logger.WriteConciseHistoricalEvent("SD-Added Domain {0} to '{1}' REVIEW", CurrentDomainName, first.GetSimpleFormForLogging());
                    }
                }
            }
            _savedSensesDuringMoveToEditArea = null;
            UpdateCurrentWords();
            return(modifiedEntries);
        }
Пример #40
0
		public Db4oProjectSetupForTesting(string xmlOfEntries)
		{
			_projectDirectory = new ProjectDirectorySetupForTesting(xmlOfEntries);

			_project = new WeSayWordsProject();
			_project.LoadFromLiftLexiconPath(_projectDirectory.PathToLiftFile);
			//CacheBuilder cacheBuilder = new CacheBuilder(_projectDirectory.PathToLiftFile);
			//cacheBuilder.DoWork(new NullProgressState());

			_lexEntryRepository = new LexEntryRepository(_project.PathToRepository);
			// InMemoryRecordListManager();
		}
Пример #41
0
 public void NewEntry_ByEntry_TriggersModifiedEntryAdded()
 {
     using (var f = new TemporaryFolder("eventTests"))
     {
         using (var r = new LexEntryRepository(f.GetPathForNewTempFile(true)))
         {
             r.AfterEntryModified += OnEvent;
             LexEntry entry = r.CreateItem();
             r.SaveItem(entry);
             Assert.IsTrue(_gotEventCall);
         }
     }
 }
Пример #42
0
        public void Setup()
        {
            WeSayProjectTestHelper.InitializeForTests();
            _glossingLanguageWSId   = WritingSystemsIdsForTests.AnalysisIdForTest;
            _vernacularLanguageWSId = WritingSystemsIdsForTests.VernacularIdForTest;
            BasilProject.Project.WritingSystems.Set(WritingSystemDefinition.Parse("fr"));

            _tempFolder             = new TemporaryFolder();
            _simpleWordListFilePath = _tempFolder.GetTemporaryFile();
//            _liftWordListFile = new TempLiftFile("wordlist.lift",_tempFolder, LiftXml, LiftIO.Validation.Validator.LiftVersion);
            _filePath = _tempFolder.GetTemporaryFile();

            _lexEntryRepository = new LexEntryRepository(_filePath);             // InMemoryRecordListManager();
            File.WriteAllLines(_simpleWordListFilePath, _words);
            _viewTemplate = new ViewTemplate();
            _viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(),
                                        "LexEntry",
                                        new string[]
            {
                WritingSystemsIdsForTests.VernacularIdForTest
            }));

            _viewTemplate.Add(
                new Field(
                    LexSense.WellKnownProperties.Definition.ToString(),
                    "LexSense",
                    new string[]
            {
                WritingSystemsIdsForTests.AnalysisIdForTest,
                "fr"
            }
                    )
                );

            _viewTemplate.Add(
                new Field(
                    LexSense.WellKnownProperties.Gloss.ToString(),
                    "LexSense",
                    new string[]
            {
                WritingSystemsIdsForTests.AnalysisIdForTest,
                "fr"
            }
                    )
                );
            _catalog = new WordListCatalog();
            _catalog.Add(_simpleWordListFilePath, new WordListDescription("en", "label", "longLabel", "description"));
            _task = new GatherWordListTask(GatherWordListConfig.CreateForTests(_simpleWordListFilePath, _glossingLanguageWSId, _catalog),
                                           _lexEntryRepository,
                                           _viewTemplate, new TaskMemoryRepository());
        }
Пример #43
0
		public MissingInfoTask(MissingInfoConfiguration config,
							   LexEntryRepository lexEntryRepository,
							   ViewTemplate viewTemplate)
			: base( config, lexEntryRepository)
		{
			if (config.MissingInfoField == null)
			{
				throw new ArgumentNullException("MissingInfoField");
			}
			if (viewTemplate == null)
			{
				throw new ArgumentNullException("viewTemplate");
			}

			_missingInfoField = viewTemplate[config.MissingInfoField];

			_viewTemplate = CreateViewTemplateFromListOfFields(viewTemplate, config.FieldsToShow);
			MarkReadOnlyFields(config.FieldsToShowReadOnly);

			//hack until we overhaul how Tasks are setup:
			_isBaseFormFillingTask = config.FieldsToShow.Contains(LexEntry.WellKnownProperties.BaseForm);
			if (_isBaseFormFillingTask)
			{
				Field flagField = new Field();
				flagField.DisplayName = StringCatalog.Get("~This word has no Base Form",
														  "The user will click this to say that this word has no baseform.  E.g. Kindess has Kind as a baseform, but Kind has no other word as a baseform.");
				flagField.DataTypeName = "Flag";
				flagField.ClassName = "LexEntry";
				flagField.FieldName = "flag_skip_" + config.MissingInfoField;
				flagField.Enabled = true;
				_viewTemplate.Add(flagField);
			}
			_writingSystem = BasilProject.Project.WritingSystems.UnknownVernacularWritingSystem;
			// use the master view Template instead of the one for this task. (most likely the one for this
			// task doesn't have the EntryLexicalForm field specified but the Master (Default) one will
			Field fieldDefn =
				WeSayWordsProject.Project.DefaultViewTemplate.GetField(
					Field.FieldNames.EntryLexicalForm.ToString());
			if (fieldDefn != null)
			{
				if (fieldDefn.WritingSystemIds.Count > 0)
				{
					_writingSystem = BasilProject.Project.WritingSystems[fieldDefn.WritingSystemIds[0]];
				}
				else
				{
					throw new ConfigurationException("There are no writing systems enabled for the Field '{0}'",
													 fieldDefn.FieldName);
				}
			}
		}
Пример #44
0
 public void Activate_IndexNotFound_GivesUserMessage()
 {
     using (var repoFile = new TempLiftFile(""))
     {
         using (var repo = new LexEntryRepository(repoFile.Path))
         {
             AddPicturesConfig config = MakeConfig("Bogus.txt");
             var task = new AddPicturesTask(config, repo,
                                            new TaskMemoryRepository(),
                                            new FileLocator(new string[0]));
             Assert.Throws <ConfigurationException>(() => task.Activate());
         }
     }
 }
		public void Setup()
		{
			WeSayWordsProject.Project.RemoveCache();
			_tempFolder = new TemporaryFolder();
			_filePath = _tempFolder.GetTemporaryFile();
			_semanticDomainFilePath = _tempFolder.GetTemporaryFile();
			CreateSemanticDomainFile();

			_lexEntryRepository = new LexEntryRepository(_filePath);
			_viewTemplate = MakeViewTemplate("en");
			_task = new GatherBySemanticDomainTask(_semanticDomainFilePath,
												   _lexEntryRepository,
												   _viewTemplate);
		}
Пример #46
0
        public DictionaryControl(EntryViewControl.Factory entryViewControlFactory, LexEntryRepository lexEntryRepository,
                                 ViewTemplate viewTemplate, IUserInterfaceMemory memory, ILogger logger)
        {
            if (lexEntryRepository == null)
            {
                throw new ArgumentNullException("lexEntryRepository");
            }
            if (viewTemplate == null)
            {
                throw new ArgumentNullException("viewTemplate");
            }
            _viewTemplate       = viewTemplate;
            _logger             = logger;
            _lexEntryRepository = lexEntryRepository;

            InitializeComponent();

            if (DesignMode)
            {
                return;
            }


            SetupPickerControlWritingSystems();

            InitializeDisplaySettings();


            _findTextAdapter    = new ResultSetToListOfStringsAdapter("Form", _records);
            SearchTextBox.Items = _findTextAdapter;

            _recordsListBox.ItemSelectionChanged += OnRecordsListBoxItemSelectionChanged;
            _recordsListBox.MinLength             = 10;
            _recordsListBox.MaxLength             = 20;
            _recordsListBox.BackColor             = Color.White;

            SetListWritingSystem(
                _viewTemplate.GetDefaultWritingSystemForField(
                    Field.FieldNames.EntryLexicalForm.ToString()));

            _searchTextBoxControl.TextBox.KeyDown += OnFindText_KeyDown;
            _searchTextBoxControl.TextBox.AutoCompleteChoiceSelected += OnSearchText_AutoCompleteChoiceSelected;
            _searchTextBoxControl.FindButton.Click += OnFind_Click;

            _splitter.SetMemory(memory);
            SetupEntryViewControl(entryViewControlFactory);
            _entryViewControl.SetMemory(memory.CreateNewSection("entryView"));

            UpdateDisplay();
        }
Пример #47
0
		public void SetUp()
		{
			WeSayWordsProject.InitializeForTests();

			_tempFolder = new TemporaryFolder();
			_filePath = _tempFolder.GetTemporaryFile();
			_lexEntryRepository = new LexEntryRepository(_filePath);

#if GlossMeaning
		   _primaryMeaningFieldName = Field.FieldNames.SenseGloss.ToString();
#else
			_primaryMeaningFieldName = LexSense.WellKnownProperties.Definition;
#endif

			string[] analysisWritingSystemIds = new string[]
													{
															BasilProject.Project.WritingSystems.
																	TestWritingSystemAnalId
													};
			string[] vernacularWritingSystemIds = new string[]
													  {
															  BasilProject.Project.WritingSystems.
																	  TestWritingSystemVernId
													  };
			RtfRenderer.HeadWordWritingSystemId = vernacularWritingSystemIds[0];

			_viewTemplate = new ViewTemplate();
			_viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(),
										"LexEntry",
										vernacularWritingSystemIds));
			_viewTemplate.Add(new Field(_primaryMeaningFieldName,
										"LexSense",
										analysisWritingSystemIds));
			_viewTemplate.Add(new Field(Field.FieldNames.ExampleSentence.ToString(),
										"LexExampleSentence",
										vernacularWritingSystemIds));
			_viewTemplate.Add(new Field(Field.FieldNames.ExampleTranslation.ToString(),
										"LexExampleSentence",
										analysisWritingSystemIds));

			empty = CreateTestEntry("", "", "");
			apple = CreateTestEntry("apple", "red thing", "An apple a day keeps the doctor away.");
			banana = CreateTestEntry("banana", "yellow food", "Monkeys like to eat bananas.");
			car = CreateTestEntry("car",
								  "small motorized vehicle",
								  "Watch out for cars when you cross the street.");
			bike = CreateTestEntry("bike", "vehicle with two wheels", "He rides his bike to school.");
		}
Пример #48
0
		public void MakePLiftForBiatah2()
		{
			using (WeSayWordsProject p = new WeSayWordsProject())
			{
				p.LoadFromProjectDirectoryPath(@"E:\Users\John\Documents\WeSay\biatah");

				using (
						LexEntryRepository lexEntryRepository =
								new LexEntryRepository(p.PathToRepository))
				{
					PLiftMaker maker = new PLiftMaker();
					string path = maker.MakePLiftTempFile(lexEntryRepository, p.DefaultPrintingTemplate);
					Console.WriteLine(path);
				}
			}
		}
		public void Setup()
		{
			_tempFolder = new TemporaryFolder();
			_filePath = _tempFolder.GetTemporaryFile();
			_lexEntryRepository = new LexEntryRepository(_filePath);

			_target = _lexEntryRepository.CreateItem();
			_source = _lexEntryRepository.CreateItem();

			Field relationField = new Field("synonyms",
											"LexEntry",
											new string[] {"vernacular"},
											Field.MultiplicityType.ZeroOr1,
											"RelationToOneEntry");
			_missingRelationFieldFilter = new MissingFieldQuery(relationField);
		}
Пример #50
0
		public DashboardControl(LexEntryRepository lexEntryRepository,
								ICurrentWorkTask currentWorkTaskProvider)
		{
			if (lexEntryRepository == null)
			{
				throw new ArgumentNullException("lexEntryRepository");
			}
			if (currentWorkTaskProvider == null)
			{
				throw new ArgumentNullException("currentWorkTaskProvider");
			}
			_taskIndicators = new List<TaskIndicator>();
			_lexEntryRepository = lexEntryRepository;
			_currentWorkTaskProvider = currentWorkTaskProvider;

			//InitializeComponent();
			InitializeContextMenu();
		}
Пример #51
0
		//private string MakePLiftTempFile(IEnumerable<LexEntry> entries, ViewTemplate template, IFindEntries finder)
		//{
		//    string path = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
		//    LiftExporter exporter = new LiftExporter(path);
		//    exporter.SetUpForPresentationLiftExport(template, finder);
		//    foreach (LexEntry entry in entries)
		//    {
		//        exporter.Add(entry);
		//    }
		//    exporter.End();
		//    return path;
		//}

		public string MakePLiftTempFile(LexEntryRepository lexEntryRepository, ViewTemplate template)
		{
			string path = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
			PLiftExporter exporter = new PLiftExporter(path, lexEntryRepository, template);
			ResultSet<LexEntry> recordTokens =
					lexEntryRepository.GetAllEntriesSortedByHeadword(template.HeadwordWritingSystem);
			foreach (RecordToken<LexEntry> token in recordTokens)
			{
				int homographNumber = 0;
				if ((bool) token["HasHomograph"])
				{
					homographNumber = (int) token["HomographNumber"];
				}
				exporter.Add(token.RealObject, homographNumber);
			}

			exporter.End();
			return path;
		}
Пример #52
0
		public void Setup()
		{
			_tempFolder = new TemporaryFolder();
			_filePath = _tempFolder.GetTemporaryFile();
			_lexEntryRepository = new LexEntryRepository(_filePath);

			Form window = new Form();
			window.Size = new Size(800, 600);

			_lexEntryRepository.CreateItem();

			Dash dash = new Dash(_lexEntryRepository, null);//, new UserSettingsForTask());
			dash.ThingsToMakeButtonsFor = GetButtonItems();
			dash.Dock = DockStyle.Fill;
			window.Controls.Add(dash);
			window.BackColor = dash.BackColor;
			dash.Activate();
			Application.Run(window);
		}
Пример #53
0
		public void SetUp()
		{
			WeSayWordsProject.InitializeForTests();

			_tempFolder = new TemporaryFolder();
			_filePath = _tempFolder.GetTemporaryFile();
			_lexEntryRepository = new LexEntryRepository(_filePath);

			_writingSystem = new WritingSystem("pretendVernacular",
											   new Font(FontFamily.GenericSansSerif, 24));

			CreateTestEntry("apple", "red thing", "An apple a day keeps the doctor away.");
			CreateTestEntry("banana", "yellow food", "Monkeys like to eat bananas.");
			CreateTestEntry("car",
							"small motorized vehicle",
							"Watch out for cars when you cross the street.");
			CreateTestEntry("dog", "animal with four legs; man's best friend", "He walked his dog.");

			string[] analysisWritingSystemIds = new string[] {"analysis"};
			string[] vernacularWritingSystemIds = new string[] {_writingSystem.Id};
			RtfRenderer.HeadWordWritingSystemId = vernacularWritingSystemIds[0];

			_viewTemplate = new ViewTemplate();
			_viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(),
										"LexEntry",
										vernacularWritingSystemIds));
			_viewTemplate.Add(new Field(LexSense.WellKnownProperties.Definition,
										"LexSense",
										analysisWritingSystemIds));

			_viewTemplate.Add(new Field(Field.FieldNames.ExampleSentence.ToString(),
										"LexExampleSentence",
										vernacularWritingSystemIds));
			Field exampleTranslationField = new Field(
					Field.FieldNames.ExampleTranslation.ToString(),
					"LexExampleSentence",
					analysisWritingSystemIds);
			_viewTemplate.Add(exampleTranslationField);

			_missingTranslationRecordList =
					_lexEntryRepository.GetEntriesWithMissingFieldSortedByLexicalUnit(
							exampleTranslationField, _writingSystem);
		}
Пример #54
0
		public TaskBase(ITaskConfiguration config,
						LexEntryRepository lexEntryRepository)
		{
			if (config.Label == null)
			{
				throw new ArgumentNullException("label");
			}
			if (config.LongLabel == null)
			{
				throw new ArgumentNullException("longLabel");
			}
			if (config.Description == null)
			{
				throw new ArgumentNullException("description");
			}
			if (config.RemainingCountText == null)
			{
				throw new ArgumentNullException("remainingCountText");
			}
			if (config.ReferenceCountText == null)
			{
				throw new ArgumentNullException("referenceCountText");
			}
			if (lexEntryRepository == null)
			{
				throw new ArgumentNullException("lexEntryRepository");
			}
			_lexEntryRepository = lexEntryRepository;
			// convert any amount of whitespace to one space
			Regex rgx = new Regex("\\s+");
			_label = rgx.Replace (config.Label.Trim(), " ");
			_longLabel = rgx.Replace (config.LongLabel.Trim(), " ");
			_description = rgx.Replace (config.Description.Trim(), " ");
			_remainingCountText = rgx.Replace (config.RemainingCountText.Trim(), " ");
			_referenceCountText = rgx.Replace (config.ReferenceCountText.Trim(), " ");
			_isPinned = config.IsPinned;

			_cachePath = WeSayWordsProject.Project.PathToCache;
			_cacheFilePath = Path.Combine(_cachePath, MakeSafeName(Label + ".cache"));

			ReadCacheFile();
		}
Пример #55
0
		public DictionaryControl(LexEntryRepository lexEntryRepository, ViewTemplate viewTemplate)
		{
			if (lexEntryRepository == null)
			{
				throw new ArgumentNullException("lexEntryRepository");
			}
			if (viewTemplate == null)
			{
				throw new ArgumentNullException("viewTemplate");
			}
			_viewTemplate = viewTemplate;
			_lexEntryRepository = lexEntryRepository;
			_cmWritingSystems = new ContextMenu();

			SetupPickerControlWritingSystems();

			InitializeComponent();
			InitializeDisplaySettings();

			_writingSystemChooser.Image = Resources.Expand.GetThumbnailImage(6,
																			 6,
																			 ReturnFalse,
																			 IntPtr.Zero);
			_btnFind.Image = Resources.Find.GetThumbnailImage(18, 18, ReturnFalse, IntPtr.Zero);
			_btnDeleteWord.Image = Resources.DeleteWord;
			_btnNewWord.Image = Resources.NewWord.GetThumbnailImage(18, 18, ReturnFalse, IntPtr.Zero);

			Control_EntryDetailPanel.ViewTemplate = _viewTemplate;
			Control_EntryDetailPanel.LexEntryRepository = _lexEntryRepository;

			_findTextAdapter = new ResultSetToListOfStringsAdapter("Form", _records);
			_findText.Items = _findTextAdapter;

			SetListWritingSystem(
					_viewTemplate.GetDefaultWritingSystemForField(
							Field.FieldNames.EntryLexicalForm.ToString()));

			_findText.KeyDown += _findText_KeyDown;
			_recordsListBox.SelectedIndexChanged += OnRecordSelectionChanged;

			UpdateDisplay();
		}
        {
			LexEntryRepositoryLoaderService x = new LexEntryRepositoryLoaderService(pathToLift);
			return x.GetLexEntryRepository();
		}
        private void Load()
        {
			using (ProgressDialog dlg = new ProgressDialog())
			{
				dlg.Overview = "Please wait while WeSay loads your data.";
				BackgroundWorker worker = new BackgroundWorker();
				worker.DoWork += delegate (object sender, DoWorkEventArgs args)
									 {
										 ProgressState progressState = (ProgressState) args.Argument;
										 try
										 {

											 _lexEntryRepository = new LexEntryRepository(_pathToLift, progressState);
											 args.Result = _lexEntryRepository;

										 }
										 catch(Exception error)
										 {
											 args.Cancel = true;//review
											 args.Result = error;
											 progressState.ExceptionThatWasEncountered = error;
										 }
									 };
				dlg.BackgroundWorker = worker;
				dlg.CanCancel = false;

				dlg.ShowDialog();
				if (dlg.DialogResult != DialogResult.OK)
				{
					Exception err = dlg.ProgressStateResult.ExceptionThatWasEncountered;
					if (err != null)
					{
						throw err;
					}
					else if (dlg.ProgressStateResult.State ==
							 ProgressState.StateValue.StoppedWithError)
					{
Пример #57
0
		public override void Setup()
		{
			base.Setup();
			this.tabbedForm = new TabbedForm();
			this.tabbedForm.Show();
			string name = new Finder().Name(this.tabbedForm);
			_mainWindowTester = new FormTester(name);


			_project = new WeSayWordsProject();
			_project.StringCatalogSelector = "en";
			_project.LoadFromProjectDirectoryPath(WeSayWordsProject.GetPretendProjectDirectory());
			_project.Tasks = new List<ITask>();
			_project.Tasks.Add(new MockTask("Dashboard", "The control center.", true));


			_lexEntryRepository = new InMemoryRecordListManager();
			LexEntry entry = new LexEntry();
			_lexEntryRepository.Get<LexEntry>().Add(entry);
			_project.Tasks.Add(new WeSay.LexicalTools.EntryDetailTask(_lexEntryRepository));

		}
Пример #58
0
		public void Setup()
		{
			_tempFolder = new TemporaryFolder();
			_filePath = _tempFolder.GetTemporaryFile();

			WeSayWordsProject.InitializeForTests();
			string[] vernacularWritingSystemIds = new string[]
													  {
															  BasilProject.Project.WritingSystems.
																	  TestWritingSystemVernId
													  };
			_viewTemplate = new ViewTemplate();
			_viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(),
										"LexEntry",
										vernacularWritingSystemIds));
			_viewTemplate.Add(new Field("Note",
										"LexEntry",
										new string[] {"en"},
										Field.MultiplicityType.ZeroOr1,
										"MultiText"));
			_lexEntryRepository = new LexEntryRepository(_filePath);
			_task = new DictionaryTask( DictionaryBrowseAndEditConfiguration.CreateForTests(),  _lexEntryRepository, _viewTemplate);//, new UserSettingsForTask());
		}
Пример #59
0
		// private bool _suspendNotificationOfNavigation=false;

		public GatherWordListTask(IGatherWordListConfig config,
									LexEntryRepository lexEntryRepository,
								  ViewTemplate viewTemplate)

				: base(config, lexEntryRepository, viewTemplate)
		{
			if (config.WordListFileName == null)
			{
				throw new ArgumentNullException("wordListFileName");
			}
			if (config.WordListWritingSystemId == null)
			{
				throw new ArgumentNullException("wordListWritingSystemId");
			}
			if (viewTemplate == null)
			{
				throw new ArgumentNullException("viewTemplate");
			}
			Field lexicalFormField =
					viewTemplate.GetField(Field.FieldNames.EntryLexicalForm.ToString());
			if (lexicalFormField == null || lexicalFormField.WritingSystemIds.Count < 1)
			{
				_lexicalUnitWritingSystem =
						BasilProject.Project.WritingSystems.UnknownVernacularWritingSystem;
			}
			else
			{
				string firstWSid = lexicalFormField.WritingSystemIds[0];
				WritingSystem firstWS = BasilProject.Project.WritingSystems[firstWSid];
				_lexicalUnitWritingSystem = firstWS;
			}

			_wordListFileName = config.WordListFileName;
			_words = null;
			_writingSystemIdForWordListWords = config.WordListWritingSystemId;
		}
Пример #60
0
		protected WordGatheringTaskBase(ITaskConfiguration config,
										LexEntryRepository lexEntryRepository,
										ViewTemplate viewTemplate)
				: base( config,
						lexEntryRepository)
		{
			if (viewTemplate == null)
			{
				throw new ArgumentNullException("viewTemplate");
			}

			_viewTemplate = viewTemplate;
			Field lexicalFormField =
					viewTemplate.GetField(Field.FieldNames.EntryLexicalForm.ToString());
			WritingSystemCollection writingSystems = BasilProject.Project.WritingSystems;
			if (lexicalFormField == null || lexicalFormField.WritingSystemIds.Count < 1)
			{
				_lexicalFormWritingSystem = writingSystems.UnknownVernacularWritingSystem;
			}
			else
			{
				_lexicalFormWritingSystem = writingSystems[lexicalFormField.WritingSystemIds[0]];
			}
		}