private void UpdateSuggestions(string words) { if (string.IsNullOrWhiteSpace(words)) { Suggestions?.Clear(); return; } string[] enteredWordList = words.Split(' ', StringSplitOptions.RemoveEmptyEntries); var lastWorld = enteredWordList.LastOrDefault().Replace("\t", ""); if (lastWorld.Length < 1) { Suggestions.Clear(); return; } var suggestedWords = EnglishWords.Where(w => w.StartsWith(lastWorld)).Except(enteredWordList).Take(7); Suggestions.Clear(); foreach (var suggestion in suggestedWords) { Suggestions.Add(new SuggestionViewModel(suggestion, OnAddWord)); } }
private void OnSearchTextChangerd() { if (string.IsNullOrEmpty(Search)) { if (Suggestions != null && Suggestions.Count > 0) { Suggestions.Clear(); } _messagingService.Send <HideUnhideViewAnimationMessage>(new HideUnhideViewAnimationMessage(true)); return; } if (Search.Length < 3) { if (Suggestions != null && Suggestions.Count > 0) { Suggestions.Clear(); } HasAnySuggestions = false; return; } // Add API Stuff here. Suggestions = new ObservableCollection <Suggestion>() { new Suggestion() { Content = "French Cuisine Restaurants", TapCommand = SuggestionTapCommand, RemoveCommand = SuggestionRemoveCommand } }; HasAnySuggestions = Suggestions.Count > 0; }
async Task AzureSuggestions(string text) { Suggestions.Clear(); var parameters = new SuggestParameters() { UseFuzzyMatching = true, HighlightPreTag = "[", HighlightPostTag = "]", MinimumCoverage = 100, Top = 10 }; var suggestionResults = await indexClient.Documents.SuggestAsync <Monkey>(text, "nameSuggester", parameters); foreach (var result in suggestionResults.Results) { Suggestions.Add(new Monkey { Name = result.Text, Location = result.Document.Location, Details = result.Document.Details, ImageUrl = result.Document.ImageUrl }); } }
private void UpdateAutocomplete() { // There's an strange reason which causes TextChanged to fire indefinitely, although the text has not changed really. // To avoid this, if the text we stored is the same, just return. if (_text == _textbox.Text) { return; } _text = _textbox.Text; if (ShouldStopAutocompleting()) { IsAutocompleting = false; return; } written = GetTextWrittenByUser(); Suggestions.Clear(); foreach (var user in _provider.Usernames .Where(x => x.IndexOf(written, StringComparison.InvariantCultureIgnoreCase) != -1) .Take(20) .OrderBy(x => x)) { Suggestions.Add(user); } }
private void ClearCurrentQuery() { Query = string.Empty; SortBy.Clear(); SpatialQuery.Clear(); ClearQueryError(); Suggestions.Clear(); CollectionSource.Clear(); }
private void OnTextChanged() { Suggestions.Clear(); var text = Text.Trim(); Suggestions.AddRange( allCountries .Where(c => c.Name.ContainsIgnoringCase(text)) .Select(c => new SelectableCountryViewModel(c, c.Id == selectedCountryId)) ); }
public async Task SelectSuggestionAsync(SearchSuggestion suggestion) { // TODO FAZER A BUSCA BASEADO NO ITEM SELECIONADO System.Diagnostics.Debug.WriteLine($"Item selecionado na viewmodel: {suggestion.Description}"); Suggestions.Clear(); var resultsApi = await _api.GetSearchResults(); Results.Clear(); Results.AddRange(resultsApi.ToSearchResultListApp()); }
public void LocationAutoSuggestTextChanged() { if (this._autoSuggestionBoxText.Length > 1) { this.GetSuggestionsAsync(this._autoSuggestionBoxText); } else { Suggestions.Clear(); Suggestions.Add("No suggestions..."); } }
private void OnSuggestionTapped(Suggestion suggestion) { Search = suggestion.Content; if (Suggestions != null && Suggestions.Count > 0) { Suggestions.Clear(); } HasAnySuggestions = false; SearchRestaurantAsync(); }
private void CompleteEnding(TagViewModel tag) { Suggestions.Clear(); RefreshPopup(); tag.SetSignalization(); if (tag.Blank is Word) { var w = tag.Blank as Word; CreatedWordsManager.AfterCompleteTagWith(w); } AddLastTag(); }
private void GetSuggestionsAsync(string text) { Task t = Task.Run(async() => { locs = await HttpServiceSingleton.GetInstance.GetLocationAsync($"https://api.mapbox.com/geocoding/v5/mapbox.places/{text}.json?access_token=pk.eyJ1IjoiZGlldGVyZHMiLCJhIjoiY2tpMGRlMTVmMDBvMjMwa2JveWYwY3k3eSJ9.I9Y9bm0oMnQJyshyZTKMdQ&autocomplete=true&limit=5"); }); t.Wait(); Suggestions.Clear(); foreach (var item in locs) { Suggestions.Add(item.LocationNameLong); } }
private void onSuggestions(IEnumerable <AutocompleteSuggestion> suggestions) { var firstSuggestion = suggestions.FirstOrDefault(); IsSuggestingTags = firstSuggestion is TagSuggestion; IsSuggestingProjects = firstSuggestion is ProjectSuggestion; Suggestions.Clear(); var groupedSuggestions = groupSuggestions(suggestions).ToList(); UseGrouping = groupedSuggestions.Count > 1; Suggestions.AddRange(groupedSuggestions); }
private void AdjustTextToEndOfScopeToTheLeft(Scope newScope) { bool textChanged = false; while (newScope.EndPosInRootScope >= StartPosInRootScope) { textChanged = true; Text = Text.Substring(1); startPosInRootScope++; } if (textChanged) { Suggestions.Clear(); } }
private void fetchSuggestions(bool databaseIsEmpty) { Suggestions.Clear(); if (databaseIsEmpty) { return; } suggestionProviders .Providers .Select(provider => provider.GetSuggestions()) .Aggregate(Observable.Merge) .Subscribe(addSuggestion); }
public SearchQueryViewModel(MessageBus messageBus) { MessageBus = messageBus ?? throw new ArgumentNullException("messageBus"); MessageBus.Subscribe <ServerSettingsChangedMessage>(m => { if (m.ServiceModel == null) { QueryText = ""; StatusMessage = ""; } }); MessageBus.Subscribe <BuildSearchMessage>(m => { m.Query.QueryText = QueryText; }); MessageBus.Subscribe <BeginSearchMessage>(m => { if (m.ReturnOptions.HasFlag(ReturnOptions.Results) && !m.IsPaging) { StatusMessage = "Searching..."; IsSearching = true; } if (m.ReturnOptions.HasFlag(ReturnOptions.Suggest)) { Suggestions.Clear(); } }); MessageBus.Subscribe <EndSearchMessage>(m => { if (m.Results.ReturnOptions.HasFlag(ReturnOptions.Results) && !m.IsPaging) { StatusMessage = $"Matched {m.Results.Total,1:n0} documents and {m.Results.TotalObjects,1:n0} distinct objects."; IsSearching = false; } if (m.Results.ReturnOptions.HasFlag(ReturnOptions.Suggest)) { foreach (var suggestion in m.Results.QuerySuggestions) { Suggestions.Add(suggestion); } } }); MessageBus.Subscribe <SearchAbortedMessage>(m => { IsSearching = false; StatusMessage = "Search aborted."; }); }
private void AutoSuggestBoxTo_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) { if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) { var suggestions = new ObservableCollection <string>(Suggestions.ToList()); Suggestions.Clear(); foreach (var place in suggestions) { if (place.Contains(sender.Text)) { Suggestions.Add(place); } } sender.ItemsSource = Suggestions; } }
public void OnAddWord(string word) { string[] words = MnemonicWords.Split(' ', StringSplitOptions.RemoveEmptyEntries); if (words.Length == 0) { MnemonicWords = word + " "; } else { words[words.Length - 1] = word; MnemonicWords = string.Join(' ', words) + " "; } CaretIndex = MnemonicWords.Length; Suggestions.Clear(); }
public async Task GetPlacesByName(string placeText) { var places = await _googleMapsApi.GetPlaces(placeText); var placeResult = places?.AutoCompletePlaces; if (placeResult != null && placeResult.Count > 0) { Places = new ObservableCollection <GooglePlaceAutoCompletePrediction>(placeResult); } Suggestions?.Clear(); foreach (var place in Places) { Suggestions?.Add($"{place.StructuredFormatting.MainText} - {place.StructuredFormatting.SecondaryText}"); } }
private void SearchForPatientCandidates(string inputText) { Suggestions.Clear(); var candidates = _summaries.Select(s => new { s, IdDistance = Levenshtein.ComputeDistance(s.Id.ToUpper(), inputText.ToUpper()), LastNameDistance = Levenshtein.ComputeDistance(s.LastName.ToUpper(), inputText.ToUpper()), FullNameDistance = Levenshtein.ComputeDistance($"{s.LastName.ToUpper()}, {s.FirstName.ToUpper()}", inputText.ToUpper()), }) .Select(s => new { s.s, Distance = Math.Min(Math.Min(s.IdDistance, s.FullNameDistance), s.LastNameDistance) }) .OrderBy(s => s.Distance) .Where(s => s.Distance < 5) .OrderBy(s => s.Distance) .Take(5).ToList(); candidates.ForEach(c => Suggestions.Add(c.s)); }
private void AdjustTextToEndOfScopeToTheRight(Scope newScope) { bool textChanged = false; while (newScope.StartPosInRootScope <= EndPosInRootScope) { textChanged = true; Text = Text.Substring(0, Text.Length - 1); if (textChanged) { Suggestions.Clear(); } } if (textChanged) { Suggestions.Clear(); } }
private void onSuggestions(IEnumerable <AutocompleteSuggestion> suggestions) { var firstQuerySymbolIndex = TextFieldInfo.Text.IndexOfAny(new char[] { QuerySymbols.Tags, QuerySymbols.Projects }); if (firstQuerySymbolIndex >= 0) { var firstQuerySymbol = TextFieldInfo.Text[firstQuerySymbolIndex]; IsSuggestingTags = firstQuerySymbol == QuerySymbols.Tags; IsSuggestingProjects = !TextFieldInfo.ProjectId.HasValue && firstQuerySymbol == QuerySymbols.Projects; } else { IsSuggestingTags = IsSuggestingProjects = false; } Suggestions.Clear(); var groupedSuggestions = groupSuggestions(suggestions).ToList(); UseGrouping = groupedSuggestions.Count > 1; Suggestions.AddRange(groupedSuggestions); }
private object MakeSuggestions(TagViewModel tag) { Contract.Requires(tag != null); var tagIndex = Tags.IndexOf(tag); // все сущности кроме сущности редактируемого тега var tagBlanksExceptEditing = Tags.Select((t, i) => i != tagIndex ? t.Blank : null); var results = sugMaker.SearchForSuggesstions( query: tag.Query, prevEntityBlank: tagIndex > 0 ? Tags[tagIndex - 1].Blank : null, exclude: null); Suggestions.Clear(); foreach (var item in results) { Suggestions.Add(new SuggestionViewModel(item, ShowAltSuggestion, item.IsTransient)); } SelectedSuggestion = Suggestions.FirstOrDefault(); return(Suggestions.FirstOrDefault()); }
private void UpdateSuggestions() { if (_selectedSuggestionChanged) { return; } Suggestions.Clear(); if (QueueManagerProvided || QueueManager != null) { App.ShellService.WithGlobalBusy(() => { try { var filter = QueueManager.NewObjectNameFilter(QueueName); var provider = QueueManager.NewObjectProvider(filter); var sysFilter = QueueManager.NewSystemObjectNameFilter(); var list = provider.GetQueueNames(); foreach (var s in list) { if (!IncludeSystemQueues && sysFilter.IsMatch(s)) { continue; } Suggestions.Add(s); } } catch (MqException) { } }); } CommandManager.InvalidateRequerySuggested(); }
void SetSuggestions() { if (!IsDropDownOpen) { return; } Suggestions.Clear(); var find = SelectedText == Text ? "" : SelectedText.CoalesceNullOrEmpty(Text) ?? ""; var ucFind = Regex.Replace(find, "[^A-Z]", ""); foreach (var suggestion in SuggestionList.Where(x => HasStr(x.Text, find))) { Suggestions.Add(suggestion); } if (!Suggestions.Any()) { Suggestions.Add(null); } SuggestedIndex = find == "" ? 0 : Suggestions.Indexes(str => str?.Text.StartsWith(Text, StringComparison.InvariantCultureIgnoreCase) ?? false).FirstOrDefault(); }
/// <summary> /// Populates the <see cref="Suggestions"/> property with word suggestions /// for the <see cref="CurrentWord"/> /// </summary> /// <remarks> /// <see cref="TestWord()"/> or <see cref="TestWord(string)"/> must have been called before calling this method /// </remarks> /// <seealso cref="CurrentWord"/> /// <seealso cref="Suggestions"/> /// <seealso cref="TestWord()"/> /// <seealso cref="TestWord(string)"/> public void Suggest() { // can't generate suggestions with out current word if (CurrentWord.Length == 0) { TraceWriter.TraceWarning("No current word"); return; } Initialize(); var tempSuggestion = new List <Word>(); if ((SuggestionMode == SuggestionEnum.PhoneticNearMiss || SuggestionMode == SuggestionEnum.Phonetic) && _dictionary.PhoneticRules.Count > 0) { // generate phonetic code for possible root word Dictionary <string, string> codes = new Dictionary <string, string>(); foreach (string tempWord in _dictionary.PossibleBaseWords) { string tempCode = _dictionary.PhoneticCode(tempWord); if (tempCode.Length > 0 && !codes.ContainsKey(tempCode)) { codes.Add(tempCode, tempCode); } } if (codes.Count > 0) { // search root words for phonetic codes foreach (Word word in _dictionary.BaseWords.Values) { if (codes.ContainsKey(word.PhoneticCode)) { List <string> words = _dictionary.ExpandWord(word); // add expanded words foreach (string expandedWord in words) { SuggestWord(expandedWord, tempSuggestion); } } } } TraceWriter.TraceVerbose("Suggestions Found with Phonetic Strategy: {0}", tempSuggestion.Count); } if (SuggestionMode == SuggestionEnum.PhoneticNearMiss || SuggestionMode == SuggestionEnum.NearMiss) { // suggestions for a typical fault of spelling, that // differs with more, than 1 letter from the right form. ReplaceChars(tempSuggestion); // swap out each char one by one and try all the tryme // chars in its place to see if that makes a good word BadChar(tempSuggestion); // try omitting one char of word at a time ExtraChar(tempSuggestion); // try inserting a tryme character before every letter ForgotChar(tempSuggestion); // split the string into two pieces after every char // if both pieces are good words make them a suggestion TwoWords(tempSuggestion); // try swapping adjacent chars one by one SwapChar(tempSuggestion); } TraceWriter.TraceVerbose("Total Suggestions Found: {0}", tempSuggestion.Count); tempSuggestion.Sort(); // sorts by edit score Suggestions.Clear(); foreach (var suggestion in tempSuggestion) { string word = suggestion.Text; // looking for duplicates if (!Suggestions.Contains(word)) { // populating the suggestion list Suggestions.Add(word); } if (Suggestions.Count >= MaxSuggestions && MaxSuggestions > 0) { break; } } }
/// <summary> /// Resets the public properties /// </summary> private void Reset() { WordIndex = 0; // reset word index _replacementWord = ""; Suggestions.Clear(); }
/// <summary> /// Создает тег. /// </summary> private TagViewModel CreateTag(object content = null) { Contract.Requires(content == null || content is string || content is ConfWithHio || content is IHrItemObject); TagViewModel tag; var itemObject = content as IHrItemObject; var chio = content as ConfWithHio; var str = content as string; if (itemObject != null) { tag = new TagViewModel(this, itemObject); } else if (chio != null) { tag = new TagViewModel(this, chio.HIO); tag.Confidence = chio.Confidence; } else if (str != null) { tag = new TagViewModel(this, str); } else { tag = new TagViewModel(this); } tag.Deleted += (s, e) => { Contract.Requires(!tag.IsLast); tagsWritable.Remove(tag); StartEdit(LastTag); }; tag.Converting += CompleteOnConvert; tag.PropertyChanged += (s, e) => { if (e.PropertyName == "Query") { if (EditingTag == null) // non user change { return; } MakeSuggestions(EditingTag); RefreshPopup(); OnPropertyChanged(() => IsEmpty); } else if (e.PropertyName == "IsTextBoxFocused") { if (tag.IsTextBoxFocused) { if (tag.Signalization == null || tag.Signalization == Signalizations.None) { Suggestions.Clear(); } else { MakeSuggestions(SelectedTag); // предположения для тегов с сигнализацией } CanCompleteOnLostFocus = true; SelectedTags.Except(tag.ToEnumerable()).ForAll(t => t.IsSelected = false); SelectedTag = tag; } else { // выход из редактирования Suggestions.Clear(); // потерялся фокус после перехода не в предположения → завершение введенного текста if (CanCompleteOnLostFocus) { CompleteOnLostFocus(tag); } } RefreshPopup(); } else if (e.PropertyName == "State") { if (tag.State == State.Completed) { OnTagCompleted(tag); OnEntitiesChanged(); } } }; return(tag); }
private void ShowSuggestions(IList <SearchSuggestion> suggestions) { Suggestions.Clear(); Suggestions.AddRange(suggestions); }