private void CaptchaTextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == Key.Enter) { CommentBox.Focus(); } }
private void ElementFocused(object sender, NewThreadPageViewModel.NewThreadFocusResult e) { switch (e) { case NewThreadPageViewModel.NewThreadFocusResult.Captcha: Focus(); Deployment.Current.Dispatcher.BeginInvoke(() => { CaptchaTextBox.Focus(); }); break; case NewThreadPageViewModel.NewThreadFocusResult.Comment: CommentBox.Focus(); break; case NewThreadPageViewModel.NewThreadFocusResult.Page: Focus(); break; default: break; } }
protected void ButtonClick(object sender, EventArgs e) { if (main.signedIn) { if (sender.Equals(PostCommentButton)) { if (replyFlag == 0) { Comment newComment = new Comment(main.currUser.UserName, CommentBox.Text, this); newComment.CurrentUser = true; commentsFeed.Children.Add(newComment); ScrollViewComments.ScrollToEnd(); discussion.GetComments().Add(newComment); CommentBox.Text = ""; CommentBoxDefault.Text = "Type a message..."; discussion.numReplies++; string repliesString = discussion.numReplies.ToString(); repliesString += (discussion.numReplies != 1) ? " replies" : " reply"; NumRepliesButton.Content = repliesString; discussion.replyCount.Text = repliesString; CommentBox.Focus(); //parent.GetDiscussionDict()[discussion.GetDiscussionId()] = discussion; } else if (replyFlag == 1) { //string[] reply = CommentBox.Text.Split('\n'); Comment newComment = new Comment(main.currUser.UserName, CommentBox.Text, this); newComment.CurrentUser = true; commentToReplyTo.repliesFeed.Children.Add(newComment); CommentBox.Text = ""; CommentBoxDefault.Text = "Type a message..."; replyFlag = 0; commentToReplyTo = null; discussion.numReplies++; string repliesString = discussion.numReplies.ToString(); repliesString += (discussion.numReplies != 1) ? " replies" : " reply"; NumRepliesButton.Content = repliesString; discussion.replyCount.Text = repliesString; CommentBox.Focus(); } } else if (sender.Equals(DeleteButton)) { DeletePrompt prompt = new DeletePrompt(main, this); prompt.SetMessage("This action cannot be undone, are you sure you want to proceed?"); prompt.ShowDialog(); main.HighlightTab(); if (prompt.confirmed == true) { // remove from discussions page main.currDiscussionPage.discussionDict.Remove(discussion.discussionId); main.currDiscussionPage.DisplayDiscussionPosts(); // remove from user's profile page main.currUser.userDiscussions.Remove(discussion.discussionId); main.currProfilePage.DisplayPosts(); // close popup window this.Visibility = Visibility.Hidden; main.ChangeFill(Visibility.Hidden); } } else if (sender.Equals(EditButton)) { if (editable == false) { EditButton.Content = "Save Changes"; EditButton.Background = Brushes.Yellow; editable = true; descriptionTextBox.Text = DiscussionDescription.Text; DiscussionDescription.Visibility = Visibility.Hidden; descriptionTextBox.Visibility = Visibility.Visible; Keyboard.Focus(descriptionTextBox); descriptionTextBox.CaretIndex = descriptionTextBox.Text.Length; } else { EditButton.Content = "EDIT"; EditButton.Background = Brushes.LightGray; DiscussionDescription.Visibility = Visibility.Visible; editable = false; updateDescription(); } } else if (sender.Equals(saveButton)) { if (!discussion.saved) { // Create a new instance with the same attributes Discussion copyOfDiscussion = new Discussion(discussion.discussionId, discussion.user, discussion.title, discussion.description, discussion.numReplies); copyOfDiscussion.score = discussion.score; copyOfDiscussion.main = discussion.main; copyOfDiscussion.comments = discussion.comments; // Set the saved flag of the new Discussion to true copyOfDiscussion.Saved = true; // Pass it to SavedPage.AddPost() main.currSavedPage.AddPost(copyOfDiscussion); // Set the Saved button content of this discussion to Unsave // Set the saved flag of this dicussion to true discussion.saved = true; discussion.saveDiscussion.Content = "Unsave"; saveButton.Content = "Unsave"; } else if (discussion.saved) { discussion.saved = false; main.currSavedPage.RemovePost(discussion); main.currDiscussionPage.SetDiscussionUnsaved(discussion); discussion.saveDiscussion.Content = "Save"; saveButton.Content = "Save"; } } else if (sender.Equals(MessageUserButton)) { MessageDevelopmentPrompt prompt = new MessageDevelopmentPrompt(this); prompt.ShowDialog(); } } else if (!main.signedIn) { if (sender.Equals(saveButton)) { NoBlurPrompt prompt = new NoBlurPrompt(main, this); prompt.SetMessage("You must sign in to save posts."); prompt.ShowDialog(); main.HighlightTab(); } else { NoBlurPrompt prompt = new NoBlurPrompt(main, this); prompt.SetMessage("You must sign in to discuss with users."); prompt.ShowDialog(); main.HighlightTab(); } } }
private void discussionLoaded(object sender, RoutedEventArgs e) { CommentBox.Focus(); }
private void InitializeApplicationBar() { _refresh = new ApplicationBarIconButton(new Uri("Assets/Appbar/appbar.refresh.png", UriKind.Relative)) { Text = AppResources.ApplicationBar_Refresh }; _refresh.Click += async(sender, e) => await _viewModel.Update(); _watch = new ApplicationBarIconButton(new Uri("Assets/Appbar/appbar.eye.png", UriKind.Relative)) { Text = AppResources.ApplicationBar_Watch }; _watch.Click += (sender, e) => { _viewModel.ToggleWatchlisted(); UpdateWatchButton(); }; _reply = new ApplicationBarIconButton(new Uri("Assets/Appbar/appbar.reply.png", UriKind.Relative)) { Text = AppResources.ApplicationBar_Reply }; _reply.Click += (sender, e) => _viewModel.OpenReplyRegion(); _send = new ApplicationBarIconButton(new Uri("Assets/Appbar/appbar.send.png", UriKind.Relative)) { Text = AppResources.ApplicationBar_Send }; _send.Click += async(sender, e) => { _send.IsEnabled = false; Focus(); ReplyPageViewModelBase.SubmitResultType result = await _viewModel.Submit(); _send.IsEnabled = true; switch (result) { case ReplyPageViewModelBase.SubmitResultType.Success: ScrollToBottom(); break; case ReplyPageViewModelBase.SubmitResultType.EmptyCaptchaError: case ReplyPageViewModelBase.SubmitResultType.WrongCatpchaError: Focus(); Deployment.Current.Dispatcher.BeginInvoke(() => { CaptchaTextBox.Focus(); }); break; case ReplyPageViewModelBase.SubmitResultType.EmptyCommentError: CommentBox.Focus(); break; case ReplyPageViewModelBase.SubmitResultType.KnownError: case ReplyPageViewModelBase.SubmitResultType.NoImageError: case ReplyPageViewModelBase.SubmitResultType.UnknownError: break; } }; _edit = new ApplicationBarIconButton(new Uri("Assets/Appbar/appbar.edit.png", UriKind.Relative)) { Text = AppResources.ApplicationBar_Edit }; _edit.Click += (sender, e) => _viewModel.EditReply(); ApplicationBarMenuItem bottom = new ApplicationBarMenuItem(AppResources.ApplicationBar_ScrollToBottom); bottom.Click += (sender, e) => ScrollToBottom(); ApplicationBar = new ApplicationBar(); if (CriticalSettingsManager.Current.EnableManualRefresh) { ApplicationBar.Buttons.Add(_refresh); } ApplicationBar.Buttons.Add(_reply); ApplicationBar.Buttons.Add(_watch); ApplicationBar.MenuItems.Add(bottom); ApplicationBar.MenuItems.Add(_orientLock); }