Beispiel #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());
        }
Beispiel #2
0
        public DictionaryTask(DictionaryControl.Factory dictionaryControlFactory,
                              DictionaryBrowseAndEditConfiguration config,
                              LexEntryRepository lexEntryRepository,
                              TaskMemoryRepository taskMemoryRepository)
            : base(config, lexEntryRepository, taskMemoryRepository)
        {
            _dictionaryControlFactory = dictionaryControlFactory;
//            if (viewTemplate == null)
//            {
//                throw new ArgumentNullException("viewTemplate");
//            }
//            _viewTemplate = viewTemplate;
//            _logger = logger;
            _taskMemory = taskMemoryRepository.FindOrCreateSettingsByTaskId(config.TaskName);
        }
        public override void Setup()
        {
            base.Setup();
            _tempFolder = new TemporaryFolder();
            _vernacularWritingSystem            = WritingSystemDefinition.Parse(WritingSystemsIdsForTests.VernacularIdForTest);
            RtfRenderer.HeadWordWritingSystemId = _vernacularWritingSystem.Id;

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

            _analysisWritingSystemIds = new string[]
            {
                WritingSystemsIdsForTests.AnalysisIdForTest
            };
            string[]     vernacularWritingSystemIds = new string[] { _vernacularWritingSystem.Id };
            ViewTemplate viewTemplate = new ViewTemplate();

            viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(),
                                       "LexEntry",
                                       vernacularWritingSystemIds));
            viewTemplate.Add(new Field("focusOnMe",
                                       "LexEntry",
                                       _analysisWritingSystemIds,
                                       Field.MultiplicityType.ZeroOr1,
                                       "MultiText"));
            viewTemplate.Add(new Field("MyEntryCustom",
                                       "LexEntry",
                                       _analysisWritingSystemIds,
                                       Field.MultiplicityType.ZeroOr1,
                                       "MultiText"));

            Field readOnlySemanticDomain =
                new Field(LexSense.WellKnownProperties.SemanticDomainDdp4,
                          "LexSense",
                          _analysisWritingSystemIds);

            readOnlySemanticDomain.Visibility = CommonEnumerations.VisibilitySetting.ReadOnly;
            viewTemplate.Add(readOnlySemanticDomain);

            Field shy1 = new Field("MyShyEntryCustom",
                                   "LexEntry",
                                   _analysisWritingSystemIds,
                                   Field.MultiplicityType.ZeroOr1,
                                   "MultiText");

            shy1.Visibility  = CommonEnumerations.VisibilitySetting.NormallyHidden;
            shy1.DisplayName = "MyShyEntryCustom";
            viewTemplate.Add(shy1);

#if GlossMeaning
            viewTemplate.Add(new Field(Field.FieldNames.SenseGloss.ToString(), "LexSense", analysisWritingSystemIds));
#else
            _definitionField = new Field(LexSense.WellKnownProperties.Definition,
                                         "LexSense",
                                         _analysisWritingSystemIds);
            viewTemplate.Add(_definitionField);
#endif
            viewTemplate.Add(new Field("MySenseCustom",
                                       "LexSense",
                                       _analysisWritingSystemIds,
                                       Field.MultiplicityType.ZeroOr1,
                                       "MultiText"));
            viewTemplate.Add(new Field(Field.FieldNames.ExampleSentence.ToString(),
                                       "LexExampleSentence",
                                       vernacularWritingSystemIds));
            viewTemplate.Add(new Field(Field.FieldNames.ExampleTranslation.ToString(),
                                       "LexExampleSentence",
                                       _analysisWritingSystemIds));

            Field customField = new Field("SemanticDomains",
                                          "LexSense",
                                          _analysisWritingSystemIds,
                                          Field.MultiplicityType.ZeroOr1,
                                          "OptionCollection");
            customField.DisplayName     = "Sem Dom";
            customField.OptionsListFile = "SemanticDomains.xml";
            viewTemplate.Add(customField);

            Field customPOSField = new Field(LexSense.WellKnownProperties.PartOfSpeech,
                                             "LexSense",
                                             _analysisWritingSystemIds,
                                             Field.MultiplicityType.ZeroOr1,
                                             "Option");
            customPOSField.DisplayName     = "POS";
            customPOSField.OptionsListFile = "PartsOfSpeech.xml";
            viewTemplate.Add(customPOSField);

            Field customNotesField = new Field(PalasoDataObject.WellKnownProperties.Note,
                                               "LexSense",
                                               _analysisWritingSystemIds);
            customNotesField.DisplayName = "s-note";
            viewTemplate.Add(customNotesField);

            Field exampleNotesField = new Field(PalasoDataObject.WellKnownProperties.Note,
                                                "LexExampleSentence",
                                                _analysisWritingSystemIds);
            exampleNotesField.DisplayName = "ex-note";
            viewTemplate.Add(exampleNotesField);

            _entryViewFactory = (() => new EntryViewControl());

            DictionaryControl.Factory dictControlFactory = (memory => new DictionaryControl(_entryViewFactory, _lexEntryRepository, viewTemplate, memory, new StringLogger()));

            _task           = new DictionaryTask(dictControlFactory, DictionaryBrowseAndEditConfiguration.CreateForTests("definition"), _lexEntryRepository, new TaskMemoryRepository());   //, new UserSettingsForTask());
            _detailTaskPage = new TabPage();
            ActivateTask();

            _tabControl = new TabControl();

            _tabControl.Dock = DockStyle.Fill;
            _tabControl.TabPages.Add(_detailTaskPage);
            _tabControl.TabPages.Add(new TabPage("Dummy"));
            _window = new Form();
            _window.Controls.Add(_tabControl);
            _window.Width  = 700;
            _window.Height = 500;
            _window.Show();
        }