async private Task onEditDiscussionNoteAsync(Control noteControl) { DiscussionNote note = getNoteFromControl(noteControl); if (note == null || !canBeModified(note)) { return; } string currentBody = StringUtils.ConvertNewlineUnixToWindows(note.Body); DiscussionNoteEditPanel actions = new DiscussionNoteEditPanel(); using (TextEditForm form = new TextEditForm("Edit Discussion Note", currentBody, true, true, actions)) { Point locationAtScreen = noteControl.PointToScreen(new Point(0, 0)); form.StartPosition = FormStartPosition.Manual; form.Location = locationAtScreen; actions.SetTextbox(form.TextBox); if (form.ShowDialog() == DialogResult.OK) { if (form.Body.Length == 0) { MessageBox.Show("Note text cannot be empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } string proposedBody = StringUtils.ConvertNewlineWindowsToUnix(form.Body); await submitNewBodyAsync(noteControl, proposedBody); } } }
async private Task onReplyToDiscussionAsync(bool proposeUserToToggleResolveOnReply) { bool isAlreadyResolved = isDiscussionResolved(); string resolveText = String.Format("{0} Thread", (isAlreadyResolved ? "Unresolve" : "Resolve")); DiscussionNoteEditPanel actions = new DiscussionNoteEditPanel(resolveText, proposeUserToToggleResolveOnReply); using (TextEditForm form = new TextEditForm("Reply to Discussion", "", true, true, actions)) { actions.SetTextbox(form.TextBox); if (form.ShowDialog() == DialogResult.OK) { if (form.Body.Length == 0) { MessageBox.Show("Reply text cannot be empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } string proposedBody = StringUtils.ConvertNewlineWindowsToUnix(form.Body); await onReplyAsync(proposedBody, actions.IsResolveActionChecked); } } }