public TreeNode LoadTreeNodes(ContentDetailCollection notesCollectionForCategory, TreeNode rootNodeForCategory, string treeNodeIdToReturn) { TreeNode treeNodeFoundForId = null; if (notesCollectionForCategory != null) { foreach (DictionaryEntry thisCatNoteDetailDictionaryEntry in notesCollectionForCategory) { ContentDetail thisCatNoteDetailNode = (ContentDetail)thisCatNoteDetailDictionaryEntry.Value; TreeNode newNode = CreateTreeNodeForCatNoteDetail(rootNodeForCategory.Nodes, thisCatNoteDetailNode); //Get category childs and recurse to fill childs TreeNode treeNodeFoundForIdFromChilds = LoadTreeNodes(m_NotepadXDocument.GetChildNotes(thisCatNoteDetailNode.Id), newNode, treeNodeIdToReturn); if (treeNodeIdToReturn == thisCatNoteDetailNode.Id) { treeNodeFoundForId = newNode; } else if (treeNodeFoundForIdFromChilds != null) { treeNodeFoundForId = treeNodeFoundForIdFromChilds; } } } return(treeNodeFoundForId); }
private ContentDetailCollection GetCategoryForSetting(string settingCategoryName, bool createCategoryIfNotExist) { ContentDetailCollection settingsInCategory = null;; ContentDetailCollection currentConfigurationSetCollection = null; if (CurrentConfigurationSet == "") //no config set is defined { //category is in root node settingsInCategory = m_NotepadXDocument.GetChildNotesByNoteTitle(settingCategoryName, false); //if no category exit if ((settingsInCategory == null) && (createCategoryIfNotExist == true)) { //Add this new category in root settingsInCategory = m_NotepadXDocument.CreateNoteInRoot(settingCategoryName).GetChildNotes(); } } else { //first get configuration set currentConfigurationSetCollection = m_NotepadXDocument.GetChildNotesByNoteTitle(CurrentConfigurationSet, false); //If no configurationset exit if ((currentConfigurationSetCollection == null) && (createCategoryIfNotExist == true)) { //Create configuration set in root, create category currentConfigurationSetCollection = m_NotepadXDocument.CreateNoteInRoot(CurrentConfigurationSet).GetChildNotes(); settingsInCategory = currentConfigurationSetCollection.Add(settingCategoryName).GetChildNotes(); } if (currentConfigurationSetCollection == null) { settingsInCategory = null; } else { settingsInCategory = currentConfigurationSetCollection.GetChildNotesByNoteTitle(settingCategoryName, false); if ((settingsInCategory == null) && (createCategoryIfNotExist == true)) { settingsInCategory = currentConfigurationSetCollection.Add(settingCategoryName).GetChildNotes(); } } } return(settingsInCategory); }
public void AddNewChildNoteForTreeNode(string noteId, string noteContent, string noteFormat) { //Get child notes ContentDetailCollection childsForSelectedNote = m_NotepadXDocument.GetChildNotes(noteId); ContentDetail newNote = childsForSelectedNote.Add(); newNote.Title = DefaultNewNoteTitle; newNote.Content = noteContent; newNote.Format = noteFormat; TreeNode newAddedNode = RefreshTreeFromCatNoteDocumentAndSelectNote(newNote.Id); if (newAddedNode != null) { newAddedNode.BeginEdit(); } }
public void SetSetting(string settingCategoryName, string settingName, string settingValue, bool isSaveNow) { ContentDetailCollection settingsInCategory = GetCategoryForSetting(settingCategoryName, true); ContentDetail settinngDetail = settingsInCategory.GetNoteDetailByNoteTitle(settingName, false); if (settinngDetail == null) { //Create setting settinngDetail = settingsInCategory.Add(); settinngDetail.Title = settingName; } settinngDetail.Content = settingValue; if (isSaveNow == true) { this.Save(); } }
public string GetSetting(string settingCategoryName, string settingName, string settingValueToReturnIfNotFound) { ContentDetailCollection settingsInCategory = GetCategoryForSetting(settingCategoryName, false); if (settingsInCategory != null) { ContentDetail settinngDetail = settingsInCategory.GetNoteDetailByNoteTitle(settingName, false); if (settinngDetail == null) { return(settingValueToReturnIfNotFound); } else { return(settinngDetail.Content); } } else { return(settingValueToReturnIfNotFound); } }