/// <summary> /// Mouse is double clicked in viewer. /// </summary> private void AnnotationTool_MouseDoubleClick(object sender, Vintasoft.Imaging.UI.VisualTools.VisualToolMouseEventArgs e) { if (CommentTool != null && e.Button == AnnotationTool.ActionButton) { // find annnotation view AnnotationView view = AnnotationTool.FindAnnotationView(e.X, e.Y); // if annotation contains the annotation if (view != null && view.Data.Comment != null) { // get annotation comment Comment comment = view.Data.Comment; // find comment control ICommentControl commentControl = CommentTool.FindCommentControl(comment); // if comment control is found if (commentControl != null) { if (CommentTool.SelectedComment != commentControl) { CommentTool.SelectedComment = commentControl; } // open comment comment.IsOpen = true; } } } }
/// <summary> /// 页面加载 /// </summary> /// <param name="e"></param> protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); Object[] parameters = e.Parameter as Object[]; if (parameters != null && parameters.Length == 1) { _news = parameters[0] as CnNews; BlogTitle.Text = _news.Title; NewsSource.Text = _news.SourceName; PublishTime.Text = _news.PublishTime; Diggs.Text = "[" + _news.Diggs + "]"; Views.Text = _news.Views; Comments.Text = _news.Comments; string newsContent = await NewsService.GetNewsContentAsync(_news.Id); if (newsContent != null) { //string pattern = "<img src=\"(.*)\""; //news_content = Regex.Replace(news_content, pattern, m => $"<img src=\"{_image_bridge}{m.Groups[1].Value}\""); HideScrollbar(ref newsContent); NewsContent.NavigateToString(newsContent); } // 获取评论数据 _commentsTotalHtml = CommentTool.BaseChatHtml; HideScrollbar(ref _commentsTotalHtml); NewsComment.NavigateToString(_commentsTotalHtml); List <CnNewsComment> refreshComments = await NewsService.GetNewsCommentsAysnc(_news.Id, 1, 200); if (refreshComments != null) { string comments = ""; foreach (CnNewsComment comment in refreshComments) { comments += CommentTool.Receive(comment.AuthorAvatar, comment.AuthorName, comment.Content, comment.PublishTime, comment.Id); } comments += "<a id='ok'></a>"; _commentsTotalHtml = _commentsTotalHtml.Replace("<a id='ok'></a>", "") + comments + "<a id='ok'></a>"; HideScrollbar(ref _commentsTotalHtml); NewsComment.NavigateToString(_commentsTotalHtml); Loading.IsActive = false; } Loading.IsActive = false; } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); object[] parameters = e.Parameter as object[]; if (parameters != null) { if (parameters.Length == 1 && (parameters[0] as CnBlog) != null) { _blog = parameters[0] as CnBlog; BlogTitle.Text = _blog.Title; AuthorName.Content = _blog.AuthorName; PublishTime.Text = _blog.PublishTime; Views.Text = _blog.Views; Diggs.Text = "[" + _blog.Diggs + "]"; Comments.Text = _blog.Comments; BitmapImage bi = new BitmapImage { UriSource = new Uri(_blog.AuthorAvator) }; Avatar.Source = bi; AuthorName.Tag = _blog.BlogApp; string blogBody = await BlogService.GetBlogContentAsync(_blog.Id); if (blogBody != null) { HideScrollbar(ref blogBody); BlogContent.NavigateToString(blogBody); } // 获取评论数据 _commentHtml = CommentTool.BaseChatHtml; HideScrollbar(ref _commentHtml); BlogComment.NavigateToString(_commentHtml); List <CnBlogComment> listComments = await BlogService.GetBlogCommentsAsync(_blog.Id, 1, 199); if (listComments != null) { string comments = ""; foreach (CnBlogComment comment in listComments) { comments += CommentTool.Receive(comment.AuthorAvatar, comment.AuthorName == _blog.AuthorName ? "[博主]" + _blog.AuthorName : comment.AuthorName, comment.Content, comment.PublishTime, comment.Id); } _commentHtml = _commentHtml.Replace("<a id='ok'></a>", "") + comments + "<a id='ok'></a>"; Debug.Write(_commentHtml); HideScrollbar(ref _commentHtml); BlogComment.NavigateToString(_commentHtml); } Loading.IsActive = false; } } }
/// <summary> /// Selects the comment of specified annotation view. /// </summary> /// <param name="view">The view.</param> private void SelectComment(AnnotationView view) { if (view == null) { CommentTool.SelectedComment = null; } else { if (view.Data.Comment != null) { CommentTool.SelectedComment = CommentTool.FindCommentControl(view.Data.Comment); } } }