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()); }
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(); }
private void SetupEntryViewControl(EntryViewControl.Factory factory) { this._entryViewControl = factory(); this.panelDetail.Controls.Add(this._entryViewControl); this._entryViewControl.Dock = System.Windows.Forms.DockStyle.Fill; this._entryViewControl.Name = "_entryViewControl"; this._entryViewControl.ShowNormallyHiddenFields = false; this._entryViewControl.TabIndex = 0; //TODO: remove these, move to ctor Control_EntryDetailPanel.ViewTemplate = _viewTemplate; Control_EntryDetailPanel.LexEntryRepository = _lexEntryRepository; _entryViewControl.SenseDeletionEnabled = true; }
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(); }