예제 #1
0
        /// <summary>
        /// 刷新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void RefreshButton_Click(object sender, RoutedEventArgs e)
        {
            _totalHtml = ChatBoxTool.BaseChatHtml;
            if (App.Theme == ApplicationTheme.Dark)
            {
                _totalHtml += "<style>body{background-color:black;color:white;}</style>";
            }
            List <CNMessageItem> refresh_items = await UserService.GetMessageItems(_msg_id);

            if (refresh_items != null)
            {
                string msgs = "";
                foreach (CNMessageItem item in refresh_items)
                {
                    if (item.Send)  //自己发的
                    {
                        msgs += ChatBoxTool.Send(item.AuthorAvatar, item.AuthorName, item.Content, item.Time);
                    }
                    else //别人发的
                    {
                        msgs += ChatBoxTool.Receive(item.AuthorAvatar, item.AuthorName, item.Content, item.Time);
                    }
                }
                //msgs += "<a id='ok'></a>";
                _totalHtml = _totalHtml.Replace("<a id='ok'></a>", "") + msgs + "<a id='ok'></a>";

                MsgContent.NavigateToString(_totalHtml);
                Loading.IsActive = false;
            }
        }
예제 #2
0
        /// <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;

                NewsTitle.Text = _news.Title;
                NewsInfo.Text  = _news.SourceName + " " + _news.PublishTime;

                _totalHtml = ChatBoxTool.BaseChatHtml;
                if (App.Theme == ApplicationTheme.Dark)
                {
                    _totalHtml += "<style>body{background-color:black;color:white;}</style>";
                }
                NewsComment.NavigateToString(_totalHtml);

                List <CNNewsComment> refresh_comments = await NewsService.GetNewsCommentsAysnc(_news.ID, 1, 200);

                if (refresh_comments != null)
                {
                    string comments = "";
                    foreach (CNNewsComment comment in refresh_comments)
                    {
                        if ((App.LoginedUser != null) && (App.LoginedUser.Name == comment.AuthorName))
                        {
                            comments += ChatBoxTool.Send(comment.AuthorAvatar,
                                                         comment.AuthorName, comment.Content, comment.PublishTime);
                        }
                        else
                        {
                            comments += ChatBoxTool.Receive(comment.AuthorAvatar,
                                                            comment.AuthorName,
                                                            comment.Content, comment.PublishTime, comment.ID);
                        }
                    }
                    comments += "<a id='ok'></a>";

                    _totalHtml = _totalHtml.Replace("<a id='ok'></a>", "") + comments + "<a id='ok'></a>";

                    NewsComment.NavigateToString(_totalHtml);
                    Loading.IsActive = false;
                }
            }
        }
예제 #3
0
        /// <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)
            {
                _blog           = parameters[0] as CNBlog;
                BlogTitle.Text  = _blog.Title;
                Author.Content  = _blog.AuthorName;
                PubishTime.Text = _blog.PublishTime;

                _totalHtml = ChatBoxTool.BaseChatHtml;
                if (App.Theme == ApplicationTheme.Dark)
                {
                    _totalHtml += "<style>body{background-color:black;color:white;}</style>";
                }
                BlogComment.NavigateToString(_totalHtml);
                List <CNBlogComment> list_comments = await BlogService.GetBlogCommentsAsync(_blog.ID, 1, 199);

                if (list_comments != null)
                {
                    string comments = "";
                    foreach (CNBlogComment comment in list_comments)
                    {
                        if ((App.LoginedUser != null) && (comment.AuthorName == App.LoginedUser.Name))
                        {
                            comments += ChatBoxTool.Send(comment.AuthorAvatar,
                                                         comment.AuthorName == _blog.AuthorName ? "[博主]" + _blog.AuthorName : comment.AuthorName,
                                                         comment.Content, comment.PublishTime);
                        }
                        else
                        {
                            comments += ChatBoxTool.Receive(comment.AuthorAvatar,
                                                            comment.AuthorName == _blog.AuthorName ? "[博主]" + _blog.AuthorName : comment.AuthorName,
                                                            comment.Content, comment.PublishTime, comment.ID);
                        }
                    }
                    //comments += "<a id='ok'></a>";

                    _totalHtml = _totalHtml.Replace("<a id='ok'></a>", "") + comments + "<a id='ok'></a>";
                    BlogComment.NavigateToString(_totalHtml);
                    Loading.IsActive = false;
                }
            }
        }
예제 #4
0
        /// <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)
            {
                if (parameters.Length == 2 && !(bool)parameters[1])  //消息ID  页面显示方式
                {
                    Back.Visibility = Visibility.Collapsed;
                }
                _msg_id    = parameters[0].ToString();
                _totalHtml = ChatBoxTool.BaseChatHtml;
                if (App.Theme == ApplicationTheme.Dark)
                {
                    _totalHtml += "<style>body{background-color:black;color:white;}</style>";
                }
                List <CNMessageItem> refresh_items = await UserService.GetMessageItems(_msg_id);

                if (refresh_items != null)
                {
                    string msgs = "";
                    foreach (CNMessageItem item in refresh_items)
                    {
                        if (item.Send)  //自己发的
                        {
                            msgs += ChatBoxTool.Send(item.AuthorAvatar, item.AuthorName, item.Content, item.Time);
                        }
                        else //别人发的
                        {
                            msgs += ChatBoxTool.Receive(item.AuthorAvatar, item.AuthorName, item.Content, item.Time);
                        }
                    }
                    //msgs += "<a id='ok'></a>";
                    _totalHtml = _totalHtml.Replace("<a id='ok'></a>", "") + msgs + "<a id='ok'></a>";

                    MsgContent.NavigateToString(_totalHtml);
                    Loading.IsActive = false;
                }
            }
        }
예제 #5
0
        /// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="e"></param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            object[] parameters = e.Parameter as object[];
            if (parameters != null)
            {
                if (parameters.Length == 2 && !(bool)parameters[1])
                {
                    Back.Visibility = Visibility.Collapsed;
                }
                _totalHtml = ChatBoxTool.BaseChatHtml;

                //默认加载两条记录
                string receive = ChatBoxTool.Receive("http://pic.cnblogs.com/avatar/104032/20150821151916.png", "周建芝", "hello world,it's time to leave", "10:02");
                string send    = ChatBoxTool.Send("http://pic.cnblogs.com/avatar/624159/20150505133758.png", "青柠檬", "以德服人", "11:32");

                _totalHtml = _totalHtml + receive + send + "<a id='ok'></a>";


                FlashComment.NavigateToString(_totalHtml);
            }
        }
예제 #6
0
        /// <summary>
        /// 刷新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void RefreshButton_Click(object sender, RoutedEventArgs e)
        {
            _totalHtml = ChatBoxTool.BaseChatHtml;
            if (App.Theme == ApplicationTheme.Dark)
            {
                _totalHtml += "<style>body{background-color:black;color:white;}</style>";
            }
            BlogComment.NavigateToString(_totalHtml);
            Loading.IsActive = true;
            List <CNBlogComment> list_comments = await BlogService.GetBlogCommentsAsync(_blog.ID, 1, 199);

            if (list_comments != null)
            {
                string comments = "";
                foreach (CNBlogComment comment in list_comments)
                {
                    if ((App.LoginedUser != null) && (comment.AuthorName == App.LoginedUser.Name))
                    {
                        comments += ChatBoxTool.Send(comment.AuthorAvatar,
                                                     comment.AuthorName == _blog.AuthorName ? "[博主]" + _blog.AuthorName : comment.AuthorName,
                                                     comment.Content, comment.PublishTime);
                    }
                    else
                    {
                        comments += ChatBoxTool.Receive(comment.AuthorAvatar,
                                                        comment.AuthorName == _blog.AuthorName ? "[博主]" + _blog.AuthorName : comment.AuthorName,
                                                        comment.Content, comment.PublishTime, comment.ID);
                    }
                }
                //comments += "<a id='ok'></a>";

                _totalHtml = _totalHtml.Replace("<a id='ok'></a>", "") + comments + "<a id='ok'></a>";

                BlogComment.NavigateToString(_totalHtml);
                Loading.IsActive = false;
            }
        }