コード例 #1
0
 public void FindAllWords(string name, int top)
 {
     if (_isthreecc == 1)
     {
         ObservableCollection <Word> list = (Application.Current as App).ThreeCCDB.SelectObservableCollection <Word>(string.Format("select Name,Description_EN,Description_CN,Detail_EN,Detail_CN from ThreeCharClassic where Name like '{0}%' ", name));
         if (list == null || list.Count == 0)
         {
             AllWordsFound(null);
         }
         else
         {
             int count = Math.Min(list.Count, top);
             ObservableCollection <Word> retlist = new ObservableCollection <Word>();
             for (int ix = 0; ix < count; ix++)
             {
                 retlist.Add(list[ix]);
             }
             AllWordsFound(retlist);
         }
     }
     else
     {
         ObservableCollection <Word> list = (Application.Current as App).GlossaryDB.SelectObservableCollection <Word>(string.Format("select Name from SAPDictionary where Name like '{0}%' and Language='{1}' ", name, _lang));
         if (list == null || list.Count == 0)
         {
             if (!EnableRemote)
             {
                 if (AllWordsFound != null)
                 {
                     AllWordsFound(null);
                 }
             }
             else
             {
                 SAPDictionaryService.SAPDictionarySoapClient client = new SAPDictionaryService.SAPDictionarySoapClient();
                 client.FindAllWordsAsync(name, _lang, top);
                 client.FindAllWordsCompleted += new System.EventHandler <SAPDictionaryService.FindAllWordsCompletedEventArgs>(client_FindAllWordsCompleted);
             }
         }
         else
         {
             int count = Math.Min(list.Count, top);
             ObservableCollection <Word> retlist = new ObservableCollection <Word>();
             for (int ix = 0; ix < count; ix++)
             {
                 retlist.Add(list[ix]);
             }
             AllWordsFound(retlist);
         }
     }
 }