internal ChangeAcronymAction(VariablesForm variablesForm, CellValueChangedEventArgs eventArgs) { _variablesForm = variablesForm; _acronymManager = variablesForm._acronymManager; _varConfigFacade = _variablesForm._varConfigFacade; _eventArgs = eventArgs; }
internal DeleteCategoryAction(VariablesForm variablesForm) { _acronymManager = variablesForm._acronymManager; _treeAcronyms = variablesForm.treeAcronyms; _dgvCategories = variablesForm.dgvCategories; _varConfigFacade = variablesForm._varConfigFacade; }
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); }
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); }
void DisplayUnusedAcronyms(bool expand) //... as assessed in CheckForUnusedAcronyms { treeAcronyms.BeginUnboundLoad(); //store which nodes are expanded, the focused node and the first visible node List <string> expandedNodesIDs = new List <string>(); string focusedNodeID = string.Empty; string topVisibleNodeID = string.Empty; AcronymManager.StoreNodeStates(treeAcronyms, ref expandedNodesIDs, ref focusedNodeID, ref topVisibleNodeID); treeAcronyms.Nodes.Clear(); TreeListNode typeNode = null; TreeListNode levelNode = null; foreach (VarConfig.AcronymRow acroRow in _acronymsToDisplay) { VarConfig.AcronymTypeRow typeRow = acroRow.AcronymLevelRow.AcronymTypeRow; if (typeNode == null || !(typeNode.Tag as VarConfig.AcronymTypeRow).Equals(typeRow)) { typeNode = treeAcronyms.AppendNode(null, null); typeNode.SetValue(colAcronym, typeRow.LongName.ToUpper() + " (" + typeRow.ShortName.ToUpper() + ")"); typeNode.Tag = typeRow; } VarConfig.AcronymLevelRow levelRow = acroRow.AcronymLevelRow; if (levelNode == null || !(levelNode.Tag as VarConfig.AcronymLevelRow).Equals(levelRow)) { levelNode = treeAcronyms.AppendNode(null, typeNode); levelNode.SetValue(colAcronym, levelRow.Name); levelNode.Tag = levelRow; } TreeListNode acroNode = treeAcronyms.AppendNode(null, levelNode); acroNode.SetValue(colAcronym, acroRow.Description + " (" + acroRow.Name.ToUpper() + ")"); acroNode.SetValue(colDeleteAcronyms, true); acroNode.Tag = acroRow; } //restore collapse/expanded, focused and first visible node states AcronymManager.RestoreNodeStates(treeAcronyms, expandedNodesIDs, focusedNodeID, topVisibleNodeID); treeAcronyms.EndUnboundLoad(); colAcronym.BestFit(); colDeleteAcronyms.BestFit(); if (expand) { treeAcronyms.ExpandAll(); //initially, i.e. if called from btnLoad_Click, expand all nodes } }
void VariablesForm_Load(object sender, EventArgs e) { string helpPath; EM_AppContext.Instance.GetHelpPath(out helpPath); helpProvider.HelpNamespace = helpPath; btnSwitchablePolicies.Enabled = !EM_AppContext.Instance.IsPublicVersion(); try { _undoManager = new ADOUndoManager(); _undoManager.AddDataSet(_varConfigFacade._varConfig); _acronymManager = new AcronymManager(this); _variablesManager = new VariablesManager(this); _acronymManager.FillAcronymsList(); _variablesManager.FillVariablesList(); //fill the combo-box containing all countries to filter for country specific descriptions RepositoryItemComboBox ricmbCountry = cmbCountry.Edit as RepositoryItemComboBox; ricmbCountry.Items.Clear(); ricmbCountry.Items.Add(_anyCountry); foreach (CountryAdministration.Country country in CountryAdministration.CountryAdministrator.GetCountries()) { ricmbCountry.Items.Add(country._shortName); } cmbCountry.EditValue = _anyCountry; //fill the combo-box containing all acronym types for searching an acronym //(should actually be updated if an acronym type is added/removed, but considering this is a very uncommon event and a rather unimportant function ...) RepositoryItemComboBox ricmbAcronymType = cmbAcronymType.Edit as RepositoryItemComboBox; ricmbAcronymType.Items.Clear(); ricmbAcronymType.Items.Add(_allAcronymTypes); foreach (VarConfig.AcronymTypeRow acroTypeRow in _varConfigFacade.GetAllAcronyms()) { ricmbAcronymType.Items.Add(acroTypeRow.LongName.ToUpper()); } cmbAcronymType.EditValue = ricmbAcronymType.Items[0].ToString(); //add data-dependant filter-checkboxes (show benefit variables, show demographic variables, ...) DrawFilterCheckboxes(); //_varConfigFacade contains a list of variables and acronyms created in the current session _varConfigFacade.ClearNewRowsList(); SetButtonGreyState(); } catch (Exception exception) { Tools.UserInfoHandler.ShowException(exception); } }
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 (_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); }
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); }
internal DeleteAcronymTypeAction(VariablesForm variablesForm) { _acronymManager = variablesForm._acronymManager; _treeAcronyms = variablesForm.treeAcronyms; _varConfigFacade = variablesForm._varConfigFacade; }
bool CheckForUnusedAcronyms(double progressSoFar = 0.0, double progressToAchieve = 0.0, BackgroundWorker backgroundWorker = null) { if (_acronymsToDisplay == null) { _acronymsToDisplay = new List <VarConfig.AcronymRow>(); } else { _acronymsToDisplay.Clear(); } int acronymsCount = _varConfigFacade.GetAcronymsCount(); //for displaying progress, see below int i = 0; //get all variables to check whether they use an acronym ... List <string> variablesNames = _varConfigFacade.GetVariables_Names(); foreach (VarConfig.AcronymTypeRow typeRow in _varConfigFacade.GetAllAcronyms()) { if (backgroundWorker != null && backgroundWorker.CancellationPending) { return(false); } foreach (VarConfig.AcronymLevelRow levelRow in typeRow.GetAcronymLevelRows()) { if (backgroundWorker != null && backgroundWorker.CancellationPending) { return(false); } foreach (VarConfig.AcronymRow acroRow in levelRow.GetAcronymRows()) { if (backgroundWorker != null && backgroundWorker.CancellationPending) { return(false); } bool used = false; foreach (string variableName in variablesNames) { if (backgroundWorker != null && backgroundWorker.CancellationPending) { return(false); } if (_variablesToDelete.Contains(variableName.ToLower())) { continue; //... but exempt variables which are to be deleted from the check } if (AcronymManager.IsAcronymOfVariable(variableName, acroRow.Name, typeRow.ShortName)) { used = true; break; } } if (!used) //store unused acronyms to be displayed outside (via DisplayAcronyms), as this function is (amongst others) used by the background worker, { _acronymsToDisplay.Add(acroRow); //thus displaying here isn't possible, as the acronym-tree-list belongs to another thread } if (backgroundWorker != null) { double progressPart = (i++ + 1.0) / acronymsCount * progressToAchieve; backgroundWorker.ReportProgress(Convert.ToInt32((progressSoFar + progressPart) * 100.0)); } } } } return(true); }
internal AddCategoryAction(VariablesForm variablesForm) { _acronymManager = variablesForm._acronymManager; _treeAcronyms = variablesForm.treeAcronyms; _varConfigFacade = variablesForm._varConfigFacade; }
internal DeleteAcronymAction(VariablesForm variablesForm) { _acronymManager = variablesForm._acronymManager; _treeAcronyms = variablesForm.treeAcronyms; }