void SetButtonGreyState()
        {
            btnUndo.Enabled = _undoManager != null && _undoManager.HasChanges();
            btnRedo.Enabled = _undoManager != null && _undoManager.CanRedo();

            btnAddVariable.Enabled    = true;
            btnDeleteVariable.Enabled = dgvVariables.SelectedRows.Count > 0;

            btnAddAcronym.Enabled    = treeAcronyms.FocusedNode != null && !AcronymManager.IsTypeNode(treeAcronyms.FocusedNode);
            btnDeleteAcronym.Enabled = AcronymManager.IsAcronymNode(treeAcronyms.FocusedNode);

            btnAddLevel.Enabled    = treeAcronyms.FocusedNode != null;
            btnDeleteLevel.Enabled = AcronymManager.IsLevelNode(treeAcronyms.FocusedNode);

            btnAddType.Enabled    = true;
            btnDeleteType.Enabled = AcronymManager.IsTypeNode(treeAcronyms.FocusedNode);

            btnAddCategory.Enabled      = AcronymManager.IsAcronymNode(treeAcronyms.FocusedNode);
            btnDeleteCategories.Enabled = dgvCategories.SelectedRows.Count > 0;

            btnApplyFilters.Enabled = true;

            btnImportVariables.Enabled = !_isReadOnly && _varConfigFacade != null && _undoManager != null && !_undoManager.HasChanges() && _hasChangedSinceLastSave == false;
            btnCleanVariables.Enabled  = !_isReadOnly && _varConfigFacade != null && _undoManager != null && !_undoManager.HasChanges() && _hasChangedSinceLastSave == false;

            btnSave.Enabled = !_isReadOnly;
        }
        internal override bool Perform()
        {
            if (!AcronymManager.IsAcronymNode(_treeAcronyms.FocusedNode))
            {
                return(false);
            }

            VarConfig.AcronymRow acronymRow = _treeAcronyms.FocusedNode.Tag as VarConfig.AcronymRow;

            string usingVariables = _acronymManager.GetVariablesUsingAcronym(acronymRow.Name, acronymRow.AcronymLevelRow.AcronymTypeRow.ShortName);

            if (usingVariables != string.Empty)
            {
                if (Tools.UserInfoHandler.GetInfo("Acronym is used by variable(s) " + usingVariables + "\n\nCancel delete?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    return(false);
                }

                List <VarConfig.AcronymRow> usedAcronyms = new List <VarConfig.AcronymRow>();
                usedAcronyms.Add(acronymRow);
                acronymRow.Description = VariablesManager.DESCRIPTION_UNKNOWN; //temporarily rename, to allow for updating automatic labels
                _acronymManager.UpdateAutomaticLabelForSpecificAcronyms(usedAcronyms);
            }

            acronymRow.Delete();
            return(true);
        }
示例#3
0
        internal override bool Perform()
        {
            if (_treeAcronyms.FocusedNode == null || AcronymManager.IsTypeNode(_treeAcronyms.FocusedNode))
            {
                return(false);
            }

            TreeListNode parentNode = null;

            //assess at which level acronym should be inserted with respect to which node is focused
            if (AcronymManager.IsLevelNode(_treeAcronyms.FocusedNode))
            {
                parentNode = _treeAcronyms.FocusedNode;
            }
            else if (AcronymManager.IsAcronymNode(_treeAcronyms.FocusedNode))
            {
                parentNode = _treeAcronyms.FocusedNode.ParentNode;
            }

            //append the new node
            TreeListNode node = _treeAcronyms.AppendNode(null, parentNode);

            node.Tag = _varConfigFacade.AddAcronymRow(parentNode.Tag as VarConfig.AcronymLevelRow);

            parentNode.Expanded            = true;
            parentNode.ParentNode.Expanded = true;

            return(true);
        }
        internal override bool Perform()
        {
            if (_treeAcronyms.FocusedNode == null)
            {
                return(false);
            }

            TreeListNode addAfterNode = null;
            TreeListNode parentNode   = null;

            //assess where level should be inserted with respect to which node is focused ...
            if (AcronymManager.IsTypeNode(_treeAcronyms.FocusedNode))
            {
                parentNode = _treeAcronyms.FocusedNode; //... type node: insert as first level
            }
            else if (AcronymManager.IsLevelNode(_treeAcronyms.FocusedNode))
            {
                addAfterNode = _treeAcronyms.FocusedNode; //... (other) level node: insert after this level
                parentNode   = addAfterNode.ParentNode;
            }

            else if (AcronymManager.IsAcronymNode(_treeAcronyms.FocusedNode))
            {
                addAfterNode = _treeAcronyms.FocusedNode.ParentNode; //... acronym node: insert after the level of the acronym
                parentNode   = addAfterNode.ParentNode;
            }

            //first append the new node ...
            TreeListNode node = _treeAcronyms.AppendNode(null, parentNode);

            VarConfig.AcronymLevelRow addAfterRow = null;
            if (addAfterNode != null)
            {
                addAfterRow = addAfterNode.Tag as VarConfig.AcronymLevelRow;
            }
            node.Tag = _varConfigFacade.AddAcronymLevelRow(parentNode.Tag as VarConfig.AcronymTypeRow, addAfterRow);

            //... then move ...
            int pos = -1;

            if (addAfterNode == null)
            {
                pos = 0;                            //... at front, if type node was selected
            }
            else if (addAfterNode.NextNode != null) //... after the focused node, if level- or acronym-node selected
            {
                pos = addAfterNode.ParentNode.Nodes.IndexOf(addAfterNode.NextNode);
            }

            if (pos >= 0)
            {
                _treeAcronyms.SetNodeIndex(node, pos);
            }

            parentNode.Expanded = true;

            return(true);
        }
示例#5
0
        internal override bool Perform()
        {
            if (_treeAcronyms.FocusedNode == null || !AcronymManager.IsAcronymNode(_treeAcronyms.FocusedNode))
            {
                return(false);
            }

            VarConfig.AcronymRow acronymRow = _treeAcronyms.FocusedNode.Tag as VarConfig.AcronymRow;

            categStateChanged = acronymRow.GetCategoryRows().Count() == 0;

            _varConfigFacade.AddCategoryRow(acronymRow);

            _acronymManager.FillCategoriesList(_treeAcronyms.FocusedNode);

            return(true);
        }