Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
        public PostStatusBase GetPostStatus()
        {
            PostStatusBase postStatus = null;

            if (IsAcceptMedia == false && IsAcceptReply == false)
            {
                postStatus = new PostStatus(PostText);
            }
            else if (IsAcceptMedia == false && IsAcceptReply == true)
            {
                if (PostText.Contains("@"))
                {
                    postStatus = new PostStatusWithReply(PostText, InReplyToStatus.id_str);
                }
                else
                {
                    postStatus = new PostStatus(PostText);
                }
            }
            else if (IsAcceptMedia == true && IsAcceptReply == false)
            {
                postStatus = new PostStatusMedia(PostText, PostMedia);
            }
            else if (IsAcceptMedia == true && IsAcceptReply == true)
            {
                if (PostText.Contains("@"))
                {
                    postStatus = new PostStatusMediaWithReply(PostText, PostMedia, InReplyToStatus.id_str);
                }
                else
                {
                    postStatus = new PostStatusMedia(PostText, PostMedia);
                }
            }
            return(postStatus);
        }