예제 #1
0
        void AddNewWord()
        {
            if ((OriginalWordText != null && OriginalWordText != "") &&
                (TranslationWordText != null && TranslationWordText != "") &&
                (SelectedOriginalLanguage != null && SelectedTranslationLanguage != null))
            {
                dataAccess.AddEntity(new Translation());
                Translation translation = dataAccess.GetTranslations().Last();

                dataAccess.AddEntity(new Word {
                    Text = OriginalWordText, LanguageId = SelectedOriginalLanguage.Id, TranslationId = translation.Id
                });
                dataAccess.AddEntity(new Description {
                    Text = OriginalWordDescription, WordId = dataAccess.GetWords().Last().Id
                });
                dataAccess.AddEntity(new Word {
                    Text = TranslationWordText, LanguageId = SelectedTranslationLanguage.Id, TranslationId = translation.Id
                });
                dataAccess.AddEntity(new Description {
                    Text = TranslationWordDescription, WordId = dataAccess.GetWords().Last().Id
                });
                OriginalWordText           = "";
                TranslationWordText        = "";
                OriginalWordDescription    = "";
                TranslationWordDescription = "";
            }
            else if (OriginalWordText == "" || OriginalWordText == null)
            {
                MessageBox.Show("You must enter original word", "Enter warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            else if (TranslationWordText == "" || TranslationWordText == null)
            {
                MessageBox.Show("You mus enter translation word", "Enter warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
예제 #2
0
 protected override void InitializeFields()
 {
     tradicIterator    = TradicIterator.GetInstance();
     Words             = new ObservableCollection <Word>(tradicIterator.GetWords());
     Descriptions      = new ObservableCollection <Description>(tradicIterator.GetDescriptions());
     OriginalLanguages = new ObservableCollection <Language>(tradicIterator.GetLanguages());
 }
예제 #3
0
        void RemoveTranslation()
        {
            if (SelectedTranslationWord != null)
            {
                if (tradicIterator.GetWords().Where(w => w.TranslationId == SelectedTranslationWord.TranslationId).Count() > 1)
                {
                    tradicIterator.RemoveEntity(SelectedTranslationWord);
                }
                else
                {
                    tradicIterator.RemoveEntity(SelectedTranslationWord);
                    tradicIterator.RemoveEntity(tradicIterator.GetTranslations().Where(t => t.Id == SelectedTranslationWord.TranslationId).Last());
                }
                Descriptions.Remove(Descriptions.First(d => d.WordId == SelectedTranslationWord.Id));

                Words.Remove(Words.First(w => w.Id == SelectedTranslationWord.Id));
                TranslationWords.Remove(SelectedTranslationWord);
            }
            else
            {
                MessageBox.Show("You must select translation", "Selection warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
예제 #4
0
 private void SortAllWords()
 {
     allWords = entitiesIterator.GetWords().OrderBy(w => w, new WordsComparer());
 }