async void ChangeCommentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { var InputBox = sender.Content as TextBox; if (InputBox.Text.Length == 0) { ShowMessageAsync(ResourceLoader.GetForCurrentView("Resources").GetString("EmptyCommentError")); } else { var statusBar = StatusBar.GetForCurrentView(); statusBar.ProgressIndicator.ProgressValue = null; statusBar.ProgressIndicator.Text = ResourceLoader.GetForCurrentView("Resources").GetString("UpdateMessage"); await statusBar.ProgressIndicator.ShowAsync(); var Item = this.DefaultViewModel[CourseItem] as Course; var Entity = Item.Id; var Id = Convert.ToInt32(InputBox.Tag.ToString()); var NewText = InputBox.Text; bool isSuccess = await CommentsSource.ChangeCommentAsync(Entity, Id, NewText); await statusBar.ProgressIndicator.HideAsync(); if (isSuccess) { ShowMessageAsync(ResourceLoader.GetForCurrentView("Resources").GetString("CommentSuccessfulChanging")); } else { ShowMessageAsync(ResourceLoader.GetForCurrentView("Resources").GetString("ErrorMessage")); } } }
private async void CommentsList_Loaded(object sender, RoutedEventArgs e) { this.CommentsLoadedProgressRing.IsActive = true; var Item = this.DefaultViewModel[CourseItem] as Course; var CommentsList = await CommentsSource.GetCommentsAsync(Item.Id); this.CommentsLoadedProgressRing.IsActive = false; if (CommentsList == null) { await ShowErrorAsync(); } else { this.DefaultViewModel[Comments] = CommentsList; if (CommentsList.Comments.Count == 0) { this.NoCommentsTextBlock.Visibility = Visibility.Visible; } else { this.NoCommentsTextBlock.Visibility = Visibility.Collapsed; } this.CommentInputTextBox.IsEnabled = true; if (CommentsList.NextPageUri == null) { this.CommentsScrollViewer.ViewChanged -= ScrollViewer_ViewChanged; } } }
public void initData(VideoBase currentVideo) { commentSource = new CommentsSource(); videoId = currentVideo.VID; this.Title = currentVideo.TITLE; updateComment(); }
private async void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e) { if (!e.IsIntermediate) { var Sender = sender as ScrollViewer; if (Sender.ScrollableHeight - Sender.VerticalOffset == 0) { lock (IncrementalLoadingHelper) { if (isIncrementalLoadingStarted) { return; } else { isIncrementalLoadingStarted = true; } } var CommentsGroup = this.DefaultViewModel[Comments] as CommentsGroup; if (CommentsGroup.NextPageUri == null) { this.CommentsScrollViewer.ViewChanged -= ScrollViewer_ViewChanged; } else { var statusBar = StatusBar.GetForCurrentView(); statusBar.ProgressIndicator.Text = ResourceLoader.GetForCurrentView("Resources").GetString("DownloadingMessage"); statusBar.ProgressIndicator.ProgressValue = null; await statusBar.ProgressIndicator.ShowAsync(); bool isSuccess = await CommentsSource.LoadMoreCommentsAsync(CommentsGroup.Id); await statusBar.ProgressIndicator.HideAsync(); if (isSuccess) { var UpdatedGroup = this.DefaultViewModel[Comments] as CommentsGroup; if (UpdatedGroup.NextPageUri == null) { this.CommentsScrollViewer.ViewChanged -= ScrollViewer_ViewChanged; } } else { await ShowErrorAsync(); } } lock (IncrementalLoadingHelper) { isIncrementalLoadingStarted = false; } } } }
private async void CommentInputTextBox_KeyUp(object sender, KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Enter) { this.CommentInputTextBox.IsEnabled = false; var Text = this.CommentInputTextBox.Text.ToString(); if (Text.Length == 0) { await ShowErrorAsync(); } else { var Item = this.DefaultViewModel[CourseItem] as Course; var statusBar = StatusBar.GetForCurrentView(); statusBar.ProgressIndicator.ProgressValue = null; statusBar.ProgressIndicator.Text = ResourceLoader.GetForCurrentView("Resources").GetString("AddingMessage"); await statusBar.ProgressIndicator.ShowAsync(); bool isSuccess = await CommentsSource.AddCommentAsync(Item.Id, Text); await statusBar.ProgressIndicator.HideAsync(); if (isSuccess) { this.CommentInputTextBox.Text = ""; this.CommentsScrollViewer.ChangeView(0, 0, this.CommentsScrollViewer.ZoomFactor); ShowMessageAsync(ResourceLoader.GetForCurrentView("Resources").GetString("CommentSuccessfulAdding")); if (this.NoCommentsTextBlock.Visibility == Visibility.Visible) { this.NoCommentsTextBlock.Visibility = Visibility.Collapsed; } } else { ShowMessageAsync(ResourceLoader.GetForCurrentView("Resources").GetString("ErrorMessage")); } this.CommentInputTextBox.IsEnabled = true; } } }
private async void RemoveCommentClick(object sender, RoutedEventArgs e) { var senderElement = sender as MenuFlyoutItem; var CommentIdString = senderElement.Tag.ToString(); if (CommentIdString.Length == 0) { ShowMessageAsync(ResourceLoader.GetForCurrentView("Resources").GetString("ErrorMessage")); } else { var Item = this.DefaultViewModel[CourseItem] as Course; int CommentId = Convert.ToInt32(CommentIdString); var statusBar = StatusBar.GetForCurrentView(); statusBar.ProgressIndicator.ProgressValue = null; statusBar.ProgressIndicator.Text = ResourceLoader.GetForCurrentView("Resources").GetString("RemoveMessage"); await statusBar.ProgressIndicator.ShowAsync(); bool isSuccess = await CommentsSource.RemoveCommentAsync(Item.Id, CommentId); await statusBar.ProgressIndicator.HideAsync(); if (isSuccess) { ResourceLoader.GetForCurrentView("Resources").GetString("CommentSuccessfulRemoving"); if ((this.DefaultViewModel[Comments] as CommentsGroup).Comments.Count == 0) { this.NoCommentsTextBlock.Visibility = Visibility.Visible; } else { this.NoCommentsTextBlock.Visibility = Visibility.Collapsed; } } else { ShowMessageAsync(ResourceLoader.GetForCurrentView("Resources").GetString("ErrorMessage")); } } }