/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.NavigationMode == NavigationMode.New) { Logger.LogAgent.GetInstance().WriteLog(this.GetType().ToString()); } string typeValue = string.Empty; string id = string.Empty; if (e.Parameter is Post) { this.post = e.Parameter as Post; this.commentsCount = post.CommentsCount; this.commentDS = new CommentsDS(this.post.ID, "blog"); } else if (e.Parameter is News) { this.news = e.Parameter as News; this.commentsCount = news.CommentsCount; this.commentDS = new CommentsDS(this.news.ID, "news"); } this.commentDS.OnLoadMoreStarted += commentDS_OnLoadMoreStarted; this.commentDS.OnLoadMoreCompleted += commentDS_OnLoadMoreCompleted; this.lv_Comments.ItemsSource = commentDS; }
/// <summary> /// save post to fav folder /// </summary> public async static Task SaveFav(Post post) { var favFolder = await GetFavFolder(); var filename = CombinePostFileName(post.ID); // get/overwrite post file var postFile = await favFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting); var xml = await Functions.Serialize(post); await FileIO.WriteTextAsync(postFile, xml); }
private void SetNewStatus(CNBlogs.DataHelper.DataModel.Post post, CNBlogs.DataHelper.DataModel.PostStatus newStatus, bool updateUI = true) { if (post.Status != newStatus) { if (post.Status <= newStatus) { post.Status = newStatus; DataHelper.DataModel.CNBlogSettings.Instance.SaveBlogStatus(post); } if (updateUI) { this.UpdateUI(); } } }
/// <summary> /// delete post from fav folder /// </summary> public async static Task DeleteFavPost(Post post) { var favFolder = await GetFavFolder(); var filename = CombinePostFileName(post.ID); // get/overwrite post file var postFile = await favFolder.CreateFileAsync(filename, CreationCollisionOption.OpenIfExists); await postFile.DeleteAsync(); }
/// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// /// Page specific logic should be placed in event handlers for the /// <see cref="GridCS.Common.NavigationHelper.LoadState"/> /// and <see cref="GridCS.Common.NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. protected async override void OnNavigatedTo(NavigationEventArgs e) { try { navigationHelper.OnNavigatedTo(e); this.commentsCount = string.Empty; var pageFile = string.Empty; if (e.Parameter is Post) { this.post = e.Parameter as Post; this.Title = this.post.Title; this.Author = post.Author; this.commentsCount = post.CommentsCount; CNBlogs.DataHelper.CloudAPI.PostContentDS pcDS = new DataHelper.CloudAPI.PostContentDS(post.ID); if (await pcDS.LoadRemoteData()) { content = pcDS.Content; } pageFile = "ms-appx-web:///HTML/post_day.html"; currentBlogger.DataContext = this.post.Author; this.commentDS = new CommentsDS(this.post.ID, "blog"); //set read this.SetNewStatus(this.post, PostStatus.Read, true); } else if (e.Parameter is News) { this.news = e.Parameter as News; this.Title = this.news.Title; this.commentsCount = news.CommentsCount; CNBlogs.DataHelper.CloudAPI.NewsContentDS ncDS = new DataHelper.CloudAPI.NewsContentDS(news.ID); if (await ncDS.LoadRemoteData()) { content = ncDS.News.Content; } pageFile = "ms-appx-web:///HTML/news_day.html"; this.commentDS = new CommentsDS(this.news.ID, "news"); //CNBlogs.DataHelper.DataModel.CNBlogSettings.Instance.SetBlogAsRead(this.news.ID); } else { return; } this.DataContext = this; this.wv_Post.Navigate(new Uri(pageFile)); this.commentDS.OnLoadMoreCompleted += commentDS_OnLoadMoreCompleted; this.lv_Comments.ItemsSource = commentDS; if (this.commentsCount == "0") { this.lv_Comments.Visibility = Windows.UI.Xaml.Visibility.Collapsed; this.tb_Message.Visibility = Windows.UI.Xaml.Visibility.Visible; } } catch (Exception ex) { this.Title = ex.Message; } }
/// <summary> /// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// <para> /// Page specific logic should be placed in event handlers for the /// <see cref="NavigationHelper.LoadState"/> /// and <see cref="NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. /// </para> /// </summary> /// <param name="e">Provides data for navigation methods and event /// handlers that cannot cancel the navigation request.</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { if (e.NavigationMode == NavigationMode.New) { Logger.LogAgent.GetInstance().WriteLog(this.GetType().ToString()); } this.navigationHelper.OnNavigatedTo(e); if (e.NavigationMode != NavigationMode.Back) { var pageFile = string.Empty; if (!CNBlogs.DataHelper.DataModel.CNBlogSettings.Instance.NightModeTheme) { pageFile = "ms-appx-web:///HTML/post_day.html#width={0}&height={1}"; this.wv_WebContent.DefaultBackgroundColor = Windows.UI.Colors.White; } else { pageFile = "ms-appx-web:///HTML/post_night.html#width={0}&height={1}"; this.wv_WebContent.DefaultBackgroundColor = Windows.UI.Colors.Black; } if (e.Parameter is Post) { this.post = e.Parameter as Post; this.Author = post.Author; this.commentsCount = post.CommentsCount; CNBlogs.DataHelper.CloudAPI.PostContentDS pcDS = new DataHelper.CloudAPI.PostContentDS(post.ID); if (await pcDS.LoadRemoteData()) { // combine author part to add to content var authorElement = string.Format(AUTHOR_PART_FORMAT, this.post.Title, this.Author == null ? string.Empty : this.Author.Uri, this.Author == null ? string.Empty : this.Author.Name, this.Author == null || string.IsNullOrWhiteSpace(this.Author.Avatar) ? string.Empty : string.Format("<img src='{0}' />", this.Author.Avatar)); content = authorElement + pcDS.Content; } UpdateUI(); string width = Window.Current.Bounds.Width.ToString(); string height = Window.Current.Bounds.Height.ToString(); this.wv_WebContent.Navigate(new Uri(string.Format(pageFile, width, height))); } } }
public void SaveBlogStatus(Post post) { SetPostReadState(SettingKeyFormat_BlogReaded, post.ID, post.Status); }
/// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// /// Page specific logic should be placed in event handlers for the /// <see cref="GridCS.Common.NavigationHelper.LoadState"/> /// and <see cref="GridCS.Common.NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. protected async override void OnNavigatedTo(NavigationEventArgs e) { if (e.NavigationMode == NavigationMode.New) { Logger.LogAgent.GetInstance().WriteLog(this.GetType().ToString()); } try { //for favorite button display await FavoriteAuthorDS.Instance.Refresh(); navigationHelper.OnNavigatedTo(e); this.commentsCount = string.Empty; var pageFile = string.Empty; if (e.Parameter is Post) { this.post = e.Parameter as Post; this.Title = this.post.Title; this.Author = post.Author; if (this.Author.Avatar == null) { SearchAuthorInfo(); } this.commentsCount = post.CommentsCount; CNBlogs.DataHelper.CloudAPI.PostContentDS pcDS = new DataHelper.CloudAPI.PostContentDS(post.ID); if (await pcDS.LoadRemoteData()) { content = pcDS.Content; } pageFile = "ms-appx-web:///HTML/post_day.html"; currentBlogger.DataContext = this.post.Author; this.commentDS = new CommentsDS(this.post.ID, "blog"); //set read this.SetNewStatus(this.post, PostStatus.Read, true); } else { return; } this.DataContext = this; this.wv_Post.Navigate(new Uri(pageFile)); this.commentDS.OnLoadMoreCompleted += commentDS_OnLoadMoreCompleted; this.lv_Comments.ItemsSource = commentDS; if (this.commentsCount == "0") { this.lv_Comments.Visibility = Windows.UI.Xaml.Visibility.Collapsed; this.tb_Message.Visibility = Windows.UI.Xaml.Visibility.Visible; } //Set UI this.SetTitleFont(pageTitle.Text.Length); UpdateUI(); RegisterForShare(); } catch (Exception ex) { this.Title = ex.Message; } }
/// <summary> /// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// <para> /// Page specific logic should be placed in event handlers for the /// <see cref="NavigationHelper.LoadState"/> /// and <see cref="NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. /// </para> /// </summary> /// <param name="e">Provides data for navigation methods and event /// handlers that cannot cancel the navigation request.</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { this.navigationHelper.OnNavigatedTo(e); string commentsCount = string.Empty; var pageFile = string.Empty; if (e.Parameter is Post) { this.post = e.Parameter as Post; this.Author = post.Author; commentsCount = post.CommentsCount; CNBlogs.DataHelper.CloudAPI.PostContentDS pcDS = new DataHelper.CloudAPI.PostContentDS(post.ID); if (await pcDS.LoadRemoteData()) { //this.wv_Post.NavigateToString(pcDS.Content); content = pcDS.Content; } pageFile = "ms-appx-web:///HTML/post.html"; } else if (e.Parameter is News) { this.news = e.Parameter as News; commentsCount = news.CommentsCount; CNBlogs.DataHelper.CloudAPI.NewsContentDS ncDS = new DataHelper.CloudAPI.NewsContentDS(news.ID); if (await ncDS.LoadRemoteData()) { //this.wv_Post.NavigateToString(ncDS.News.Content); content = ncDS.News.Content; } pageFile = "ms-appx-web:///HTML/news.html"; } UpdateUI(commentsCount); this.wv_WebContent.Navigate(new Uri(pageFile)); }