/// <summary> /// When the "Add" button is clicked, creates a category with the name entered /// by the user. /// </summary> private void OnAddCategory(object sender, EventArgs e) { IResource root = _categoryTree.SelectedResource; string defaultContentType = null; if (root == null) { root = Core.CategoryManager.RootCategory; } else { defaultContentType = root.GetStringProp(Core.Props.ContentType); } IResource category = new NewCategoryDlg().ShowNewCategoryDialog(this, "", root, defaultContentType); _categoryTree.ProcessPendingUpdates(); if (category != null) { TreeNode node = _categoryTree.FindResourceNode(category); if (node != null) { _categoryTree.SelectedNode = node; _categoryTree.SetNodeCheckState(node, NodeCheckState.Checked); } } UpdateButtonState(); }
public void Execute(IActionContext context) { IResource defaultParent = null; string defaultContentType = null; if (context.SelectedResources.Count > 0) { defaultParent = context.SelectedResources [0]; defaultContentType = defaultParent.GetStringProp(Core.Props.ContentType); } using (NewCategoryDlg dlg = new NewCategoryDlg()) { IResource newCategory = dlg.ShowNewCategoryDialog(Core.MainWindow, "", defaultParent, defaultContentType); if (newCategory != null) { Core.LeftSidebar.DefaultViewPane.ExpandParents(newCategory); Core.LeftSidebar.DefaultViewPane.SelectResource(newCategory); } } }