} //parameter: some basic checking if user input corresponds with type of parameter //handling for function and policies, parameter has its own handling (described there) internal virtual void HandleValueChanged(TreeListNode node, TreeListColumn column, string value) { if (value == TreeListManagement.TreeListManager.NA_ALL_COMPONENTS) { return; //'n/a (all components)' has a special handling (see HandleSwitchToNAallComponents) } _mainForm.PerformAction(new ChangeParameterValueAction(node, column, value), false, false); //set switch of function/policy }
// used as call-back-function by the ribbon-buttons and called by call-back-functions of the policy/function-context-menus internal static void MenuItemClicked(EM_UI_MainForm mainForm, string groupOrExtensionName) { if (groupOrExtensionName == NO_ITEMS_DEFINED) { return; } string cc = mainForm.GetCountryShortName(); switch (selectedMenu) // ... the parent-menu was stored on opening the group-sub-menu in the variable selectedMenu { case MENU_GROUP_ADD: mainForm.PerformAction(new GroupAddContentAction(cc, groupOrExtensionName), false); break; case MENU_EXTENSION_ADDON: mainForm.PerformAction(new ExtensionAddContentAction(cc, mainForm, groupOrExtensionName, true), false); break; case MENU_EXTENSION_ADDOFF: mainForm.PerformAction(new ExtensionAddContentAction(cc, mainForm, groupOrExtensionName, false), false); break; case MENU_GROUP_REMOVE: mainForm.PerformAction(new GroupRemoveContentAction(cc, groupOrExtensionName), false); break; case MENU_EXTENSION_REMOVE: mainForm.PerformAction(new ExtensionRemoveContentAction(cc, mainForm, groupOrExtensionName), false); break; case MENU_GROUP_EXPAND: VisualiseMenuOperation(mainForm: mainForm, egName: groupOrExtensionName, extensionOnOnly: null, setVisible: null, expand: true); break; case MENU_EXTENSION_EXPAND: VisualiseMenuOperation(mainForm: mainForm, egName: groupOrExtensionName, extensionOnOnly: false, setVisible: null, expand: true); break; case MENU_GROUP_VISIBLE: VisualiseMenuOperation(mainForm: mainForm, egName: groupOrExtensionName, extensionOnOnly: null, setVisible: true, expand: false); break; case MENU_EXTENSION_VISIBLE: VisualiseMenuOperation(mainForm: mainForm, egName: groupOrExtensionName, extensionOnOnly: true, setVisible: true, expand: false); break; case MENU_GROUP_NOT_VISIBLE: VisualiseMenuOperation(mainForm: mainForm, egName: groupOrExtensionName, extensionOnOnly: null, setVisible: false, expand: false); break; case MENU_EXTENSION_NOT_VISIBLE: VisualiseMenuOperation(mainForm: mainForm, egName: groupOrExtensionName, extensionOnOnly: true, setVisible: false, expand: false); break; case MENU_EXTENSION_PRIVATE_COUNTRY: SetExtensionPrivateCountry(cc: cc, mainForm: mainForm, extName: groupOrExtensionName, set: true); break; case MENU_EXTENSION_NOT_PRIVATE_COUNTRY: SetExtensionPrivateCountry(cc: cc, mainForm: mainForm, extName: groupOrExtensionName, set: false); break; case MENU_EXTENSION_PRIVATE_ALL: SetExtensionPrivateGlobal(extName: groupOrExtensionName, set: true); break; case MENU_EXTENSION_NOT_PRIVATE_ALL: SetExtensionPrivateGlobal(extName: groupOrExtensionName, set: false); break; default: break; } }
void mniAddFunction_Click(object senderMenuItem, EventArgs e) { TreeListNode senderNode = (senderMenuItem as ToolStripMenuItem).Tag as TreeListNode; //add the function AddFunctionAction action = new AddFunctionAction(_mainForm, senderNode, senderMenuItem.ToString(), _mainForm.GetTreeListManager().GetIDsOfHiddenSystems()); _mainForm.PerformAction(action, false); //after redrawing treeview expand whatever is necessary to make the new function visible _mainForm.GetTreeListBuilder().ExpandSpecificNode(action.GetAddedFunctionsIDs()); }
void mnuPolicyTypes_Click(object senderMenuItem, EventArgs e) { string policyType = senderMenuItem.ToString(); //benefit, tax, sic, etc. if (_clickedMainMenu == mniAddPolicyBefore.Name) //ActMainMenu is set in PolMenI_xxx_DropDownOpened { _mainForm.PerformAction(new AddPolicyAction(_mainForm, _mainForm.treeList.FocusedNode, policyType, true, _mainForm.GetTreeListManager().GetIDsOfHiddenSystems()), false); } else if (_clickedMainMenu == mniAddPolicyAfter.Name) { _mainForm.PerformAction(new AddPolicyAction(_mainForm, _mainForm.treeList.FocusedNode, policyType, false, _mainForm.GetTreeListManager().GetIDsOfHiddenSystems()), false); } else if (_clickedMainMenu == mniChangePolicyType.Name) { _mainForm.PerformAction(new ChangePolicyTypeAction(_mainForm.treeList.FocusedNode, policyType)); } _clickedMainMenu = string.Empty; }
void mniPasteValues_Click(object sender, EventArgs e) { if (_senderColumn == null || _senderNode == null) { return; } _mainForm.treeList.FocusedNode = _senderNode; _mainForm.treeList.FocusedColumn = _senderColumn; _mainForm.PerformAction(new PasteMultiValuesAction(_mainForm), false); }
internal void RedrawTreeForPolicyView() { BaseAction action = new BaseAction(); action.SetNoCommitAction(); _mainForm.PerformAction(action); //update tree without performing commit if (_mainForm.treeList.Nodes.Count == 1) { _mainForm.treeList.Nodes[0].ExpandAll(); //expand the single policy in single-policy-view _mainForm.treeList.TopVisibleNodeIndex = 0; //to avoid that, due to a previous scrolling position, some middle- or end-part of the policy is shown } }
void btnOK_Click(object sender, EventArgs e) { if (!verifyNumericValues()) { UserInfoHandler.ShowError("Cell(s) with invalid value found!"); } else if (!haveEmptyCells() || UserInfoHandler.GetInfo("Empty cell(s) found; they will be treated as n/a when running the model." + Environment.NewLine + "Do you want to correct?", MessageBoxButtons.YesNo) == DialogResult.No) { mainForm.PerformAction(new IndirectTaxesAction(this), false); DialogResult = DialogResult.OK; Close(); } }
internal static void SetSelectionPrivate(EM_UI_MainForm mainForm) { List <TreeListNode> selectedNodes = new List <TreeListNode>(); TreeListNode focusedNode = mainForm.treeList.FocusedNode; if (mainForm.GetMultiCellSelector().HasSelection() && (focusedNode == null || mainForm.GetMultiCellSelector().GetSelectedNodes().Contains(focusedNode))) { selectedNodes.AddRange(mainForm.GetMultiCellSelector().GetSelectedNodes()); } else { selectedNodes.Add(focusedNode); } mainForm.PerformAction(new SetSelectionPrivateStateAction(selectedNodes), false); }
private static void SetExtensionPrivateCountry(string cc, EM_UI_MainForm mainForm, string extName, bool set) { bool isLocal = (from e in GetDataConfig(cc).Extension where e.Name.ToLower() == extName.ToLower() || e.ID == extName select e).Any(); if (!isLocal) { switch (UserInfoHandler.GetInfo("Do you want to perform this private-setting-action for all countries? Click" + Environment.NewLine + "'Yes' to perform the action for all countries" + "," + Environment.NewLine + "'No' to perform the action only for " + cc + ".", MessageBoxButtons.YesNoCancel)) { case DialogResult.Cancel: return; case DialogResult.Yes: SetExtensionPrivateGlobal(extName, set); return; case DialogResult.No: break; } } mainForm.PerformAction(new ExtensionSetPrivateAction(extName, cc, set)); }
void btnOK_Click(object sender, EventArgs e) { if (verifyNumericValues()) { _mainForm.PerformAction(new UpratingIndicesAction(this), false); if (haveEmptyCells()) { MessageBox.Show("Warning: one or more factor series have empty cells; a value of " + _factorValueInvalid + " will be used for these empty cells when running the model."); } StoreHICPInGlobalTable(); DialogResult = DialogResult.OK; Close(); } else { MessageBox.Show("There are cells with invalid values!"); } }
void btnApply_Click(object sender, EventArgs e) { List <DataGridViewRow> selectedRows = GetSelectedRows(); if (selectedRows.Count == 0) { return; } ActionGroup actionGroup = new ActionGroup(); List <KeyValuePair <string, string> > conflictParameters = new List <KeyValuePair <string, string> >(); //helper list for dedecting conflicts à la comp_perElig[grp1]/comp_perTU[grp1] foreach (DataGridViewRow selectedRow in selectedRows) { string countAsString = selectedRow.Cells[colCount.Index].Value == null ? "0" : selectedRow.Cells[colCount.Index].Value.ToString(); uint count = (countAsString != string.Empty && EM_Helpers.IsNonNegInteger(countAsString)) ? Convert.ToUInt32(countAsString) : 1; var gon = selectedRow.Cells[colGroupNo.Index].Value; string groupOrNo = gon == null? string.Empty : gon.ToString(); string initialGroupOrNo = groupOrNo; string substitute = selectedRow.Cells[colReplaces.Index].Value.ToString(); if (substitute != string.Empty) { actionGroup.AddAction(new ChangeParameterNameAction((selectedRow.Tag as AddParameterTag)._parameterNode, selectedRow.Cells[colParameter.Index].Value.ToString())); continue; } for (uint index = 0; index < count; ++index) { DefinitionAdmin.Par parDef = (selectedRow.Tag as AddParameterTag)._parDef; DefinitionAdmin.ParGroup parGroup = (selectedRow.Tag as AddParameterTag)._parGroup; string parName = (selectedRow.Tag as AddParameterTag)._parName; if (parDef.maxCount == 1 && (parGroup == null || parGroup.maxCount == 1) && count > 1) { count = 1; //if parameter is "single" make sure it is only added once! } if (groupOrNo != string.Empty) //group- or footnote-parameter { if (EM_Helpers.IsNonNegInteger(groupOrNo)) { groupOrNo = (EM_Helpers.SaveConvertToInt(initialGroupOrNo) + index).ToString(); } if (CountryConfigFacade.DoesParameterExist(_displayedFunctionRow, parName, groupOrNo)) {//may happen if user changes group or footnote number manually UserInfoHandler.ShowError($"Parameter {parName} with Grp/No {groupOrNo} already exists. " + "Please consider Grp/No and/or whether there is a conflict parameter."); return; } } if (parDef.substitutes.Count > 0) { foreach (string conflictPar in parDef.substitutes) { if (conflictParameters.Contains(new KeyValuePair <string, string>(conflictPar.ToLower(), groupOrNo))) {//trying to add e.g. comp_perElig and comp_perTU with same group or output_var and output_add_var string groupMessage = groupOrNo != string.Empty ? " with identical group " + groupOrNo : string.Empty; UserInfoHandler.ShowError($"Cannot add parameter {parName} and parameter {conflictPar} {groupMessage}, as they are subsitudes."); return; } } conflictParameters.Add(new KeyValuePair <string, string>(parName.ToLower(), groupOrNo)); } if ((_focusedNode.Tag as BaseTreeListTag).GetDefaultParameterRow() == null) { //if the dialog was opened via the function context menu, parameters are added at the end of the function //thus they can be added simply one after the other, without changing the order ... actionGroup.AddAction(new AddParameterAction(_focusedNode, parName, parDef, groupOrNo)); } else { //if the dialog was opened via the parameter context menu, parameters are added after the selected parameter //thus they have to be added in reverted order to keep the given order actionGroup.InsertAction(0, new AddParameterAction(_focusedNode, parName, parDef, groupOrNo)); } } } _inApplyAction = true; TreeListNode functionNode = (_focusedNode.Tag as BaseTreeListTag).GetDefaultParameterRow() == null ? _focusedNode : _focusedNode.ParentNode; EM_UI_MainForm mainForm = EM_AppContext.Instance.GetCountryMainForm(_displayedFunctionRow.PolicyRow.SystemRow.CountryRow.ShortName); mainForm.PerformAction(actionGroup, true, false, functionNode); //performance optimisation Aug 13: update only the concerned function instead of the whole tree _inApplyAction = false; UpdateContent(functionNode); }
void InsertFirstSystem_MenuItemClick(object sender, EventArgs e) { _mainForm.PerformAction(new CopySystemAction( CountryAdministrator.GetCountryConfigFacade(_mainForm.GetCountryShortName()), _mainForm._isAddOn), true, true); }