private void LanguageToPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     Dictionary.Language newValue = e.NewValue as Dictionary.Language;
     if (newValue != null)
     {
         image1.Source = GetSourceByLanguage(newValue);
     }
 }
 private ImageSource GetSourceByLanguage(Dictionary.Language language)
 {
     if (!_flags.ContainsKey(language))
     {
         var source = new BitmapImage(new Uri("ms-appx:///Assets/Flags/" + language.Abbreviation + ".png"));
         _flags.Add(language, source);
     }
     return(_flags[language]);
 }
Пример #3
0
        private void SwitchDirection()
        {
            if (_canSwitchDirection)
            {
                Dictionary.Language languageFrom = LanguageFrom;
                LanguageFrom = LanguageTo;
                LanguageTo   = languageFrom;

                if (!string.IsNullOrEmpty(SearchQuery))
                {
                    StartSearch();
                }
            }
        }
Пример #4
0
        public List <string> GetAllWordForms(string query)
        {
            lock (_locker)
            {
                Dictionary.Language language = _dictionary.RecognizeLanguage(query);
                if (language == null)
                {
                    language = LanguageFrom;
                }

                List <string> result = new List <string>();

                string[] words = query.Split(' ');
                foreach (string word in words)
                {
                    result.AddRange(_dictionary.GetAllWordForms(word, language));
                }

                return(result);
            }
        }