Beispiel #1
0
        public async override Task <DictionaryQueryModel> GetDictionaryQueryModelAsync(string word)
        {
            var str = await ParentExtension.InvokeAndGetJSON(word, LanguageHelper.ConvertToLangCode(SourceLanguage), LanguageHelper.ConvertToLangCode(TargetLanguage));

            var preresult = Json.Deserialize <DictionaryQueryModelFromExtension>(str);
            DictionaryQueryModel result = new DictionaryQueryModel()
            {
                QueryWord      = preresult.QueryWord,
                SourceLanguage = preresult.SourceLanguage,
                TargetLanguage = preresult.TargetLanguage,
                QueryStatus    = preresult.QueryStatus,
                Result         = GetWordModel(preresult.Result),
                ResultStatus   = ResultStatus.Succuss
            };

            return(ResultModel = result);
        }
        public static void QueryFromCompactOverlayView(string _queryword)
        {
            _queryword = DictionaryService.HandleQueryWord(_queryword);//处理、裁剪要查询的单词
            Language lang;

            if (AdjustLanguage(_queryword, out lang))
            {
                CompactOverlay_HomePageViewModel.Current.UpdateViewModel(_queryword, QueryWord(_queryword), LanguageHelper.ConvertToLangCode(CurrentSourceLanguage), LanguageHelper.ConvertToLangCode(CurrentTargetLanguage));//前台更新,加载所有词典的UI
            }
            else
            {
                QueryWord(_queryword, lang);
            }
        }
        public static void QueryFromHistory(WordHistoryModel historyViewModel)
        {
            var _queryword = historyViewModel.Word;

            CurrentSourceLanguage = (Language)historyViewModel.SourceLanguage;
            CurrentTargetLanguage = (Language)historyViewModel.TargetLanguage;
            DefinationPageViewModel.Current.UpdateViewModel(_queryword, QueryWord(_queryword), LanguageHelper.ConvertToLangCode(CurrentSourceLanguage), LanguageHelper.ConvertToLangCode(CurrentTargetLanguage));//前台更新,加载所有词典的UI
            HomePageViewModel.Current.SearchUIState = SearchUIState.Searched;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="_queryword">待查询的单词 Word which is going to be queried</param>
        /// <param name="languageIndicatorIndex">语言指示器的当前索引 Current Index of the Language Indicator</param>
        public static void QueryFromAutoSuggestBox(string _queryword)
        {
            _queryword = DictionaryService.HandleQueryWord(_queryword);//处理、裁剪要查询的单词
            Language lang;

            if (AdjustLanguage(_queryword, out lang))
            {
                DefinationPageViewModel.Current.UpdateViewModel(_queryword, QueryWord(_queryword), LanguageHelper.ConvertToLangCode(CurrentSourceLanguage), LanguageHelper.ConvertToLangCode(CurrentTargetLanguage));//前台更新,加载所有词典的UI
            }
            else
            {
                DefinationPageViewModel.Current.UpdateViewModel(_queryword, QueryWord(_queryword, lang), LanguageHelper.ConvertToLangCode(CurrentSourceLanguage), LanguageHelper.ConvertToLangCode(CurrentTargetLanguage));//前台更新,加载所有词典的UI
            }
            HomePageViewModel.Current.SearchUIState = SearchUIState.Searched;
            WordHistoryModel _wordhistoryitem = new WordHistoryModel()
            {
                Word           = DefinationPageViewModel.Current.Word,
                SourceLanguage = (int)CurrentSourceLanguage,
                TargetLanguage = (int)CurrentTargetLanguage
            };

            SearchSuggestionPageViewModel.Current.Add_WordHistory(_wordhistoryitem);
        }