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 void FillCategoriesList(TreeListNode focusedNode) { _dgvCategories.Rows.Clear(); if (!IsAcronymNode(focusedNode)) { return; } VarConfig.AcronymRow acronymRow = focusedNode.Tag as VarConfig.AcronymRow; foreach (VarConfig.CategoryRow categoryRow in acronymRow.GetCategoryRows()) { int index = _dgvCategories.Rows.Add(categoryRow.Value, categoryRow.Description); _dgvCategories.Rows[index].Tag = categoryRow; } _variablesForm.colCategoryValue.Width = _variablesForm.colCategoryValue.GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true); _variablesForm.colCategoryDescription.Width = _variablesForm.colCategoryDescription.GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true); if (_dgvCategories.SortedColumn == null) { _dgvCategories.Sort(_variablesForm.colCategoryValue, System.ComponentModel.ListSortDirection.Ascending); } else { System.ComponentModel.ListSortDirection sortOrder = System.ComponentModel.ListSortDirection.Ascending; if (_dgvCategories.SortOrder == SortOrder.Descending) { sortOrder = System.ComponentModel.ListSortDirection.Descending; } _dgvCategories.Sort(_dgvCategories.SortedColumn, sortOrder); } }
TreeListNode AcronymTree_AddNode(TreeListNode parentNode, object nodeTag, string action = "") { TreeListNode node = treeAcronyms.AppendNode(null, parentNode); if (action == string.Empty) { node.SetValue(colPerformAcronyms, string.Empty); //do not show check box if just "header", e.g. type containing added/deleted/changed acronyms/levels, but not changed itself } else { node.SetValue(colPerformAcronyms, _actionDefaultPerform); } node.SetValue(colActionAcronyms, action); node.SetValue(colInfoAcronyms, string.Empty); node.Tag = nodeTag; //somewhat unelegant procedure, which serves only to determin the content of colAcronym string acronymText = string.Empty; VarConfig.AcronymTypeRow typeRow = null; VarConfig.AcronymLevelRow levelRow = null; VarConfig.AcronymRow acronymRow = null; bool tagIsDictionary = action == _actionChange || action == string.Empty; if (parentNode == null) { typeRow = !tagIsDictionary ? nodeTag as VarConfig.AcronymTypeRow : (nodeTag as Dictionary <VarConfig.AcronymTypeRow, VarConfig.AcronymTypeRow>).Keys.ElementAt(0); } else if (parentNode != null && parentNode.ParentNode == null) { levelRow = !tagIsDictionary ? nodeTag as VarConfig.AcronymLevelRow : (nodeTag as Dictionary <VarConfig.AcronymLevelRow, VarConfig.AcronymLevelRow>).Keys.ElementAt(0); } else { acronymRow = !tagIsDictionary ? nodeTag as VarConfig.AcronymRow : (nodeTag as Dictionary <VarConfig.AcronymRow, VarConfig.AcronymRow>).Keys.ElementAt(0); } if (typeRow != null) { acronymText = typeRow.ShortName.ToUpper() + " (" + typeRow.LongName + ")"; } if (levelRow != null) { acronymText = levelRow.Name; } if (acronymRow != null) { acronymText = acronymRow.Name + " (" + acronymRow.Description + ")"; } node.SetValue(colAcronym, acronymText); return(node); }
void FillCategoriesList() { dgvCategories.Rows.Clear(); if (treeAcronyms.FocusedNode == null || treeAcronyms.FocusedNode.ParentNode == null || treeAcronyms.FocusedNode.ParentNode.ParentNode == null) { return; //no acronym node } if (!treeAcronyms.FocusedNode.GetDisplayText(colInfoAcronyms).Contains(_infoChangeCategory)) { return; //no node indicating a category difference } VarConfig.AcronymRow internalAcronym = (treeAcronyms.FocusedNode.Tag as Dictionary <VarConfig.AcronymRow, VarConfig.AcronymRow>).Keys.ElementAt(0); VarConfig.AcronymRow externalAcronym = (treeAcronyms.FocusedNode.Tag as Dictionary <VarConfig.AcronymRow, VarConfig.AcronymRow>).Values.ElementAt(0); //search for categories existing in internal list only and for categories with different description or value foreach (VarConfig.CategoryRow internalCategory in internalAcronym.GetCategoryRows()) { bool found = false; foreach (VarConfig.CategoryRow externalCategory in externalAcronym.GetCategoryRows()) { if (internalCategory.Value != externalCategory.Value && internalCategory.Description != externalCategory.Description) { continue; } found = true; if (internalCategory.Value != externalCategory.Value || internalCategory.Description != externalCategory.Description) { dgvCategories.Rows.Add(internalCategory.Value, internalCategory.Description, externalCategory.Value, externalCategory.Description); } break; } if (!found) { dgvCategories.Rows.Add(internalCategory.Value, internalCategory.Description, "-", "-"); } } //search for categories existing in external list only foreach (VarConfig.CategoryRow externalCategory in externalAcronym.GetCategoryRows()) { bool found = false; foreach (VarConfig.CategoryRow internalCategory in internalAcronym.GetCategoryRows()) { if (internalCategory.Value == externalCategory.Value || internalCategory.Description == externalCategory.Description) {//it is enough that value OR description are equal, as only categories existing in the external list only are searched found = true; break; } } if (!found) { dgvCategories.Rows.Add("-", "-", externalCategory.Value, externalCategory.Description); } } }
internal static bool IsAcronymNode(TreeListNode node) { if (node == null || node.Tag == null) { return(false); } VarConfig.AcronymRow acronymRow = node.Tag as VarConfig.AcronymRow; return(acronymRow != null); }
internal void DeleteCategoryRows(VarConfig.AcronymRow acronymRow) { List <VarConfig.CategoryRow> categoryRows = (from categoryRow in acronymRow.GetCategoryRows() select categoryRow).ToList(); for (int index = categoryRows.Count() - 1; index >= 0; --index) { categoryRows.ElementAt(index).Delete(); } }
void PerformAddAcronym(VarConfig.AcronymLevelRow internalLevel, VarConfig.AcronymRow externalAcronym) { VarConfig.AcronymRow internalAcronym = _varConfigFacade.AddAcronymRow(internalLevel, externalAcronym.Name, externalAcronym.Description); foreach (VarConfig.CategoryRow externalCategory in externalAcronym.GetCategoryRows()) { _varConfigFacade.AddCategoryRow(internalAcronym, externalCategory.Value, externalCategory.Description); } _varConfigFacade.Commit(); }
short AssessAcroLevel(string ID, bool local, out DataRow dataRow, List <string> allIDs = null) { VarConfigFacade _vcFac = local ? _vcFacLocal : _vcFacRemote; dataRow = _vcFac.GetAcronymTypeByID(ID); if (dataRow != null) { return(LEVEL_ACROTYPE); } VarConfig.AcronymLevelRow acroLevel = _vcFac.GetAcronymLevelByID(ID); if (acroLevel != null) { if (allIDs != null && allIDs.Contains(acroLevel.AcronymTypeRow.ID)) { return(LEVEL_INVALID); //the level is already taken into account, by the action on type-level (e.g. deleted via the type instead of individually) } dataRow = acroLevel; return(LEVEL_ACROLEVEL); } VarConfig.AcronymRow acro = _vcFac.GetAcronymByID(ID); if (acro != null) { if (allIDs != null && (allIDs.Contains(acro.AcronymLevelRow.ID) || allIDs.Contains(acro.AcronymLevelRow.AcronymTypeRow.ID))) { return(LEVEL_INVALID); //see comment above } dataRow = acro; return(LEVEL_ACRO); } if (!ID.Contains("#")) { return(LEVEL_INVALID); } string catValue = ID.Split(new string[] { "#" }, StringSplitOptions.None)[0]; string acroID = ID.Split(new string[] { "#" }, StringSplitOptions.None)[1]; VarConfig.CategoryRow categ = _vcFac.GetCategoryByKey(acroID, catValue); if (categ != null) { if (allIDs != null && (allIDs.Contains(categ.AcronymRow.ID) || allIDs.Contains(categ.AcronymRow.AcronymLevelRow.ID) || allIDs.Contains(categ.AcronymRow.AcronymLevelRow.AcronymTypeRow.ID))) { return(LEVEL_INVALID); //see comment above } dataRow = categ; return(LEVEL_ACROCAT); } dataRow = null; return(LEVEL_INVALID); }
void AddAcros(bool local) { List <string> addIDs = GetRelevantIDs(_mcAcronyms, local, true); foreach (string ID in addIDs) { DataRow dataRow; switch (AssessAcroLevel(ID, false, out dataRow)) { case LEVEL_INVALID: continue; //should not happen case LEVEL_ACROTYPE: VarConfig.AcronymTypeRow acroType = dataRow as VarConfig.AcronymTypeRow; _vcFacLocal.CopyAcronymTypeRow(acroType); //note: this copies without content (i.e. without included levels, their acronyms and their categories (which may have been refused)) break; case LEVEL_ACROLEVEL: VarConfig.AcronymLevelRow acroLevel = dataRow as VarConfig.AcronymLevelRow; VarConfig.AcronymTypeRow parentType = _vcFacLocal.GetAcronymTypeByID(acroLevel.AcronymTypeRow.ID); if (parentType != null) //possible though non-sense (see comment below) { _vcFacLocal.CopyAcronymLevelRow(acroLevel, parentType); //see note above (i.e. included acronyms and their categories are not copied) } break; case LEVEL_ACRO: VarConfig.AcronymRow acro = dataRow as VarConfig.AcronymRow; VarConfig.AcronymLevelRow parentLevel = _vcFacLocal.GetAcronymLevelByID(acro.AcronymLevelRow.ID); if (parentLevel != null) //possible though non-sense (see comment below) { _vcFacLocal.CopyAcronymRow(acro, parentLevel); //see note above (i.e. included categories are not copied) } break; case LEVEL_ACROCAT: VarConfig.CategoryRow categ = dataRow as VarConfig.CategoryRow; VarConfig.AcronymRow parentAcro = _vcFacLocal.GetAcronymByID(categ.AcronymRow.ID); if (parentAcro != null) //may happen if (though non-sense) copying acro was refused while copying category was accepted { _vcFacLocal.CopyCategoryRow(categ, parentAcro); } break; } } _vcFacLocal.GetVarConfig().AcceptChanges(); }
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); }
void PerformChangeAcronym(VarConfig.AcronymRow internalAcronym, VarConfig.AcronymRow externalAcronym, string info) { if (info.Contains(ImportVariablesForm._infoNewDescription)) { internalAcronym.Description = externalAcronym.Description; } if (info.Contains(ImportVariablesForm._infoChangeCategory)) { _varConfigFacade.DeleteCategoryRows(internalAcronym); foreach (VarConfig.CategoryRow externalCategory in externalAcronym.GetCategoryRows()) { _varConfigFacade.AddCategoryRow(internalAcronym, externalCategory.Value, externalCategory.Description); } } _varConfigFacade.Commit(); }
internal override bool Perform() { string newValue = _eventArgs.Value.ToString(); VarConfig.AcronymRow acronymRow = _eventArgs.Node.Tag as VarConfig.AcronymRow; List <KeyValuePair <string, string> > updateLabelAcronyms = new List <KeyValuePair <string, string> >(); //change of acronym-description if (_eventArgs.Column.Name == _variablesForm.colAcronymDescription.Name) { if (newValue == acronymRow.Description) { return(false); //only change if different } acronymRow.Description = newValue; updateLabelAcronyms.Add(new KeyValuePair <string, string>(acronymRow.Name, acronymRow.AcronymLevelRow.AcronymTypeRow.ShortName)); } //change of acronym itself else { if (newValue == acronymRow.Name) { return(false); //only change if different } //check for usage 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\nUndo change?", MessageBoxButtons.YesNo) == DialogResult.Yes) { _updateVariables = false; return(true); //return true to allow for redraw, i.e. show the old value still stored in the datarow (but only update acronyms, no need to update variables) } } //check for correctness if (newValue.Length != 2) { Tools.UserInfoHandler.ShowError("Acronym must have two characters. Please correct."); _updateVariables = false; return(true); //return true to allow for redraw, i.e. show the old value still stored in the datarow (but only update acronyms, no need to update variables) } if (newValue.Contains('#')) { Tools.UserInfoHandler.ShowError("Character # is reserved for footnotes and therefore cannot be used for acronyms. Please correct."); _updateVariables = false; return(true); //return true to allow for redraw, i.e. show the old value still stored in the datarow (but only update acronyms, no need to update variables) } string acroType = _eventArgs.Node.ParentNode.ParentNode.GetDisplayText(_variablesForm.colAcronym); foreach (VarConfig.AcronymRow silblingRow in _varConfigFacade.GetAcronymsOfType(acroType)) { if (silblingRow.Name.ToLower() == newValue.ToLower()) { Tools.UserInfoHandler.ShowError("Acronym already exists (see level " + silblingRow.AcronymLevelRow.Name + "). Please correct."); _updateVariables = false; return(true); //return true to allow for redraw, i.e. show the old value still stored in the datarow (but only update acronyms, no need to update variables) } } //care for updating automatic labels of variables concerned updateLabelAcronyms.Add(new KeyValuePair <string, string>(newValue, acronymRow.AcronymLevelRow.AcronymTypeRow.ShortName)); //variables already using the new acro-name now get a valid auto-label if (usingVariables != string.Empty) { updateLabelAcronyms.Add(new KeyValuePair <string, string>(acronymRow.Name, acronymRow.AcronymLevelRow.AcronymTypeRow.ShortName)); //variables, which used the old acro-name get an invalid auto-label } //finally reflect change in datarow acronymRow.Name = newValue; } //update automatic label of variables concerned _variablesForm._acronymManager.UpdateAutomaticLabelForSpecificAcronyms(updateLabelAcronyms); return(true); }
internal static void StoreNodeStates(TreeList treeAcronyms, ref List <string> expandedNodesIDs, ref string focusedNodeID, ref string topVisibleNodeID) { foreach (TreeListNode typeNode in treeAcronyms.Nodes) { VarConfig.AcronymTypeRow typeRow = typeNode.Tag as VarConfig.AcronymTypeRow; if (typeRow.RowState != System.Data.DataRowState.Unchanged) { continue; //happens if tree is redrawn because of an undo action } string typeID = typeRow.ID; if (typeNode.Expanded == true) { expandedNodesIDs.Add(typeID); } if (typeNode.Focused == true) { focusedNodeID = typeID; } if (treeAcronyms.GetVisibleIndexByNode(typeNode) == treeAcronyms.TopVisibleNodeIndex) { topVisibleNodeID = typeID; } foreach (TreeListNode levelNode in typeNode.Nodes) { VarConfig.AcronymLevelRow levelRow = levelNode.Tag as VarConfig.AcronymLevelRow; if (levelRow.RowState != System.Data.DataRowState.Unchanged) { continue; } string levelID = levelRow.ID; if (levelNode.Expanded == true) { expandedNodesIDs.Add(levelID); } if (levelNode.Focused == true) { focusedNodeID = levelID; } if (treeAcronyms.GetVisibleIndexByNode(levelNode) == treeAcronyms.TopVisibleNodeIndex) { topVisibleNodeID = levelID; } foreach (TreeListNode acroNode in levelNode.Nodes) { VarConfig.AcronymRow acroRow = acroNode.Tag as VarConfig.AcronymRow; if (acroRow.RowState != System.Data.DataRowState.Unchanged) { continue; } string acroID = acroRow.ID; if (acroNode.Focused == true) { focusedNodeID = acroID; } if (treeAcronyms.GetVisibleIndexByNode(acroNode) == treeAcronyms.TopVisibleNodeIndex) { topVisibleNodeID = acroID; } } } } }
void ChangeAcros(bool local) { foreach (MergeControl.NodeInfo nodeInfo in local ? _mcAcronyms.GetNodeInfoLocal() : _mcAcronyms.GetNodeInfoRemote()) { if (nodeInfo.changeType != MergeControl.ChangeType.changed || nodeInfo.changeHandling == (local ? MergeControl.ChangeHandling.accept : MergeControl.ChangeHandling.reject)) { continue; //not relevant, because neither changed nor locally accepted nor remotely rejected } const string NOT_CHANGED = "NOT_CHANGED"; MergeControl.CellInfo cellInfo = nodeInfo.cellInfo.First(); MergeControl.CellInfo cellInfoRemote = local ? _mcAcronyms.GetTwinCellInfo(cellInfo) : cellInfo; string changedName = (cellInfo.isChanged && (local ? !cellInfo.acceptChange : cellInfo.acceptChange)) //if name is changed and remotely accepted or locally rejected ? cellInfoRemote.text : NOT_CHANGED; //change to remote name (otherwise mark not changed) cellInfo = nodeInfo.cellInfo.Last(); cellInfoRemote = local ? _mcAcronyms.GetTwinCellInfo(cellInfo) : cellInfo; string changedDesc = (cellInfo.isChanged && (local ? !cellInfo.acceptChange : cellInfo.acceptChange)) //if description is changed and remotely accepted or locally rejected ? cellInfoRemote.text : NOT_CHANGED; //change to remote description (otherwise mark not changed) DataRow dataRow; switch (AssessAcroLevel(nodeInfo.ID, true, out dataRow)) { case LEVEL_INVALID: continue; //should not happen case LEVEL_ACROTYPE: VarConfig.AcronymTypeRow acroType = dataRow as VarConfig.AcronymTypeRow; if (changedName != NOT_CHANGED) { acroType.ShortName = changedName; } if (changedDesc != NOT_CHANGED) { acroType.LongName = changedDesc; } break; case LEVEL_ACROLEVEL: VarConfig.AcronymLevelRow acroLevel = dataRow as VarConfig.AcronymLevelRow; if (changedName != NOT_CHANGED) { acroLevel.Index = Convert.ToInt32(changedName); //probably not relevant } if (changedDesc != NOT_CHANGED) { acroLevel.Name = changedDesc; } break; case LEVEL_ACRO: VarConfig.AcronymRow acro = dataRow as VarConfig.AcronymRow; if (changedName != NOT_CHANGED) { acro.Name = changedName; } if (changedDesc != NOT_CHANGED) { acro.Description = changedDesc; } break; case LEVEL_ACROCAT: VarConfig.CategoryRow categ = dataRow as VarConfig.CategoryRow; if (changedName != NOT_CHANGED) { categ.Value = changedName; } if (changedDesc != NOT_CHANGED) { categ.Description = changedDesc; } break; } } }
void FillAcronymsList() { //(1) ACRONYM TYPES: search for elements existing only in one version as well as elements with different descriptions and/or content List <VarConfig.AcronymTypeRow> internalTypes = _internalVarConfigFacade.GetAcronymTypesSortedByShortName(); List <VarConfig.AcronymTypeRow> externalTypes = _externalVarConfigFacade.GetAcronymTypesSortedByShortName(); List <string> internalIDs = (from internalType in internalTypes select internalType.ShortName).ToList(); List <string> externalIDs = (from externalType in externalTypes select externalType.ShortName).ToList(); Dictionary <int, int> compareTypeIndexList = new Dictionary <int, int>(); List <int> addIndexList = new List <int>(); List <int> deleteIndexList = new List <int>(); AnalyseLists(internalIDs, externalIDs, ref compareTypeIndexList, ref addIndexList, ref deleteIndexList); //fill the found differences into the tree-control foreach (int addIndex in addIndexList) //elements only existent in external version { AcronymTree_AddNode(null, externalTypes.ElementAt(addIndex), _actionAdd); } foreach (int deleteIndex in deleteIndexList) //elements only existent in internal version { AcronymTree_AddNode(null, internalTypes.ElementAt(deleteIndex), _actionDelete); } foreach (int internalTypeIndex in compareTypeIndexList.Keys) //elements existent in both version: still have to check for different description and/or content { int externalTypeIndex = compareTypeIndexList[internalTypeIndex]; VarConfig.AcronymTypeRow internalType = internalTypes.ElementAt(internalTypeIndex); VarConfig.AcronymTypeRow externalType = externalTypes.ElementAt(externalTypeIndex); Dictionary <VarConfig.AcronymTypeRow, VarConfig.AcronymTypeRow> typeTag = new Dictionary <VarConfig.AcronymTypeRow, VarConfig.AcronymTypeRow>(); typeTag.Add(internalType, externalType); //put a Dictionary with one element into Tag, as KeyValuePair cannot be casted back, because it does not allow for NULL values TreeListNode typeNode = null; //check for different description (LongName) if (internalType.LongName != externalType.LongName) { typeNode = AcronymTree_AddNode(null, typeTag, _actionChange); typeNode.SetValue(colInfoAcronyms, _infoNewDescription + externalType.LongName); } //check for differnet content, i.e.: //(2) ACRONYM LEVELS: search for elements existing only in one version as well as elements with different content List <VarConfig.AcronymLevelRow> internalLevels = _internalVarConfigFacade.GetAcronymLevelsSortedByName(internalType); List <VarConfig.AcronymLevelRow> externalLevels = _externalVarConfigFacade.GetAcronymLevelsSortedByName(externalType); internalIDs = (from internalLevel in internalLevels select internalLevel.Name).ToList(); externalIDs = (from externalLevel in externalLevels select externalLevel.Name).ToList(); Dictionary <int, int> compareLevelIndexList = new Dictionary <int, int>(); addIndexList.Clear(); deleteIndexList.Clear(); AnalyseLists(internalIDs, externalIDs, ref compareLevelIndexList, ref addIndexList, ref deleteIndexList); if (typeNode == null && (addIndexList.Count != 0 || deleteIndexList.Count != 0)) { typeNode = AcronymTree_AddNode(null, typeTag); //generate parent node if necessary } //fill the found differences into the tree-control foreach (int addIndex in addIndexList) //elements only existent in external version { AcronymTree_AddNode(typeNode, externalLevels.ElementAt(addIndex), _actionAdd); } foreach (int deleteIndex in deleteIndexList) //elements only existent in internal version { AcronymTree_AddNode(typeNode, internalLevels.ElementAt(deleteIndex), _actionDelete); } foreach (int internalLevelIndex in compareLevelIndexList.Keys) //elements existent in both version: still have to check for different content { int externalLevelIndex = compareLevelIndexList[internalLevelIndex]; VarConfig.AcronymLevelRow internalLevel = internalLevels.ElementAt(internalLevelIndex); VarConfig.AcronymLevelRow externalLevel = externalLevels.ElementAt(externalLevelIndex); Dictionary <VarConfig.AcronymLevelRow, VarConfig.AcronymLevelRow> levelTag = new Dictionary <VarConfig.AcronymLevelRow, VarConfig.AcronymLevelRow>(); levelTag.Add(internalLevel, externalLevel); //put a Dictionary with one element into Tag, as KeyValuePair cannot be casted back, because it does not allow for NULL values TreeListNode levelNode = null; //check for differnet content, i.e.: //(3) ACRONYMS: search for elements existing only in one version as well as elements with different description List <VarConfig.AcronymRow> internalAcronyms = _internalVarConfigFacade.GetAcronymsOfLevelSortedByName(internalLevel); List <VarConfig.AcronymRow> externalAcronyms = _externalVarConfigFacade.GetAcronymsOfLevelSortedByName(externalLevel); internalIDs = (from internalAcronym in internalAcronyms select internalAcronym.Name).ToList(); externalIDs = (from externalAcronym in externalAcronyms select externalAcronym.Name).ToList(); Dictionary <int, int> compareAcronymIndexList = new Dictionary <int, int>(); addIndexList.Clear(); deleteIndexList.Clear(); AnalyseLists(internalIDs, externalIDs, ref compareAcronymIndexList, ref addIndexList, ref deleteIndexList); if (addIndexList.Count != 0 || deleteIndexList.Count != 0) { if (typeNode == null) //generate parent nodes if necessary { typeNode = AcronymTree_AddNode(null, typeTag); } if (levelNode == null) { levelNode = AcronymTree_AddNode(typeNode, levelTag); } } //fill the found differences into the tree-control foreach (int addIndex in addIndexList) //elements only existent in external version { AcronymTree_AddNode(levelNode, externalAcronyms.ElementAt(addIndex), _actionAdd); } foreach (int deleteIndex in deleteIndexList) //elements only existent in internal version { AcronymTree_AddNode(levelNode, internalAcronyms.ElementAt(deleteIndex), _actionDelete); } foreach (int internalAcronymIndex in compareAcronymIndexList.Keys) //elements existent in both version: still have to check for different description { int externalAcronymIndex = compareAcronymIndexList[internalAcronymIndex]; VarConfig.AcronymRow internalAcronym = internalAcronyms.ElementAt(internalAcronymIndex); VarConfig.AcronymRow externalAcronym = externalAcronyms.ElementAt(externalAcronymIndex); Dictionary <VarConfig.AcronymRow, VarConfig.AcronymRow> acronymTag = new Dictionary <VarConfig.AcronymRow, VarConfig.AcronymRow>(); acronymTag.Add(internalAcronym, externalAcronym); //put a Dictionary with one element into Tag, as KeyValuePair cannot be casted back, because it does not allow for NULL values TreeListNode acronymNode = null; //check for different description if (internalAcronym.Description != externalAcronym.Description) { if (typeNode == null) //generate parent nodes if necessary { typeNode = AcronymTree_AddNode(null, typeTag); } if (levelNode == null) { levelNode = AcronymTree_AddNode(typeNode, levelTag); } acronymNode = AcronymTree_AddNode(levelNode, acronymTag, _actionChange); acronymNode.SetValue(colInfoAcronyms, _infoNewDescription + externalAcronym.Description); } //check for different categories bool equal = internalAcronym.GetCategoryRows().Count() == externalAcronym.GetCategoryRows().Count(); if (equal) { foreach (VarConfig.CategoryRow internalCategory in internalAcronym.GetCategoryRows()) { bool found = false; foreach (VarConfig.CategoryRow externalCategory in externalAcronym.GetCategoryRows()) { if (internalCategory.Value == externalCategory.Value && internalCategory.Description == externalCategory.Description) { found = true; break; } } if (!found) { equal = false; break; //if one category different, acronym needs to be marked as changed - no need to check all categories here } } } if (!equal) { if (typeNode == null) //generate parent nodes if necessary { typeNode = AcronymTree_AddNode(null, typeTag); } if (levelNode == null) { levelNode = AcronymTree_AddNode(typeNode, levelTag); } string info = _infoChangeCategory; if (acronymNode == null) { acronymNode = AcronymTree_AddNode(levelNode, acronymTag, _actionChange); } else { info = acronymNode.GetDisplayText(colInfoAcronyms) + " + " + _infoChangeCategory; } acronymNode.SetValue(colInfoAcronyms, info); } } } } colPerformAcronyms.BestFit(); colAcronym.BestFit(); colActionAcronyms.BestFit(); colInfoAcronyms.BestFit(); treeAcronyms.ExpandAll(); }
internal void CopyCategoryRow(VarConfig.CategoryRow originalCategory, VarConfig.AcronymRow parentAcronym) { _varConfig.Category.AddCategoryRow(parentAcronym, originalCategory.Value, originalCategory.Description); }
internal VarConfig.CategoryRow AddCategoryRow(VarConfig.AcronymRow parentRow, string value = "", string description = "") { return(_varConfig.Category.AddCategoryRow(parentRow, value, description)); }
internal void CopyAcronymRow(VarConfig.AcronymRow originalAcronym, VarConfig.AcronymLevelRow parentLevel) { _varConfig.Acronym.AddAcronymRow(originalAcronym.ID, parentLevel, originalAcronym.Name, originalAcronym.Description); }