private async void btnSend_Click(object sender, RoutedEventArgs e) { TextRange textRange = new TextRange( // TextPointer to the start of content in the RichTextBox. rtbDescription.Document.ContentStart, // TextPointer to the end of content in the RichTextBox. rtbDescription.Document.ContentEnd ); if (textRange.Text != "" && textRange.Text != "\r\n" && txtName.Text != "" && cbArea.Text != "") { Member M = MC.SearchMember(Environment.UserName); Project P = PC.AddProject(new Project { projectName = txtName.Text, projectDescription = textRange.Text, startDate = DateTime.Now, area = cbArea.Text }, M); CC.AddProjectComment(P.idProject, "The project was created. ", M.idMember); GlobalVariables.projecViewNav = P.projectName; txtName.Text = ""; rtbDescription.SelectAll(); rtbDescription.Selection.Text = ""; cbArea.Text = ""; var ProjectView = new ProjectView(); this.Content = ProjectView; } else { await metroWindow.ShowMessageAsync("Attention", "Fill all the fields first"); } }
private async void rtbDescription_LostFocus(object sender, RoutedEventArgs e) { //button add new task on the add task grid TextRange textRange = new TextRange( // TextPointer to the start of content in the RichTextBox. rtbDescription.Document.ContentStart, // TextPointer to the end of content in the RichTextBox. rtbDescription.Document.ContentEnd ); if (PC.UpdateDescription(P, textRange.Text) != null) { rtbDescription.Document.Blocks.ToString(); rtbProjectCommentHistory.Document.Blocks.Add(CC.AddProjectComment(P.idProject, "The project description was updated", MC.SearchMember(Environment.UserName).idMember)); } else { await metroWindow.ShowMessageAsync("Atention", "Description can not be updated"); } }