コード例 #1
0
        /// <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();
        }