void StoreStates(TreeListNode senderNode) { try { BaseTreeListTag senderNodeTag = senderNode.Tag as BaseTreeListTag; //not that using string senderNodeID = (senderNodeTag as BaseTreeListTag).GetDefaultID() //is not a good idea, because it slows the process down by many catches if the data-row stored in the tag does not exist any more if (senderNode.Expanded) { _expandedNodesIDs.Add(senderNodeTag.GetDefaultID()); } if (senderNode.Selected) { _selectedNodesIDs.Add(senderNodeTag.GetDefaultID()); } if (senderNode.Visible == false) { _hiddenNodesIDs.Add(senderNodeTag.GetDefaultID()); } if (senderNode.Focused) { _focusedNodeID = senderNodeTag.GetDefaultID(); _focusedColumnIndex = senderNode.TreeList.Columns.IndexOf(senderNode.TreeList.FocusedColumn); //also store the focused column _focusedNodeID_alternative = GetFocusedNodeID_alternative(senderNode); } } catch (Exception e) { //do not jeopardise tree-list building, because node state cannot be restored (e.g. nodes point at deleted data-rows) Tools.UserInfoHandler.RecordIgnoredException("StoreRestoreNodeStates.StoreStates", e); } }
internal static List <ExtensionOrGroup> GetLookGroupDrawInfo(string cc, TreeListNode node) { if (CountryAdministrator.IsAddOn(cc) || node.Tag == null || node.Tag as BaseTreeListTag == null) { return(new List <ExtensionOrGroup>()); } BaseTreeListTag nodeTag = node.Tag as BaseTreeListTag; List <string> lookGroupIds = (from lgPol in GetCountryConfig(cc).LookGroup_Policy where lgPol.PolicyID == nodeTag.GetDefaultPolicyRow().ID select lgPol.LookGroupID).ToList(); if (nodeTag.GetDefaultFunctionRow() != null) { lookGroupIds.AddRange((from lgFun in GetCountryConfig(cc).LookGroup_Function where lgFun.FunctionID == nodeTag.GetDefaultFunctionRow().ID select lgFun.LookGroupID)); } if (nodeTag.GetDefaultParameterRow() != null) { lookGroupIds.AddRange((from lgPar in GetCountryConfig(cc).LookGroup_Parameter where lgPar.ParameterID == nodeTag.GetDefaultParameterRow().ID select lgPar.LookGroupID)); } List <ExtensionOrGroup> lookGroups = new List <ExtensionOrGroup>(); foreach (CountryConfig.LookGroupRow lg in GetCountryConfig(cc).LookGroup) { if (lookGroupIds.Contains(lg.ID)) { lookGroups.Add(new ExtensionOrGroup(lg)); } } return(lookGroups); }
void mnuFunction_Opening(object sender, CancelEventArgs e) { BaseTreeListTag treeListTag = _mainForm.treeList.FocusedNode.Tag as BaseTreeListTag; bool visible = (treeListTag.GetFunctionName().ToLower() == DefFun.DefIl.ToLower()); mniDescriptionAsComment.Visible = visible; //this menu item is only available for the function DefIL toolStripSeparator_DefIL.Visible = visible; }
void mniCopySymbolicIdentifier_Click(object sender, EventArgs e) { BaseTreeListTag treeListTag = _mainForm.treeList.FocusedNode.Tag as BaseTreeListTag; if (treeListTag != null) { treeListTag.CopySymbolicIdentfierToClipboard(); } }
void PasteIntoCell(TreeListNode node, TreeListColumn column, string value) { //account for the destination of the value to paste, i.e. to which column it should be pasted ... //... system column: i.e. either a parameter value or a switch of a policy or function if (TreeListBuilder.IsSystemColumn(column)) { BaseTreeListTag treeListTag = (node.Tag as BaseTreeListTag); DataSets.CountryConfig.SystemRow systemRow = (column.Tag as SystemTreeListTag).GetSystemRow(); if (!treeListTag.IsPermittedPasteValue(value, systemRow.ID)) { return; // e.g. trying to paste 'grumml' into a policy-switch } treeListTag.StoreChangedValue(value, systemRow); TreeListManager.UpdateIntelliAndTUBoxInfo((node.Tag as BaseTreeListTag).GetFunctionName(), column); } //... comment column: i.e. a comment (to a parameter, function or policy) else if (TreeListBuilder.IsCommentColumn(column)) { (node.Tag as BaseTreeListTag).SetComment(value); } //... policy column: ... else if (TreeListBuilder.IsPolicyColumn(column)) { //... an editable policy column belongs to a parameter and contains e.g. a component of an incomelist, the name of a constant/variable, etc. if ((node.Tag as BaseTreeListTag).IsPolicyColumnEditable()) { foreach (CountryConfig.ParameterRow parameterRow in (node.Tag as ParameterTreeListTag).GetParameterRows()) { parameterRow.Name = value; } } else { return; //no action if a policy-, function- or parameter-name } } //... group column: else if (TreeListBuilder.IsGroupColumn(column)) { //... an editable group column belongs to a parameter if ((node.Tag as BaseTreeListTag).IsGroupColumnEditable()) { foreach (CountryConfig.ParameterRow parameterRow in (node.Tag as ParameterTreeListTag).GetParameterRows()) { parameterRow.Group = value; } } else { return; //group column of policies and functions is not editable } } else { return; //does not happen } node.SetValue(column, value); //update nodes here to avoid having to redraw the tree (to enhance performance) }
internal static List <ExtensionOrGroup> GetExtensionDrawInfo(string cc, TreeListNode node) { if (CountryAdministrator.IsAddOn(cc) || node.Tag == null || node.Tag as BaseTreeListTag == null) { return(new List <ExtensionOrGroup>()); } BaseTreeListTag nodeTag = node.Tag as BaseTreeListTag; Dictionary <string, LookDef.STYLE> extIdsAndStyles = new Dictionary <string, LookDef.STYLE>(); foreach (CountryConfig.Extension_PolicyRow extPolRow in from ePol in GetCountryConfig(cc).Extension_Policy where ePol.PolicyID == nodeTag.GetDefaultPolicyRow().ID select ePol) { extIdsAndStyles.Add(extPolRow.ExtensionID, extPolRow.BaseOff ? LookDef.STYLE.EXTENSION_OFF : LookDef.STYLE.EXTENSION_ON); } if (nodeTag.GetDefaultFunctionRow() != null) { foreach (CountryConfig.Extension_FunctionRow extFunRow in from eFun in GetCountryConfig(cc).Extension_Function where eFun.FunctionID == nodeTag.GetDefaultFunctionRow().ID select eFun) { // function-setting with regard to BaseOff overwrites policy-setting (in fact only BaseOff=true may overwrite BaseOff=false, but this is not the point to check for observing this rule) if (extIdsAndStyles.ContainsKey(extFunRow.ExtensionID)) { extIdsAndStyles[extFunRow.ExtensionID] = extFunRow.BaseOff ? LookDef.STYLE.EXTENSION_OFF : LookDef.STYLE.EXTENSION_ON; } else { extIdsAndStyles.Add(extFunRow.ExtensionID, extFunRow.BaseOff ? LookDef.STYLE.EXTENSION_OFF : LookDef.STYLE.EXTENSION_ON); } } } if (nodeTag.GetDefaultParameterRow() != null) { foreach (CountryConfig.Extension_ParameterRow extParRow in from ePar in GetCountryConfig(cc).Extension_Parameter where ePar.ParameterID == nodeTag.GetDefaultParameterRow().ID select ePar) { // see overwriting rule above if (extIdsAndStyles.ContainsKey(extParRow.ExtensionID)) { extIdsAndStyles[extParRow.ExtensionID] = extParRow.BaseOff ? LookDef.STYLE.EXTENSION_OFF : LookDef.STYLE.EXTENSION_ON; } else { extIdsAndStyles.Add(extParRow.ExtensionID, extParRow.BaseOff ? LookDef.STYLE.EXTENSION_OFF : LookDef.STYLE.EXTENSION_ON); } } } List <ExtensionOrGroup> extensions = new List <ExtensionOrGroup>(); foreach (GlobLocExtensionRow e in GetExtensions(cc)) { if (extIdsAndStyles.ContainsKey(e.ID)) { extensions.Add(new ExtensionOrGroup(e, extIdsAndStyles[e.ID])); } } return(extensions); }
TreeListNode GetFunctionNode(TreeListNode parameterOrFunctionNode) { //get function node if menu was opened from a parameter node BaseTreeListTag treeListTag = parameterOrFunctionNode.Tag as BaseTreeListTag; if (treeListTag.GetDefaultParameterRow() == null) { return(parameterOrFunctionNode); } else { return(parameterOrFunctionNode.ParentNode); } }
internal override bool Execute(TreeListNode node) { BaseTreeListTag tag = node.Tag as BaseTreeListTag; foreach (string systemID in _systemIDs) { if (tag.GetID(systemID).ToLower() == _ID.ToLower()) { return(true); } } return(false); }
internal override bool Execute(TreeListNode senderNode) { BaseTreeListTag tag = senderNode.Tag as BaseTreeListTag; if (tag.GetDefaultParameterRow() != null) { return(parameterIDs.Contains(tag.GetDefaultParameterRow().ID)); } if (tag.GetDefaultFunctionRow() != null) { return(functionIDs.Contains(tag.GetDefaultFunctionRow().ID)); } return(policyIDs.Contains(tag.GetDefaultPolicyRow().ID)); }
private static void AddHiddenNode(ref List <string> hiddenNodes, TreeListNode node) { if (node.Visible || node.Tag == null) { return; } BaseTreeListTag tag = node.Tag as BaseTreeListTag; if (tag == null) { return; } hiddenNodes.AddUnique(tag.GetDefaultID(), true); }
private static void SetHiddenNode(List <string> hiddenNodes, TreeListNode node) { if (node.Tag == null) { return; } BaseTreeListTag tag = node.Tag as BaseTreeListTag; if (tag == null) { return; } if (hiddenNodes.Contains(tag.GetDefaultID(), true)) { node.Visible = false; // this assumes that ids do not change (which should actually be the case between country-close and reopen, and if not - not much harm done) } }
void mniPrivateComment_Click(object sender, EventArgs e) { if (_senderNode == null || _senderNode.Tag == null) { return; } BaseTreeListTag nodeTag = _senderNode.Tag as BaseTreeListTag; if (nodeTag == null) { return; } string existingPrivateComment = nodeTag.GetPrivateComment(); if (UserInput.Get("Insert/Edit Private Comment (for '" + _senderNode.GetDisplayText(_mainForm.GetTreeListBuilder().GetPolicyColumn()) + "')", out existingPrivateComment, existingPrivateComment, true) != DialogResult.Cancel) { nodeTag.SetPrivateComment(existingPrivateComment); } }
void GreyState(TreeListNode senderNode) { if (senderNode == null) { return; } BaseTreeListTag treeListTag = _mainForm.treeList.FocusedNode.Tag as BaseTreeListTag; bool isParameterNode = treeListTag.GetDefaultParameterRow() != null; mniDeleteParameter.Enabled = isParameterNode; mniDeleteFunction.ShortcutKeys = isParameterNode ? System.Windows.Forms.Keys.None : System.Windows.Forms.Keys.Delete; mniDeleteParameter.ShortcutKeys = isParameterNode ? System.Windows.Forms.Keys.Delete : System.Windows.Forms.Keys.None; mniMoveFunctionDown.Enabled = senderNode.NextNode != null; mniMoveFunctionUp.Enabled = senderNode.PrevNode != null; mniPasteFunctionAfter.Enabled = mniPasteFunctionBefore.Enabled = EM_AppContext.Instance.GetPasteFunctionAction() != null; mniPrivate.Enabled = !_mainForm._isAddOn; //the following is in fact not really correct (a reasonable copy of the selection is only possible if the function-name-cell lies within the selection and the selection contains editable cells) //it's aim is just to indicate that it is not possible to copy the values of the function with this menu (unless they are selected) mniCopyValues.Enabled = _mainForm.GetMultiCellSelector().HasSelection(); toolStripSeparator10.Enabled = !MultiCellSelector.IsClipboardEmpty(); mniGroups.Enabled = !_mainForm._isAddOn; mniExtensions.Enabled = !_mainForm._isAddOn; }
void mniDescriptionAsComment_Click(object sender, EventArgs e) { //a(ny) system is necessary to find out which incomelists (via DefIL), constants (via DefConst) and variables (via DefVar) are defined and to gather their descriptions TreeListColumn anySystemColumn = null; foreach (TreeListColumn column in _mainForm.treeList.Columns) { if (TreeListBuilder.IsSystemColumn(column)) { anySystemColumn = column; break; } } if (anySystemColumn == null || anySystemColumn.Tag == null) { return; } _mainForm.Cursor = Cursors.WaitCursor; Dictionary <string, string> descriptionsILVarConst = new Dictionary <string, string>(); //gather incomelists and their description in a dictionary to be applied below SystemTreeListTag systemTag = anySystemColumn.Tag as SystemTreeListTag; foreach (DataSets.CountryConfig.ParameterRow ilParameterRow in systemTag.GetParameterRowsILs()) { if (!descriptionsILVarConst.Keys.Contains(ilParameterRow.Value.ToLower())) { descriptionsILVarConst.Add(ilParameterRow.Value.ToLower(), systemTag.GetILTUComment(ilParameterRow)); } } foreach (DataSets.CountryConfig.ParameterRow parameterRow in systemTag.GetParameterRowsConstants()) { if (!descriptionsILVarConst.Keys.Contains(parameterRow.Name.ToLower())) { descriptionsILVarConst.Add(parameterRow.Name.ToLower(), parameterRow.Comment); } } foreach (DataSets.CountryConfig.ParameterRow parameterRow in systemTag.GetParameterRowsDefVariables()) { if (!descriptionsILVarConst.Keys.Contains(parameterRow.Name.ToLower())) { descriptionsILVarConst.Add(parameterRow.Name.ToLower(), parameterRow.Comment); } } //the necessary comment-changes must be gathered in an action-group (to allow for a common undo) ActionGroup actionGroup = new ActionGroup(); //loop over the parameters of the DefIL-function to put the respective descriptions of its components in the comment column BaseTreeListTag treeListTag = _mainForm.treeList.FocusedNode.Tag as BaseTreeListTag; TreeListNode functionNode = treeListTag.GetDefaultParameterRow() != null ? _mainForm.treeList.FocusedNode.ParentNode : _mainForm.treeList.FocusedNode; foreach (TreeListNode parameterNode in functionNode.Nodes) { CountryConfig.ParameterRow parameterRow = (parameterNode.Tag as ParameterTreeListTag).GetDefaultParameterRow(); string description = string.Empty; if (descriptionsILVarConst.Keys.Contains(parameterRow.Name.ToLower())) //component is an incomelist, variable or constant { description = descriptionsILVarConst[parameterRow.Name.ToLower()]; } else //component is a variable (defined in the variables description file) { description = EM_AppContext.Instance.GetVarConfigFacade().GetDescriptionOfVariable(parameterRow.Name, _mainForm.GetCountryShortName()); } if (description != string.Empty) { actionGroup.AddAction(new ChangeParameterCommentAction(parameterNode, description, true, _mainForm.GetTreeListBuilder().GetCommentColumn())); } //else: 'name' parameter, no description or unknown component } if (actionGroup.GetActionsCount() > 0) { _mainForm.PerformAction(actionGroup, false); } _mainForm.Cursor = Cursors.Default; }
private static Dictionary <string, Image> GetRelevantExtensionMenuItems(string cc, string menuItemName) { Dictionary <string, Image> relevantExtensions = new Dictionary <string, Image>(); bool globalOnly = menuItemName == MENU_EXTENSION_PRIVATE_ALL || menuItemName == MENU_EXTENSION_NOT_PRIVATE_ALL; // (1) add to extension: only show extensions which still can be added, i.e. where not already all selected elements belong to if (menuItemName == MENU_EXTENSION_ADDON || menuItemName == MENU_EXTENSION_ADDOFF) { foreach (GlobLocExtensionRow extRow in globalOnly ? ExtensionAndGroupManager.GetGlobalExtensions() : ExtensionAndGroupManager.GetExtensions(cc)) { bool canBeAdded = false; foreach (TreeListNode node in GetSelectedNodes(cc)) { if (CountryAdministrator.IsAddOn(cc) || node.Tag == null || node.Tag as BaseTreeListTag == null) { continue; } BaseTreeListTag nodeTag = node.Tag as BaseTreeListTag; if (nodeTag.GetDefaultParameterRow() != null) // means: if (isParameterRow) { if ((from ePar in GetCountryConfig(cc).Extension_Parameter where ePar.ExtensionID == extRow.ID && ePar.ParameterID == nodeTag.GetDefaultParameterRow().ID select ePar).Any()) { continue; // node belongs to extension } } if (nodeTag.GetDefaultFunctionRow() != null) // means: if (isFunctionRow || isParameterRow) { var ef = from eFun in GetCountryConfig(cc).Extension_Function where eFun.ExtensionID == extRow.ID && eFun.FunctionID == nodeTag.GetDefaultFunctionRow().ID select eFun; if (ef.Any()) { if (nodeTag.GetDefaultParameterRow() == null) { continue; // is actually function-node and belongs to extension } // a parameter-node can still be added as switch-off, if function-node is added as switch-on if (ef.First().BaseOff || menuItemName == MENU_EXTENSION_ADDON) { continue; } } } // means: if (isPolicyRow || isFunctionRow || isParameterRow) var ep = from ePol in GetCountryConfig(cc).Extension_Policy where ePol.ExtensionID == extRow.ID && ePol.PolicyID == nodeTag.GetDefaultPolicyRow().ID select ePol; if (ep.Any()) { if (nodeTag.GetDefaultParameterRow() == null && nodeTag.GetDefaultFunctionRow() == null) { continue; // is actually policy-node and belongs to extension } // a parameter- or function-node can still be added as switch-off, if policy-node is added as switch-on if (ep.First().BaseOff || menuItemName == MENU_EXTENSION_ADDON) { continue; } } canBeAdded = true; break; // node, nor parent nodes, do belong to extension: can be added } if (!canBeAdded) { continue; } ExtensionOrGroup eg = new ExtensionOrGroup(extRow); relevantExtensions.Add(eg.name, eg.look.GetMenuImage()); } } // (2) remove from extension: only show extensions which can be removed, i.e. where any of the selected elements belongs to else if (menuItemName == MENU_EXTENSION_REMOVE) { List <string> extIds = new List <string>(); foreach (TreeListNode node in GetSelectedNodes(cc)) { if (CountryAdministrator.IsAddOn(cc) || node.Tag == null || node.Tag as BaseTreeListTag == null) { continue; } BaseTreeListTag nodeTag = node.Tag as BaseTreeListTag; // "belongs to" means, that the function/parameter itself has to belong to the extension, not only the parent if (nodeTag.GetDefaultParameterRow() != null) // means: if (isParameterRow) { extIds.AddRange(from ePar in GetCountryConfig(cc).Extension_Parameter where ePar.ParameterID == nodeTag.GetDefaultParameterRow().ID select ePar.ExtensionID); } else if (nodeTag.GetDefaultFunctionRow() != null) // means: if (isFunctionRow) { extIds.AddRange(from eFun in GetCountryConfig(cc).Extension_Function where eFun.FunctionID == nodeTag.GetDefaultFunctionRow().ID select eFun.ExtensionID); } else // means: if (isPolicyRow) { extIds.AddRange(from ePol in GetCountryConfig(cc).Extension_Policy where ePol.PolicyID == nodeTag.GetDefaultPolicyRow().ID select ePol.ExtensionID); } } foreach (GlobLocExtensionRow gleRow in from e in globalOnly ? ExtensionAndGroupManager.GetGlobalExtensions() : ExtensionAndGroupManager.GetExtensions(cc) where extIds.Contains(e.ID) select e) { ExtensionOrGroup eg = new ExtensionOrGroup(gleRow); relevantExtensions.Add(eg.name, eg.look.GetMenuImage()); } } // (3) all other menu items (Expand,etc.): show all extensions else { foreach (GlobLocExtensionRow extRow in globalOnly ? ExtensionAndGroupManager.GetGlobalExtensions() : ExtensionAndGroupManager.GetExtensions(cc)) { ExtensionOrGroup eg = new ExtensionOrGroup(extRow); relevantExtensions.Add(eg.name, eg.look.GetMenuImage()); } } return(relevantExtensions.Any() ? relevantExtensions : new Dictionary <string, Image>() { { NO_ITEMS_DEFINED, null } }); }
private static Dictionary <string, Image> GetRelevantGroupMenuItems(string cc, string menuItemName) { Dictionary <string, Image> relevantGroups = new Dictionary <string, Image>(); // (1) add to group: only show groups which still can be added, i.e. where not already all selected elements belong to if (menuItemName == MENU_GROUP_ADD) { foreach (CountryConfig.LookGroupRow groupRow in GetCountryConfig(cc).LookGroup) { bool canBeAdded = false; foreach (TreeListNode node in GetSelectedNodes(cc)) { if (CountryAdministrator.IsAddOn(cc) || node.Tag == null || node.Tag as BaseTreeListTag == null) { continue; } BaseTreeListTag nodeTag = node.Tag as BaseTreeListTag; if (nodeTag.GetDefaultParameterRow() != null) // means: if (isParameterRow) { if ((from lgPar in GetCountryConfig(cc).LookGroup_Parameter where lgPar.LookGroupID == groupRow.ID && lgPar.ParameterID == nodeTag.GetDefaultParameterRow().ID select lgPar).Any()) { continue; // node belongs to group } } if (nodeTag.GetDefaultFunctionRow() != null) // means: if (isFunctionRow || isParameterRow) { if ((from lgFun in GetCountryConfig(cc).LookGroup_Function where lgFun.LookGroupID == groupRow.ID && lgFun.FunctionID == nodeTag.GetDefaultFunctionRow().ID select lgFun).Any()) { continue; // node belongs to group } } // means: if (isPolicyRow || isFunctionRow || isParameterRow) if ((from lgPol in GetCountryConfig(cc).LookGroup_Policy where lgPol.LookGroupID == groupRow.ID && lgPol.PolicyID == nodeTag.GetDefaultPolicyRow().ID select lgPol).Any()) { continue; // node belongs to group } canBeAdded = true; break; // node, nor parent nodes, do belong to group: can be added } if (!canBeAdded) { continue; } ExtensionOrGroup eg = new ExtensionOrGroup(groupRow); relevantGroups.Add(eg.name, eg.look.GetMenuImage()); } } // (2) remove from group: only show groups which can be removed, i.e. where any of the selected elements belongs to else if (menuItemName == MENU_GROUP_REMOVE) { List <string> lookGroupIds = new List <string>(); foreach (TreeListNode node in GetSelectedNodes(cc)) { if (CountryAdministrator.IsAddOn(cc) || node.Tag == null || node.Tag as BaseTreeListTag == null) { continue; } BaseTreeListTag nodeTag = node.Tag as BaseTreeListTag; // "belongs to" means, that the function/parameter itself has to belong to the group, not only the parent if (nodeTag.GetDefaultParameterRow() != null) // means: if (isParameterRow) { lookGroupIds.AddRange(from lgPar in GetCountryConfig(cc).LookGroup_Parameter where lgPar.ParameterID == nodeTag.GetDefaultParameterRow().ID select lgPar.LookGroupID); } else if (nodeTag.GetDefaultFunctionRow() != null) // means: if (isFunctionRow) { lookGroupIds.AddRange(from lgFun in GetCountryConfig(cc).LookGroup_Function where lgFun.FunctionID == nodeTag.GetDefaultFunctionRow().ID select lgFun.LookGroupID); } else // means: if (isPolicyRow) { lookGroupIds.AddRange(from lgPol in GetCountryConfig(cc).LookGroup_Policy where lgPol.PolicyID == nodeTag.GetDefaultPolicyRow().ID select lgPol.LookGroupID); } } foreach (CountryConfig.LookGroupRow groupRow in from lg in GetCountryConfig(cc).LookGroup where lookGroupIds.Contains(lg.ID) select lg) { ExtensionOrGroup eg = new ExtensionOrGroup(groupRow); relevantGroups.Add(eg.name, eg.look.GetMenuImage()); } } // (3) all other menu items (Expand,etc.): show all groups else { foreach (CountryConfig.LookGroupRow groupRow in GetCountryConfig(cc).LookGroup) { ExtensionOrGroup eg = new ExtensionOrGroup(groupRow); relevantGroups.Add(eg.name, eg.look.GetMenuImage()); } } return(relevantGroups.Any() ? relevantGroups : new Dictionary <string, Image>() { { NO_ITEMS_DEFINED, null } }); }
internal override bool Execute(TreeListNode senderNode) { BaseTreeListTag tag = senderNode.Tag as BaseTreeListTag; return(_nodeIDs.Contains(tag.GetDefaultID())); }
private bool IsDataRowNode(TreeListNode node, string rowID) { BaseTreeListTag tag = node.Tag as BaseTreeListTag; return(tag != null && tag.GetIDsWithinAllSystems().Contains(rowID)); }
List <IntelliItem> GetIntelliItems() { List <IntelliItem> intelliItems = new List <IntelliItem>(); intelliItems.Clear(); try { if (_treeList.FocusedNode.Tag == null) { return(intelliItems); //should not happen } BaseTreeListTag nodeTag = _treeList.FocusedNode.Tag as BaseTreeListTag; SystemTreeListTag systemTag = null; //first assess which intelli-items should be shown in dependece of the edited cell ... List <int> specficIntelliItems = null; if (TreeListBuilder.IsPolicyColumn(_treeList.FocusedColumn)) //editited cell is an exceptionally editable policy-column-cell (e.g. functions DefIL, DefConst, SetDefault, etc.) { //take system specific intelli-items (e.g. incomelists) from any existing system, as one cannot know for which system the user wants to define the parameter TreeListColumn anySystemColumn = _treeList.Columns.ColumnByName(nodeTag.GetDefaultPolicyRow().SystemRow.Name); if (anySystemColumn != null) { systemTag = anySystemColumn.Tag as SystemTreeListTag; } //in dependence of the function define the available intelli-items (e.g. only variables or variables and incomelists, etc.) specficIntelliItems = GetIntelliItemsForEditablePolicyColumn(nodeTag.GetDefaultFunctionRow().Name); } else if (TreeListBuilder.IsSystemColumn(_treeList.FocusedColumn)) { //in dependence of the parameter-value-type define the available intelli-items (usually everything, but e.g. for output_variables only variables) systemTag = _treeList.FocusedColumn.Tag as SystemTreeListTag; specficIntelliItems = nodeTag.GetTypeSpecificIntelliItems(systemTag); } else { return(intelliItems); //should not happen } //... then gather the respective intelli-items //constants defined by function DefConst if ((specficIntelliItems == null || specficIntelliItems.Contains(_intelliContainsDefConst)) && systemTag != null) { foreach (DataSets.CountryConfig.ParameterRow parameterRow in systemTag.GetParameterRowsConstants()) { if (parameterRow.Name.ToLower() == DefPar.DefVar.EM2_Var_Name.ToLower()) { intelliItems.Add(new IntelliItem(parameterRow.Value, parameterRow.Comment, _intelliImageConstant)); } else if (parameterRow.Name.ToLower() == DefPar.DefConst.Condition.ToLower()) { continue; } else { intelliItems.Add(new IntelliItem(parameterRow.Name, GetConstDescription(parameterRow) + " " + parameterRow.Comment, _intelliImageConstant)); } } } //variables defined by function DefVar if ((specficIntelliItems == null || specficIntelliItems.Contains(_intelliContainsDefVar)) && systemTag != null) { foreach (DataSets.CountryConfig.ParameterRow parameterRow in systemTag.GetParameterRowsDefVariables()) { if (parameterRow.Name.ToLower() == DefPar.DefVar.EM2_Var_Name.ToLower()) { intelliItems.Add(new IntelliItem(parameterRow.Value, parameterRow.Comment, _intelliImageVariable)); } else { intelliItems.Add(new IntelliItem(parameterRow.Name, parameterRow.Comment, _intelliImageVariable)); } } } // uprating factors if (specficIntelliItems == null || specficIntelliItems.Contains(_intelliContainsUpRateFactor)) { string cc = EM_AppContext.Instance.GetActiveCountryMainForm().GetCountryShortName(); CountryConfigFacade ccf = CountryAdministration.CountryAdministrator.GetCountryConfigFacade(cc); foreach (CountryConfig.UpratingIndexRow ur in ccf.GetUpratingIndices()) { intelliItems.Add(new IntelliItem(ur.Reference, ur.Description, _intelliImageConstant)); } } //standard variables defined in VarConfig (idhh, yem, poa, ...) if (specficIntelliItems == null || specficIntelliItems.Contains(_intelliContainsStandardVar)) { string countryShortName = systemTag == null ? string.Empty : systemTag.GetSystemRow().CountryRow.ShortName; Dictionary <string, string> standardVariables = EM_AppContext.Instance.GetVarConfigFacade().GetVariables_NamesAndDescriptions(countryShortName); foreach (string standardVariable in standardVariables.Keys) { intelliItems.Add(new IntelliItem(standardVariable, standardVariables[standardVariable], _intelliImageVariable)); } } //incomelists defined by function DefIL if ((specficIntelliItems == null || specficIntelliItems.Contains(_intelliContainsDefIL)) && systemTag != null) { foreach (DataSets.CountryConfig.ParameterRow parameterRow in systemTag.GetParameterRowsILs()) { intelliItems.Add(new IntelliItem(parameterRow.Value, systemTag.GetILTUComment(parameterRow), _intelliImageIL)); } } //queries (IsDepChild, ...) if (specficIntelliItems == null || specficIntelliItems.Contains(_intelliContainsQueries)) { foreach (var q in DefinitionAdmin.GetQueryNamesAndDesc()) { string queryName = q.Key, queryDesc = q.Value; intelliItems.Add(new IntelliItem(queryName, queryDesc, _intelliImageConfiguration)); //first add normally ... intelliItems.Add(new IntelliItem(_queryPrefix + queryName, //.. then add with query prefix to allow users to see all available queries (is removed before query is inserted) queryDesc, _intelliImageConfiguration)); } } //footnotes if (specficIntelliItems == null || specficIntelliItems.Contains(_intelliContainsFootnotes)) { //placeholders for new footnote parameters (#x1[_Level], #x2[_UpLim], etc.) Dictionary <string, string> footnotes = GetFootnoteParametersForIntelli(); foreach (string footnote in footnotes.Keys) { intelliItems.Add(new IntelliItem(footnote, footnotes[footnote], _intelliImageFootnote)); } //existing footnote amount parameters (#_Amount reverserd to Amount#x) footnotes = TreeListManager.GetFunctionsExistingAmountParameters(_treeList.FocusedNode.ParentNode, _treeList.FocusedColumn.GetCaption()); foreach (string footnote in footnotes.Keys) { intelliItems.Add(new IntelliItem(footnote, footnotes[footnote], _intelliImageFootnote)); } //other existing footnote parameters (#_Level, #_UpLim, etc.) footnotes = TreeListManager.GetFunctionsExistingFootnoteParameters(_treeList.FocusedNode.ParentNode, _treeList.FocusedColumn.GetCaption()); foreach (string footnote in footnotes.Keys) { intelliItems.Add(new IntelliItem(footnote, footnotes[footnote], _intelliImageFootnote)); } } if (specficIntelliItems == null || specficIntelliItems.Contains(_intelliContainsRandAbsMinMax)) { intelliItems.Add(new IntelliItem("rand", "Random number", _intelliImageConfiguration)); intelliItems.Add(new IntelliItem("<abs>()", "Absolute value operator", _intelliImageConfiguration)); intelliItems.Add(new IntelliItem("<min> ", "Minimum operator", _intelliImageConfiguration)); intelliItems.Add(new IntelliItem("<max> ", "Maximum operator", _intelliImageConfiguration)); } // special case for parameter DefTU/Members: show the options, e.g. Partner, OwnDepChild, ... if (specficIntelliItems != null && specficIntelliItems.Contains(_intelliContainsDefTUMembers)) { ParameterTreeListTag parTag = nodeTag as ParameterTreeListTag; if (parTag != null) { foreach (string tuMember in new List <string>() { DefPar.DefTu.MEMBER_TYPE.PARTNER_CAMEL_CASE, DefPar.DefTu.MEMBER_TYPE.OWNCHILD_CAMEL_CASE, DefPar.DefTu.MEMBER_TYPE.DEPCHILD_CAMEL_CASE, DefPar.DefTu.MEMBER_TYPE.OWNDEPCHILD_CAMEL_CASE, DefPar.DefTu.MEMBER_TYPE.LOOSEDEPCHILD_CAMEL_CASE, DefPar.DefTu.MEMBER_TYPE.DEPPARENT_CAMEL_CASE, DefPar.DefTu.MEMBER_TYPE.DEPRELATIVE_CAMEL_CASE }) { intelliItems.Add(new IntelliItem(tuMember, string.Empty, _intelliImageConfiguration)); } } } //taxunits defined by function DefTU: only for add-ons, which use formulas for all parameters (i.e. also for taxunit parameters) if ((_treeList.Parent as EM_UI_MainForm)._isAddOn && systemTag != null) { foreach (DataSets.CountryConfig.ParameterRow parameterRow in systemTag.GetParameterRowsTUs()) { intelliItems.Add(new IntelliItem(parameterRow.Value, systemTag.GetILTUComment(parameterRow), _intelliImageTU)); } } return(intelliItems); } catch { //do not jeopardise the UI-stability because IntelliItems cannot be gathered but try if problem can be fixed by updating the info UpdateInfo(); return(intelliItems); } List <int> GetIntelliItemsForEditablePolicyColumn(string functionName) { functionName = functionName.ToLower(); List <int> items = new List <int>(); if (functionName == DefFun.SetDefault.ToLower() || functionName == DefFun.Uprate.ToLower()) { items.Add(_intelliContainsStandardVar); items.Add(_intelliContainsDefVar); //not sure whether variables defined by DefVar should be displayed (?) } if (functionName == DefFun.DefIl.ToLower()) { items.Add(_intelliContainsStandardVar); items.Add(_intelliContainsDefVar); items.Add(_intelliContainsDefConst); items.Add(_intelliContainsDefIL); } //other functions with editable policy column (DefConst, DefVar): no intelliItems (i.e. no suggestions for e.g. constant names) return(items); } }