public void MakeBlankDocument()
        {
            CleanUpPrivateVariables();
            m_NotepadXXmlDocument.LoadXml("<" + m_catNoteConfiguration.XmlTagName + @" id=""" + m_catNoteConfiguration.RootNoteId + @""" title=""" + m_catNoteConfiguration.DefaultRootNoteTitle + @"""/>");
            m_catNoteConfiguration.IsDocumentReadOnly = false;
            ContentDetail rootNote = this.GetNoteById(this.Configuration.RootNoteId);

            rootNote.SetCreatedByInfo();
            rootNote.SetCustomAttribute("openWithApplicationName", "NotepadX");
            rootNote.SetCustomAttribute("openWithApplicationHomePage", @"http://www.ShitalShah.com/notepadx");
            m_catNoteConfiguration.SetIsDirty(true);
        }
        public void Remove(string catNoteId)
        {
            if (m_catNoteConfiguration.IsDocumentReadOnly == false)
            {
                ContentDetail catNoteDetailForId = (ContentDetail)Dictionary[catNoteId];
                m_NotepadXDocumentParentXmlNode.RemoveChild(catNoteDetailForId.XmlNode);
                Dictionary.Remove(catNoteDetailForId);
            }
            else
            {
                throw new ReadOnlyDocumentException("Can not remove note because this document is read-only");
            }

            m_catNoteConfiguration.SetIsDirty(true);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="outerXmlForNote"></param>
        /// <returns>GUID of new node created</returns>
        protected internal string AddXmlDirect(string outerXmlForNote)
        {
            XmlDocumentFragment newNoteXmlFragment = m_NotepadXDocumentParentXmlNode.OwnerDocument.CreateDocumentFragment();

            newNoteXmlFragment.InnerXml = outerXmlForNote;
            ContentDetail newNote = new ContentDetail(newNoteXmlFragment.FirstChild, m_catNoteConfiguration);
            string        newId   = Guid.NewGuid().ToString();

            newNote.SetId(newId);

            newNoteXmlFragment.InnerXml = newNote.Xml;
            m_NotepadXDocumentParentXmlNode.AppendChild(newNoteXmlFragment);

            return(newId);
        }
        public ContentDetail Add(string noteTitle)
        {
            if (m_catNoteConfiguration.IsDocumentReadOnly == false)
            {
                ContentDetail newNoteForCollection = ContentDetail.CreateCatNoteDetail(m_NotepadXDocumentParentXmlNode, m_catNoteConfiguration);
                newNoteForCollection.Title = noteTitle;
                newNoteForCollection.SetCreatedByInfo();
                Dictionary.Add(newNoteForCollection.Id, newNoteForCollection);

                m_catNoteConfiguration.SetIsDirty(true);

                return(newNoteForCollection);
            }
            else
            {
                throw new ReadOnlyDocumentException("Can not add new note because this document is read-only");
            }
        }
        /// <summary>
        /// Reset this note's ID to new GUID and change all of child's IDs recursively
        /// </summary>
        /// <param name="noteToChange">Parent note whoes ID will be changed</param>
        public void ResetNoteIDs(string noteId, bool isRecurseChilds, bool isChangeParent)
        {
            ContentDetail noteToChange = GetNoteById(noteId);

            if (isChangeParent == true)
            {
                string newId = Guid.NewGuid().ToString();
                noteToChange.SetId(newId);                      //This should be done before so we can find it uniquely
            }

            if (isRecurseChilds == true)
            {
                ContentDetailCollection childNotes = GetChildNotes(noteToChange.Id);
                if (childNotes != null)
                {
                    foreach (DictionaryEntry childNoteDictionaryEntry in childNotes)
                    {
                        ContentDetail childCatNote = ((ContentDetail)childNoteDictionaryEntry.Value);
                        ResetNoteIDs(childCatNote.Id, true, true);                              //Recurse
                    }
                }
            }
        }