Esempio n. 1
0
        /// <summary>
        /// Enables or disables the toolbar buttons.
        /// </summary>
        private void SetButtonsEnabled()
        {
            TreeNode selectedNode = treeView.SelectedNode;

            btnAdd.Enabled      = configProvider.AllowAction(ConfigAction.Add, btnAdd, selectedNode);
            btnMoveUp.Enabled   = configProvider.AllowAction(ConfigAction.MoveUp, btnMoveUp, selectedNode);
            btnMoveDown.Enabled = configProvider.AllowAction(ConfigAction.MoveDown, btnMoveDown, selectedNode);
            btnDelete.Enabled   = configProvider.AllowAction(ConfigAction.Delete, btnDelete, selectedNode);

            if (btnAddWithChoice.Visible)
            {
                bool anyItemEnabled = false;

                foreach (ToolStripItem item in btnAddWithChoice.DropDownItems)
                {
                    item.Enabled = configProvider.AllowAction(ConfigAction.Add, item, selectedNode);

                    if (item.Enabled)
                    {
                        anyItemEnabled = true;
                    }
                }

                btnAddWithChoice.Enabled = anyItemEnabled;
            }
        }