示例#1
0
        private async void ChangeSuggestList()
        {
            if (!(PostText.Contains("@") || PostText.Contains("#")))
            {
                return;
            }
            ObservableCollection <string> resultSuggest = new ObservableCollection <string>();
            await Task.Run(() =>
            {
                int mIndex = PostText.LastIndexOf('@');
                int hIndex = PostText.LastIndexOf('#');

                if (mIndex > hIndex)
                {
                    var s       = PostText.Split('@');
                    string name = s[s.Count() - 1];

                    int i = 0;
                    foreach (var n in MentionSuggestSourceList.Where(q => q.StartsWith(name)).Select(q => q))
                    {
                        resultSuggest.Add("@" + n);
                        if (i > 10)
                        {
                            break;
                        }
                        i++;
                    }
                }
                else if (mIndex < hIndex)
                {
                    var s       = PostText.Split('#');
                    string name = s[s.Count() - 1];
                    int i       = 0;
                    foreach (var n in HashSuggestSourceList.Where(q => q.StartsWith(name)).Select(q => q))
                    {
                        resultSuggest.Add("#" + n);
                        if (i > 10)
                        {
                            break;
                        }
                        i++;
                    }
                }
            });

            SuggestList.Clear();
            foreach (var r in resultSuggest)
            {
                SuggestList.Add(r);
            }
        }