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); }
internal override bool Perform() { if (!AcronymManager.IsTypeNode(_treeAcronyms.FocusedNode)) { return(false); } VarConfig.AcronymTypeRow typeRow = _treeAcronyms.FocusedNode.Tag as VarConfig.AcronymTypeRow; string usage = string.Empty; List <VarConfig.AcronymRow> usedAcronymRows = new List <VarConfig.AcronymRow>(); foreach (VarConfig.AcronymRow acronymRow in _varConfigFacade.GetAcronymsOfType(typeRow.ShortName)) { string usingVariables = _acronymManager.GetVariablesUsingAcronym(acronymRow.Name, typeRow.ShortName); if (usingVariables != string.Empty) { usedAcronymRows.Add(acronymRow); usage += acronymRow.Name + " used by " + usingVariables + Environment.NewLine; } } if (usage != string.Empty) { if (usage.Length > 2000) //probably this will happen only per accident, if a user tries to delete types like tax or benefit/pension (MessageBox is then too large for the screen) { usage = usage.Substring(0, 2000) + Environment.NewLine + Environment.NewLine + "etc., etc., etc."; } if (Tools.UserInfoHandler.GetInfo("The following acronyms of this type are used:" + Environment.NewLine + usage + Environment.NewLine + Environment.NewLine + "Cancel delete?", MessageBoxButtons.YesNo) == DialogResult.Yes) { return(false); } foreach (VarConfig.AcronymRow usedAcronymRow in usedAcronymRows) { usedAcronymRow.Description = VariablesManager.DESCRIPTION_UNKNOWN; //temporarily rename, to allow for updating automatic labels } typeRow.LongName = VariablesManager.DESCRIPTION_UNKNOWN; _acronymManager.UpdateAutomaticLabelForSpecificAcronyms(usedAcronymRows); } typeRow.Delete(); return(true); }
internal override bool Perform() { if (!AcronymManager.IsLevelNode(_treeAcronyms.FocusedNode)) { return(false); } VarConfig.AcronymLevelRow levelRow = _treeAcronyms.FocusedNode.Tag as VarConfig.AcronymLevelRow; string usage = string.Empty; List <VarConfig.AcronymRow> usedAcronymRows = new List <VarConfig.AcronymRow>(); foreach (VarConfig.AcronymRow acronymRow in _varConfigFacade.GetAcronymsOfType(levelRow.AcronymTypeRow.ShortName)) { if (levelRow.Name.ToLower() != acronymRow.AcronymLevelRow.Name.ToLower()) { continue; } string usingVariables = _acronymManager.GetVariablesUsingAcronym(acronymRow.Name, levelRow.AcronymTypeRow.ShortName); if (usingVariables != string.Empty) { usedAcronymRows.Add(acronymRow); usage += acronymRow.Name + " used by " + usingVariables + "\n"; } } if (usage != string.Empty) { if (Tools.UserInfoHandler.GetInfo("The following acronyms of this level are used:\n" + usage + "\nCancel delete?", MessageBoxButtons.YesNo) == DialogResult.Yes) { return(false); } foreach (VarConfig.AcronymRow usedAcronymRow in usedAcronymRows) { usedAcronymRow.Description = VariablesManager.DESCRIPTION_UNKNOWN; //temporarily rename, to allow for updating automatic labels } _acronymManager.UpdateAutomaticLabelForSpecificAcronyms(usedAcronymRows); } levelRow.Delete(); return(true); }