Ejemplo n.º 1
0
 bool HasAnyUnsupportKey(string key)
 {
     if (RawEngines.Any(s => s.Disabled || s.SupportUnicode))
     {
         return(false);
     }
     return(EngineUtility.IsUnicodeKey(key));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 开始加载更多
        /// </summary>
        void BeginLoadMore()
        {
            pWarning.Visible = HasAnyUnsupportKey(_currentKeyWord);
            if (pWarning.Visible)
            {
                return;
            }

            if (Engines.Any(s => !s.Provider.Disabled && s.IsBusy))
            {
                if (!this.Question("当前正在搜索,需要取消当前搜索并重新搜索吗?", true))
                {
                    return;
                }

                Engines.Where(s => !s.Provider.Disabled).ForEach(s =>
                {
                    if (s.IsBusy)
                    {
                        s.Cancel();
                    }
                });
            }

            lblSearchProgress.Text      = "准备搜索...";
            lblSearchProgress.ForeColor = Color.Green;

            //初始化各参数
            _maxSearchPage = Engines.Where(s => !s.Provider.Disabled).Max(s => s.CurrentLoadedPage) + AppContext.Instance.Options.LoadPages;
            var isUnicodeKey = EngineUtility.IsUnicodeKey(_currentKeyWord);

            foreach (var engine in Engines)
            {
                if (engine.Provider.Disabled || (engine.CurrentLoadedPage > 0 && !engine.HasMore) || (!engine.Provider.SupportUnicode && isUnicodeKey))
                {
                    continue;
                }

                engine.SearchKey = _currentKeyWord;
                engine.CurrentLoadedPage++;
                engine.SearchedCount = 1;
                engine.ErrorCount    = 0;
                if (engine.CurrentLoadedPage > _maxSearchPage)
                {
                    continue;
                }
                Interlocked.Increment(ref _currentWorkingClients);
                _currentSearchedPage++;
                engine.DoSearch();
                RefreshSearchStatus();
            }
            RefreshSearchStatus();
            if (_currentWorkingClients == 0)
            {
                ResourceOperation.MainForm.ShowFloatTip("没有更多可搜索的资源 :-(");
            }
        }