private void FolderNodeContextMenu_Popup(object sender, EventArgs e) { ContextMenu contextMenu = sender as ContextMenu; TreeNode treeNode = contextMenu.Tag as TreeNode; BookmarkFolder folder = treeNode.Tag as BookmarkFolder; contextMenu.MenuItems.Clear(); contextMenu.MenuItems.Add(new MenuItem(folder == null ? "&Add Folder..." : "&Add Subfolder...", (sender2, e2) => { string dialogResult = PromptBox.Show("Folder path:", folder == null ? "" : (folder.Path + "/"), "Add subfolder", null); if (dialogResult != null) { BookmarksModel.RegisterPath(dialogResult); } }) { Name = "folder_add" }); if (folder != null) { contextMenu.MenuItems.Add(new MenuItem("&Edit Folder...", (sender2, e2) => { string folderPath = GetPathFileName(folder.Path); string dialogResult = PromptBox.Show("Change name to:", folder.Text, string.Format("Edit Bookmark folder - {0}", folder.Path), (new string[] { folder.Text, CultureInfo.CurrentCulture?.TextInfo?.ToTitleCase(folder.Text), folder.Text.ToLower(), folder.Text.ToUpper(), folderPath, CultureInfo.CurrentCulture?.TextInfo?.ToTitleCase(folderPath), folderPath.ToLower(), folderPath.ToUpper(), }).Distinct().Where(x => !string.IsNullOrEmpty(x)).ToArray()); if (dialogResult != null) { folder.Text = dialogResult; treeNode.Text = dialogResult; treeView.Sort(treeNode.Parent, treeViewNodeSorter); } }) { Name = "folder_edit" }); contextMenu.MenuItems.Add(new MenuItem("&Remove Folder", (sender2, e2) => { treeNode.Remove(); BookmarksModel.RemovePath(folder.Path); }) { Name = "remove_folder" }); // TODO: "move to..." command (to change the folder (and its children) path) } }