Beispiel #1
0
        public async Task<List<TagCategoryEntity>> GetTagList(long forumId)
        {
            var tagList = new List<TagEntity>();

            //inject this
            var doc = (await _webManager.DownloadHtml(string.Format(Constants.NEW_THREAD, forumId))).Document;

            var icons = doc.DocumentNode.Descendants("div").Where(node => node.GetAttributeValue("class", string.Empty).Equals("posticon"));

            foreach(var icon in icons)
            {
                var tag = new TagEntity();
                tag.Parse(icon);
                tagList.Add(tag);
            }
            var tagCategoryList = new List<TagCategoryEntity>();
            var tagCategory = new TagCategoryEntity("Tags", tagList);
            tagCategoryList.Add(tagCategory);
            return tagCategoryList;
        }
        private void itemGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            object item = e.ClickedItem;

            if (item.GetType() == typeof (TagEntity))
            {
                _selectedTag = (TagEntity) e.ClickedItem;
                var imgSource = new BitmapImage();
                imgSource.UriSource = new Uri(_selectedTag.ImageUrl, UriKind.Absolute);
                TagImage.Source = imgSource;
            }

            if (item.GetType() == typeof (SmileEntity))
            {
                var smile = (SmileEntity) e.ClickedItem;
                ReplyText.Text = ReplyText.Text.Insert(ReplyText.SelectionStart, smile.Title);
            }

            if (item.GetType() == typeof (BBCodeEntity))
            {
                var bbcode = (BBCodeEntity) e.ClickedItem;
                if (!string.IsNullOrEmpty(ReplyText.SelectedText))
                {
                    string selectedText = "[{0}]" + ReplyText.SelectedText + "[/{0}]";
                    ReplyText.SelectedText = string.Format(selectedText, bbcode.Code);
                }
                else
                {
                    string text = string.Format("[{0}][/{0}]", bbcode.Code);
                    string replyText = string.IsNullOrEmpty(ReplyText.Text) ? string.Empty : ReplyText.Text;
                    ReplyText.Text = replyText.Insert(ReplyText.SelectionStart, text);
                }
            }
        }