Example #1
0
        private void AddNewNote(object sender, EventArgs e)
        {
            AddNoteDialog dialog = new AddNoteDialog(m_project);

            dialog.Verse = m_verseRef;
            dialog.ShowDialog();
            if (dialog.DialogResult == DialogResult.OK)
            {
                if (dialog.m_comment.Lines.Length == 0)
                {
                    MessageBox.Show("Comment cannot be empty");
                }
                else
                {
                    IWriteLock writeLock = m_project.RequestWriteLock(
                        this,
                        WriteLockReleaseRequested,
                        WriteLockScope.ProjectNotes);

                    if (writeLock == null)
                    {
                        MessageBox.Show("Can't get a write lock");
                    }
                    else
                    {
                        string text = dialog.SelectedText;
                        IScriptureTextSelection anchor = null;
                        if (string.IsNullOrEmpty(text))
                        {
                            anchor = m_project.GetScriptureSelectionForVerse(dialog.Verse);
                        }
                        else
                        {
                            IReadOnlyList <IScriptureTextSelection> anchors;
                            anchors = m_project.FindMatchingScriptureSelections(dialog.Verse, text, wholeWord: dialog.WholeWord);
                            if (anchors.Count != 0)
                            {
                                anchor = anchors[0];
                            }
                        }
                        if (anchor == null)
                        {
                            MessageBox.Show("Nothing matches selection");
                        }
                        else
                        {
                            List <CommentParagraph> paragraphs = FormParagraphs(dialog.m_comment.Lines);

                            IUserInfo assignee = dialog.Assignee;

                            m_project.AddNote(writeLock, anchor, paragraphs, assignedUser: assignee);
                        }
                        writeLock.Dispose();
                    }
                }
                UpdateNotesList();
            }
            dialog.Dispose();
        }
Example #2
0
 public Annotation(IScriptureTextSelection selection, string styleName)
 {
     ScriptureSelection = selection;
     StyleName          = styleName;
 }