private void UpdateInlineBot(bool fast) { //var text = Text.Substring(0, Math.Max(Document.Selection.StartPosition, Document.Selection.EndPosition)); var text = Text; var query = string.Empty; var inline = SearchInlineBotResults(text, out query); if (inline && fast) { ViewModel.GetInlineBotResults(query); } else if (!inline) { ViewModel.CurrentInlineBot = null; ViewModel.InlineBotResults = null; InlinePlaceholderText = string.Empty; if (fast) { if (text.Trim().Length <= 14 && !string.IsNullOrWhiteSpace(text) && ViewModel.EditedMessage == null) { ViewModel.StickerPack = ViewModel.Stickers.StickersService.LoadStickersForEmoji(text.Trim()); } else { ViewModel.StickerPack = null; } } else { ViewModel.StickerPack = null; if (SearchByUsername(text.Substring(0, Math.Min(Document.Selection.EndPosition, text.Length)), out string username)) { ViewModel.Autocomplete = GetUsernames(username.ToLower(), text.StartsWith('@' + username)); } else if (SearchByEmoji(text.Substring(0, Math.Min(Document.Selection.EndPosition, text.Length)), out string replacement) && replacement.Length > 0 && ApplicationSettings.Current.IsReplaceEmojiEnabled) { ViewModel.Autocomplete = EmojiSuggestion.GetSuggestions(replacement); } else if (text.Length > 0 && text[0] == '/' && SearchByCommand(text, out string command)) { ViewModel.Autocomplete = GetCommands(command.ToLower()); } else { ViewModel.Autocomplete = null; } } } }
private void OnSelectionChanged(object sender, RoutedEventArgs e) { var text = Text.ToString(); if (BubbleTextBox.SearchByUsername(text.Substring(0, Math.Min(SelectionStart, text.Length)), out string username)) { View.Autocomplete = GetUsernames(username); } else if (BubbleTextBox.SearchByEmoji(text.Substring(0, Math.Min(SelectionStart, text.Length)), out string replacement) && replacement.Length > 0 && ApplicationSettings.Current.IsReplaceEmojiEnabled) { View.Autocomplete = EmojiSuggestion.GetSuggestions(replacement); } else { View.Autocomplete = null; } }