Esempio n. 1
0
 private void AddHistoryItems()
 {
     HintItems.Add(new AutoHintItem {
         Word = "---------历史记录---------", IsEnable = false
     });
     if (Settings?.HistoryKeywords?.Count > 0)
     {
         foreach (var kitem in Settings.HistoryKeywords)
         {
             HintItems.Add(kitem);
         }
     }
 }
Esempio n. 2
0
        public async Task ShowKeywordComboBoxItemsAsync(string keyword, CancellationToken token)
        {
            try
            {
                HintItems.Clear();
                AddHistoryItems();
                await Task.Delay(600, token); // 等待0.6再开始获取,避免每输入一个字都进行网络操作

                if (string.IsNullOrWhiteSpace(keyword))
                {
                    throw new Exception("keyword is empty");
                }
                // 开始搜索
                var list = await CurrentSelectedSite.GetAutoHintItemsAsync(GetSearchPara(), token);

                if (list.Count > 0)
                {
                    HintItems.Clear();
                    foreach (var item in list)
                    {
                        HintItems.Add(item);
                    }
                    AddHistoryItems();
                }
                App.Log($"AutoPredict 搜索完成 结果个数{list.Count}");
            }
            catch (TaskCanceledException) // 任务取消
            {
                return;
            }
            catch (Exception e)
            {
                App.Log(e.Message);
            }

            this.Sb("SearchingSpinSb").Stop();
            CurrentTaskCts = null;
        }