Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        protected Control MakeOptionWidget(PalasoDataObject target, Field field)
        {
            OptionRef   optionRefTarget = target.GetOrCreateProperty <OptionRef>(field.FieldName);
            OptionsList list            = WeSayWordsProject.Project.GetOptionsList(field, false);
            IWritingSystemDefinition preferredWritingSystem = _viewTemplate.GetDefaultWritingSystemForField(field.FieldName);
            SingleOptionControl      control = new SingleOptionControl(optionRefTarget,
                                                                       list,
                                                                       field.FieldName,
                                                                       preferredWritingSystem,
                                                                       WeSayWordsProject.Project.ServiceLocator);
            SimpleBinding <string> binding = new SimpleBinding <string>(optionRefTarget, control);

            binding.CurrentItemChanged += _detailList.OnBinding_ChangeOfWhichItemIsInFocus;
            return(control);
        }
Ejemplo n.º 4
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());
        }
Ejemplo n.º 5
0
        private void SetupTestData()
        {
            Palaso.Reporting.ErrorReport.IsOkToInteractWithUser = false;
            _tempFolder = new TemporaryFolder();
            _filePath   = _tempFolder.GetTemporaryFile();

            _currentItem = null;
            string lexicalForm        = "test";
            string definition         = "definition";
            string exampleSentence    = "Test sentence";
            string exampleTranslation = "Translated sentence";

            _lexEntryRepository = (LexEntryRepository)
                                  WeSayWordsProject.Project.ServiceLocator.GetService(typeof(LexEntryRepository));
            _viewTemplate = (ViewTemplate)
                            WeSayWordsProject.Project.ServiceLocator.GetService(typeof(ViewTemplate));

            List <String> headwordWritingSystemIds = new List <string>(_viewTemplate.GetHeadwordWritingSystemIds());
            string        wsA = headwordWritingSystemIds[0];
            string        wsB = _viewTemplate.GetDefaultWritingSystemForField(definition).Id;

            HtmlRenderer.HeadWordWritingSystemId = _viewTemplate.HeadwordWritingSystem.Id;

            _entry = _lexEntryRepository.CreateItem();
            _entry.LexicalForm[wsA] = lexicalForm;
            LexSense sense = new LexSense();

            sense.Definition[wsB] = definition;
            LexExampleSentence example = new LexExampleSentence();

            example.Sentence[wsA]    = exampleSentence;
            example.Translation[wsB] = exampleTranslation;
            sense.ExampleSentences.Add(example);
            _entry.Senses.Add(sense);
            empty        = CreateTestEntry("", "", "");
            apple        = CreateTestEntry("apple", "red thing", "An apple a day keeps the doctor away.");
            anotherApple = CreateTestEntry("apple", "fruit", "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.");
        }
Ejemplo n.º 6
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();
		}
Ejemplo n.º 7
0
        private LexEntry CreateTestEntry(string lexicalForm, string meaning, string exampleSentence)
        {
            List <String> headwordWritingSystemIds = new List <string>(_viewTemplate.GetHeadwordWritingSystemIds());
            string        wsA   = headwordWritingSystemIds[0];
            string        wsB   = _viewTemplate.GetDefaultWritingSystemForField("definition").Id;
            LexEntry      entry = _lexEntryRepository.CreateItem();

            entry.LexicalForm[wsA] = lexicalForm;
            LexSense sense = new LexSense();

#if GlossMeaning
            sense.Gloss[GetSomeValidWsIdForField("SenseGloss")] = meaning;
#else
            sense.Definition[wsB] = meaning;
#endif
            LexExampleSentence example = new LexExampleSentence();
            example.Sentence[wsA] = exampleSentence;
            sense.ExampleSentences.Add(example);
            entry.Senses.Add(sense);
            _lexEntryRepository.SaveItem(entry);
            return(entry);
        }