コード例 #1
0
ファイル: RelationController.cs プロジェクト: sillsdev/wesay
 private static IEnumerable FindClosestAndNextClosestAndPrefixedPairStringLexEntryForms(
     string text, IEnumerable items, IDisplayStringAdaptor adaptor)
 {
     return(ApproximateMatcher.FindClosestForms <object>(items,
                                                         adaptor.GetDisplayLabel,
                                                         text,
                                                         ApproximateMatcherOptions.
                                                         IncludePrefixedAndNextClosestForms));
 }
コード例 #2
0
 private static IEnumerable FindClosestAndNextClosestAndPrefixedForms(string text,
                                                                      IEnumerable items,
                                                                      IDisplayStringAdaptor
                                                                      adaptor)
 {
     return(ApproximateMatcher.FindClosestForms(items,
                                                text,
                                                ApproximateMatcherOptions.IncludePrefixedAndNextClosestForms));
 }
コード例 #3
0
        private static IEnumerable FilterList(string text,
                                              IEnumerable items,
                                              IDisplayStringAdaptor adaptor)
        {
            ICollection <object> newList = new Collection <object>();

            foreach (object item in items)
            {
                string label = adaptor.GetDisplayLabel(item);
                if (label.ToLower().StartsWith(text.ToLower()))
                {
                    newList.Add(item);
                    break;
                }
            }
            return(newList);
        }
コード例 #4
0
ファイル: DictionaryControl.cs プロジェクト: bbriggs/wesay
		private static IEnumerable FindClosestAndNextClosestAndPrefixedForms(string text,
																			 IEnumerable items,
																			 IDisplayStringAdaptor
																					 adaptor)
		{
			return ApproximateMatcher.FindClosestForms(items,
													   text,
													   ApproximateMatcherOptions.IncludePrefixedAndNextClosestForms);
		}
コード例 #5
0
ファイル: AutoCompleteTextBox.cs プロジェクト: bbriggs/wesay
		private static IEnumerable FilterList(string text,
											  IEnumerable items,
											  IDisplayStringAdaptor adaptor)
		{
			ICollection<object> newList = new Collection<object>();

			foreach (object item in items)
			{
				string label = adaptor.GetDisplayLabel(item);
				if (label.ToLower().StartsWith(text.ToLower()))
				{
					newList.Add(item);
					break;
				}
			}
			return newList;
		}
コード例 #6
0
 public OptionDisplayAdaptor(OptionsList allOptions, string preferredWritingSystemId)
 {
     _allOptions = allOptions;
     _preferredWritingSystemId = preferredWritingSystemId;
     _toolTipAdaptor           = null;
 }
コード例 #7
0
        public IEnumerable GetItemsToOffer(string text,
                                           IEnumerable items,
                                           IDisplayStringAdaptor adaptor)
        {
            List <Option> show = new List <Option>();

#if !DEBUG
            try
            {
#endif
            //enhance: make that text safe for regex. for now, we just swallow the exception
            string pattern             = @"(^|[^\w])(" + text + @")[^\w]";
            Regex MatchWholeWordNoCase = new Regex(pattern,
                                                   RegexOptions.IgnoreCase | RegexOptions.Compiled);

            foreach (Option option in _allOptions.Options)
            {
                //todo: make this prefferd script(s) savvy
                if (option.Name.GetFirstAlternative().StartsWith(text,
                                                                 StringComparison.
                                                                 CurrentCultureIgnoreCase))
                {
                    show.Add(option);
                }
            }
            foreach (Option option in _allOptions.Options)
            {
                //todo: make this prefferd script(s) savvy
                if (option.Abbreviation.GetFirstAlternative().StartsWith(text, StringComparison.CurrentCultureIgnoreCase))
                {
                    if (!show.Contains(option))
                    {
                        show.Add(option);
                    }
                }
            }

            //this grabs up the DDP examples
            foreach (Option option in _allOptions.Options)
            {
                if (option.GetSearchKeys(_preferredWritingSystemId).Contains(text.ToLower()))
                {
                    if (!show.Contains(option))
                    {
                        show.Add(option);
                    }
                }
            }

            //  if(show.Count == 0)
            {
                foreach (Option option in _allOptions.Options)
                {
                    //todo: make this prefferd script(s) savvy
                    if (MatchWholeWordNoCase.IsMatch(option.Description.GetFirstAlternative()))
                    {
                        if (!show.Contains(option))
                        {
                            show.Add(option);
                        }
                    }
                }
            }
#if !DEBUG
        }

        catch (Exception /*e*/)
        {
            //not worth crashing over some regex problem
        }
#endif
            return(show);
        }