internal static void LoadAndDrawBookmarks(EM_UI_MainForm mainForm) { try { foreach (string bookmark in EM_AppContext.Instance.GetUserSettingsAdministrator().GetBookmarks()) { string[] parts = bookmark.Split(';'); if (bookmark.StartsWith(mainForm.GetCountryShortName())) { TreeListNode node = mainForm.GetTreeListManager().GetSpecifiedNode(parts[1]); if (node != null) { mainForm.DrawBookmark(parts[2], parts[1], node); } } } } catch (Exception exception) { DeleteBookmarks(mainForm.GetCountryShortName()); //try to delete the bookmarks, so that they do not cause further problems in e.g. adding new ones //do nothing (does not seem important enough to jeopardise loading of the whole country or any other relevant action) Tools.UserInfoHandler.RecordIgnoredException("BookmarkAndColorManager.LoadAndDrawBookmarks", exception); } }
internal static Dictionary <string, string> GetSystemAssignement(EM_UI_MainForm copyCountryMainForm, EM_UI_MainForm pasteCountryMainForm, List <string> pasteCountryHiddenSystems) { Dictionary <string, string> pasteSystemsNamesAndIDs = new Dictionary <string, string>(); Dictionary <string, string> copySystemNamesAndIDs = new Dictionary <string, string>(); foreach (CountryConfig.SystemRow systemRow in CountryAdministrator.GetCountryConfigFacade(pasteCountryMainForm.GetCountryShortName()).GetSystemRows()) { if (!pasteCountryHiddenSystems.Contains(systemRow.ID)) { pasteSystemsNamesAndIDs.Add(systemRow.Name, systemRow.ID); } } foreach (CountryConfig.SystemRow systemRow in CountryAdministrator.GetCountryConfigFacade(copyCountryMainForm.GetCountryShortName()).GetSystemRows()) { copySystemNamesAndIDs.Add(systemRow.Name, systemRow.ID); } AssignSystemsForm assignSystemsForm = new AssignSystemsForm(pasteCountryMainForm.GetCountryShortName(), pasteSystemsNamesAndIDs, copyCountryMainForm.GetCountryShortName(), copySystemNamesAndIDs); if (assignSystemsForm.ShowDialog() == DialogResult.Cancel) { return(null); } return(assignSystemsForm.GetSystemAssignment()); }
internal abstract void CopySymbolicIdentfierToClipboard(); //copy the symbolic identifier of a policy (=policy name), function (e.g. yse_#3) or parameter (e.g. yse_#3.4) to the clipboard internal virtual void CopyIdentfierToClipboard() //copy the real (system specific) identifier of a policy, function or parameter to the clipboard { SelectSystemsForm selectSystemsForm = new SelectSystemsForm(_mainForm.GetCountryShortName(), null, true); selectSystemsForm.SetSingleSelectionMode(); if (selectSystemsForm.ShowDialog() == DialogResult.Cancel) { return; } if (selectSystemsForm.IsAllSystemsSelected()) { string clipboardText = string.Empty; foreach (TreeListColumn column in (from col in _mainForm.GetTreeListBuilder().GetSystemColums() where col.VisibleIndex >= 0 select col).OrderBy(col => col.VisibleIndex)) { clipboardText += GetID((column.Tag as SystemTreeListTag).GetSystemRow().ID) + "\t"; } ; clipboardText = clipboardText.TrimEnd('\t'); System.Windows.Forms.Clipboard.SetText(clipboardText); } else if (selectSystemsForm.GetSelectedSystemRows().Count > 0) { System.Windows.Forms.Clipboard.SetText(GetID(selectSystemsForm.GetSelectedSystemRows().First().ID)); } }
// 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; } }
internal static bool RestoreCountry(EM_UI_MainForm mainForm, string backUpFolder = "") { bool reportSuccess = false; if (backUpFolder == string.Empty) //called via button in MainForm { FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); folderBrowserDialog.SelectedPath = EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles); folderBrowserDialog.Description = "Please select the back-up folder"; if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { return(true); } backUpFolder = folderBrowserDialog.SelectedPath; reportSuccess = true; } else //called from a catch-branch, i.e. using just generated back-up in Temp/BackUp { backUpFolder = EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles) + backUpFolder; } string countryShortName = mainForm.GetCountryShortName(); bool isAddOn = CountryAdministrator.IsAddOn(countryShortName); try { //check if backUpFolder contains the necessary files and if the files actually contain a backup of the loaded country/add-on ... string errorMessage; if (!Country.DoesFolderContainValidXMLFiles(countryShortName, out errorMessage, backUpFolder, isAddOn, true)) //check if countryShortName corresponds to country's short name as stored in the XML-file { throw new System.ArgumentException(errorMessage); } //... if yes, copy files form backup-folder to Countries-folder if (!Country.CopyXMLFiles(countryShortName, out errorMessage, backUpFolder)) { throw new System.ArgumentException(errorMessage); } mainForm.ReloadCountry(); if (reportSuccess) //report success only if called via button (and not if called by a failed function) { UserInfoHandler.ShowSuccess("Successfully restored using back-up stored in" + Environment.NewLine + backUpFolder + "."); } return(true); } catch (Exception exception) { UserInfoHandler.ShowError("Restore failed because of the error stated below." + Environment.NewLine + "You may want to try a manual restore via the button in the ribbon 'Country Tools'." + Environment.NewLine + Environment.NewLine + exception.Message); return(false); } }
internal static void StoreSettings(EM_UI_MainForm mainForm) { if (!keepMode) { return; } CountryViewSetting setting = new CountryViewSetting(); string cc = mainForm.GetCountryShortName(); try { foreach (TreeListColumn col in mainForm.treeList.Columns) { setting.systemWidths.Add(col.Caption, col.Width); if (!col.Visible) { setting.hiddenSystems.AddUnique(col.Caption, true); } } foreach (TreeListNode polNode in mainForm.treeList.Nodes) { AddHiddenNode(ref setting.hiddenNodes, polNode); foreach (TreeListNode funcNode in polNode.Nodes) { AddHiddenNode(ref setting.hiddenNodes, funcNode); foreach (TreeListNode parNode in funcNode.Nodes) { AddHiddenNode(ref setting.hiddenNodes, parNode); } } } if (mainForm.GetTreeListBuilder() != null) { setting.textSize = mainForm.GetTreeListBuilder().GetTextSize(); } if (countryViewSettings.ContainsKey(cc)) { countryViewSettings[cc] = setting; } else { countryViewSettings.Add(cc, setting); } } catch (Exception exception) { UserInfoHandler.ShowException(exception, "Failed to store view settings for " + cc + ". Settings are set back to default.", false); if (countryViewSettings.ContainsKey(cc)) { countryViewSettings.Remove(cc); } } }
internal static string StoreCountry(EM_UI_MainForm mainForm, bool storeChanges = true) { CleanBackupFolder(); //delete all folders which are older than 3 days to avoid that the backup folder gets too big //outcommented as it is probably more confusing to inform the user than that one cannot undo actions before this (probably big) action ... //if (undoManager.HasChanges() && Tools.UserInfoHandler.GetInfo("Please note that the action generates a backup and therefore must reset the undo list. That means no undoing of actions up until now will be possible.", // MessageBoxButtons.OKCancel) == DialogResult.Cancel) // return false; //... instead pose this easier to understand question (i.e. only ask for saving unsaved changes, but not for any undo-stuff) if (storeChanges && mainForm.HasChanges() && Tools.UserInfoHandler.GetInfo("Do you want to save changes?", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return(string.Empty); } try { //the action will directly operate the XML-files therefore changes need to be commited and saved, unless explicitly not wished if (storeChanges) { SaveDirectXMLAction(mainForm); } //create a backup by copying files from Countries-folder to a dated folder (see below) in BackUps-folder if (!Directory.Exists(EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles))) { Directory.CreateDirectory(EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles)); } string countryShortName = mainForm.GetCountryShortName(); string backUpFolder = countryShortName + "_" + DateTime.Now.ToString("yyyy-MM-dd_H-mm-ss"); //backup-folder is name e.g. uk_2013-12-08_10-30-23 if (!Directory.Exists(EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles) + backUpFolder)) //is actually rather unlikely { Directory.CreateDirectory(EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles) + backUpFolder); } //copy XML-files (e.g. uk.xml + uk_DataConfig.xml or LMA.xml) string errorMessage; if (!Country.CopyXMLFiles(countryShortName, out errorMessage, string.Empty, EMPath.AddSlash(EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles) + backUpFolder))) { throw new System.ArgumentException(errorMessage); } return(backUpFolder); } catch (Exception exception) { UserInfoHandler.ShowException(exception); return(string.Empty); } }
internal static void SaveDirectXMLAction(EM_UI_MainForm mainForm) { string countryShortName = mainForm.GetCountryShortName(); CountryAdministrator.GetCountryConfigFacade(countryShortName).GetCountryConfig().AcceptChanges(); if (!CountryAdministrator.IsAddOn(countryShortName)) { CountryAdministrator.GetDataConfigFacade(countryShortName).GetDataConfig().AcceptChanges(); } mainForm.GetUndoManager().Reset(); //reset undo-manager with the drawback that actions up until now cannot be undone lock (EM_UI_MainForm._performActionLock) //to not get into conflict with auto-saving { CountryAdministrator.WriteXML(countryShortName); } }
private static void VisualiseMenuOperation(EM_UI_MainForm mainForm, string egName, bool?extensionOnOnly, bool?setVisible, bool expand) { string cc = mainForm.GetCountryShortName(); IsSpecificBase specificationOperation; if (extensionOnOnly == null) { specificationOperation = new IsGroupMember(GetCountryConfig(cc), egName); } else { specificationOperation = new IsExtensionMember(GetCountryConfig(cc), GetDataConfig(cc), egName, extensionOnOnly == true ? true : false); } mainForm.treeList.NodesIterator.DoOperation(new TreatSpecificNodes( isSpecific: specificationOperation, treatment: null, visualiseTreated: expand, expandTreated: expand, setVisibleTreated: setVisible | expand)); }
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; }
internal void RemoveCountryMainForm(EM_UI_MainForm countryMainForm) { if (countryMainForm == _emptyForm) { StoreViewSettings(); return; //close button was clicked in the empty form: no need to remove anything, just let the empty form (and therewith the application) close } if (_pasteFunctionAction != null && _pasteFunctionAction.GetCopyCountryShortName().ToLower() == countryMainForm.GetCountryShortName().ToLower()) { _pasteFunctionAction = null; } if (_pastePolicyAction != null && _pastePolicyAction.GetCopyCountryShortName().ToLower() == countryMainForm.GetCountryShortName().ToLower()) { _pastePolicyAction = null; } _countryMainForms.Remove(countryMainForm); //close application or show empty form if last country is closed if (_countryMainForms.Count == 0) { if (_userSettingsAdministrator.Get().CloseInterfaceWithLastMainform == DefPar.Value.NO) { ShowEmptyForm(true); } else { StoreViewSettings(); _emptyForm.Close(); //this is the last form open (currently hidden, as a country was open), the means the application will close as well } } //this might not be necessary: I first thought that the application closes if this.MainForm closes (which would make the code necessary to prevent closing) //testing proofed that this is not true, however I observed (and could not reproduce) that the application closed with closing "some", but not the last MainForm //I guess the code should do no harm and help to be on the save side ... else if (countryMainForm == this.MainForm) { this.MainForm = _emptyForm; //in this context note that this.MainForm is set in EM_UI_MainForm.EM_UI_MainForm_Activated (also see GetActiveCountryMainForm) } }
internal UpratingIndicesForm(EM_UI_MainForm mainForm) { InitializeComponent(); try { _mainForm = mainForm; _countryConfigFacade = EM_UI.CountryAdministration.CountryAdministrator.GetCountryConfigFacade(_mainForm.GetCountryShortName()); _dataConfigFacade = EM_UI.CountryAdministration.CountryAdministrator.GetDataConfigFacade(_mainForm.GetCountryShortName()); dgvDataSet.Tables.Add(dgvDataTable); dgvIndices.DataSource = dgvDataSet; dgvIndices.DataMember = "dgvDataTable"; //load the information for the 'Raw Indices' tab LoadIndices(); //load the information for the 'Factors per Data and System' tab ... //... datasets (for selection by the user) foreach (DataConfig.DataBaseRow dataSet in _dataConfigFacade.GetDataBaseRows()) { cmbDatasets.Items.Add(dataSet.Name); } //... and systems (for the table) foreach (CountryConfig.SystemRow system in _countryConfigFacade.GetSystemRowsOrdered()) { bool showSystem = false; foreach (DevExpress.XtraTreeList.Columns.TreeListColumn c in mainForm.treeList.VisibleColumns) { showSystem = showSystem || (c.Name.ToLower() == system.Name.ToLower()); } if (showSystem) { DataGridViewColumn headerColumn = colIndexName.Clone() as DataGridViewColumn; //clone the factorname-column to overtake the settings headerColumn.Name = system.ID; //to be able to identify each system column, when the table is filled headerColumn.HeaderText = system.Name; int index = dgvFactors.Columns.Add(headerColumn); dgvFactors.Columns[index].Tag = system; } } // only after all the data is loaded, add the row numbers and the refresh listeners dgvIndices.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders; dgvIndices.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(dgvIndices_RefreshRowNumbers); dgvIndices.RowsRemoved += new System.Windows.Forms.DataGridViewRowsRemovedEventHandler(dgvIndices_RefreshRowNumbers); dgvIndices_RefreshRowNumbers(null, null); colIndexDescription.Frozen = true; colReference.Frozen = true; // colComment.Frozen = true; // this can only happen if it is not the last row! } catch (Exception exception) { UserInfoHandler.ShowException(exception); } }
void GreyState(TreeListNode senderNode) { if (senderNode == null) { return; } bool singlePolicyView = (_mainForm != null && _mainForm.GetTreeListBuilder() != null && _mainForm.GetTreeListBuilder().SinglePolicyView); mniMovePolicyDown.Enabled = senderNode.NextNode != null && !singlePolicyView; mniMovePolicyUp.Enabled = senderNode.PrevNode != null && !singlePolicyView; mniPastePolicyAfter.Enabled = mniPastePolicyBefore.Enabled = EM_AppContext.Instance.GetPastePolicyAction() != null && !singlePolicyView; mniPasteReferenceBefore.Enabled = mniPasteReferenceAfter.Enabled = !_mainForm._isAddOn && EM_AppContext.Instance.GetPastePolicyAction() != null && EM_AppContext.Instance.GetPastePolicyAction().GetCopyCountryShortName() == _mainForm.GetCountryShortName() && !singlePolicyView; mniPasteFunction.Enabled = EM_AppContext.Instance.GetPasteFunctionAction() != null && !PolicyTreeListTag.IsReferencePolicy(senderNode); mniCopyPolicy.Enabled = !PolicyTreeListTag.IsReferencePolicy(senderNode); mniRenamePolicy.Enabled = !PolicyTreeListTag.IsReferencePolicy(senderNode); mniChangePolicyType.Enabled = !PolicyTreeListTag.IsReferencePolicy(senderNode); mniPrivate.Enabled = !_mainForm._isAddOn; mniGoToReferredPolicy.Enabled = PolicyTreeListTag.IsReferencePolicy(senderNode); mniAddPolicyAfter.Enabled = !singlePolicyView; mniAddPolicyBefore.Enabled = !singlePolicyView; mniDeletePolicy.Enabled = !singlePolicyView; //the following is in fact not really correct (a reasonable copy of the selection is only possible if the policy-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 policy with this menu (unless they are selected) mniCopyValues.Enabled = _mainForm.GetMultiCellSelector().HasSelection(); mniPasteValues.Enabled = !MultiCellSelector.IsClipboardEmpty(); if (_mniAddFunction == null) { return; } _mniAddFunction.Enabled = !PolicyTreeListTag.IsReferencePolicy(senderNode); mniGroups.Enabled = !_mainForm._isAddOn; mniExtensions.Enabled = !_mainForm._isAddOn; }
internal void PolicySelectMenu_ItemSelected(CountryConfig.PolicyRow policyRow) { try { if (policyRow == null) //user selected menu item "Full Spine" { PolicyViewChanged(false); return; } CountryConfigFacade countryConfigFacade = CountryAdministration.CountryAdministrator.GetCountryConfigFacade(_mainForm.GetCountryShortName()); if (_singlePolicyView) //in single-poliy-view: display the selected policy as "the" policy { _idsDisplayedSinglePolicy.Clear(); //need to gather policy-ids of all systems as the FillTreeList function has just one of them foreach (string systemID in GetSystemIDs()) { System.Data.DataRow twinRow = CountryConfigFacade.GetTwinRow(policyRow, systemID); if (twinRow != null && (twinRow as CountryConfig.PolicyRow) != null) { _idsDisplayedSinglePolicy.Add((twinRow as CountryConfig.PolicyRow).ID); } } RedrawTreeForPolicyView(); //update the tree to realise the selected view } else //in full-spine-view: jump to the selected policy { foreach (TreeListNode policyNode in _mainForm.treeList.Nodes) { PolicyTreeListTag policyTag = policyNode.Tag as PolicyTreeListTag; //need to check policy-ids of all systems as the FillTreeList function (where the policies for the menu were gathered) provided just one of them foreach (CountryConfig.PolicyRow nodePolicyRow in policyTag.GetPolicyRows()) { if (nodePolicyRow.ID == policyRow.ID) { _mainForm.treeList.FocusedNode = policyNode; return; //done } } } } } catch (Exception exception) { UserInfoHandler.RecordIgnoredException("TreeListBuilder.selectPolicyMenu_ItemClicked", exception); } }
void InsertFirstSystem_MenuItemClick(object sender, EventArgs e) { _mainForm.PerformAction(new CopySystemAction( CountryAdministrator.GetCountryConfigFacade(_mainForm.GetCountryShortName()), _mainForm._isAddOn), true, true); }
internal static void RestoreSettings(EM_UI_MainForm mainForm, bool exceptionCall = false) { if (!keepMode) { return; } string cc = mainForm.GetCountryShortName(); try { if (!countryViewSettings.ContainsKey(cc)) { return; } CountryViewSetting setting = countryViewSettings[cc]; foreach (TreeListColumn col in mainForm.treeList.Columns) { if (setting.systemWidths.ContainsKey(col.Caption)) { col.Width = setting.systemWidths[col.Caption]; } if (setting.hiddenSystems.Contains(col.Caption, true)) { col.Visible = false; } if (setting.hiddenSystems.Count > 0) { mainForm.showHiddenSystemsBox(); } } foreach (TreeListNode polNode in mainForm.treeList.Nodes) { SetHiddenNode(setting.hiddenNodes, polNode); foreach (TreeListNode funcNode in polNode.Nodes) { SetHiddenNode(setting.hiddenNodes, funcNode); foreach (TreeListNode parNode in funcNode.Nodes) { SetHiddenNode(setting.hiddenNodes, parNode); } } } if (setting.textSize != null) { mainForm.GetTreeListBuilder().SetTextSize(setting.textSize); } } catch (Exception exception) { if (exceptionCall) { return; // to avoid an infinite loop because of some unknown problem } UserInfoHandler.ShowException(exception, "Failed to restored view settings. Settings are set back to default.", false); if (countryViewSettings.ContainsKey(cc)) { countryViewSettings[cc] = new CountryViewSetting(); } else { countryViewSettings.Add(cc, new CountryViewSetting()); } RestoreSettings(mainForm, true); } }
Dictionary <string, string> GatherComponents() { Dictionary <string, string> selectedComponents = new Dictionary <string, string>(); if (chkAllVariables.Checked) { if (chkCountrySpecific.Checked) { string countryShortName = _mainForm.GetCountryShortName(); foreach (VarConfig.VariableRow variableRow in EM_AppContext.Instance.GetVarConfigFacade().GetVariablesWithCountrySpecificDescription(countryShortName)) { if (IsCheckedVariable(variableRow)) { selectedComponents.Add(variableRow.Name, _componentType_Variable); } } } else if (chkMonetary.Checked || chkNonMonetary.Checked || chkSimulated.Checked || chkNonSimulated.Checked) { foreach (VarConfig.VariableRow variableRow in EM_AppContext.Instance.GetVarConfigFacade().GetVariables()) { if (IsCheckedVariable(variableRow)) { selectedComponents.Add(variableRow.Name, _componentType_Variable); } } } else { foreach (string variableName in EM_AppContext.Instance.GetVarConfigFacade().GetVariables_NamesAndDescriptions().Keys) { if (!selectedComponents.Keys.Contains(variableName.ToLower())) { selectedComponents.Add(variableName.ToLower(), _componentType_Variable); } } } } if (chkAssessmentUnits.Checked) { List <CountryConfig.ParameterRow> parameterRowsTUs = null; foreach (TreeListColumn systemColumn in _mainForm.GetTreeListBuilder().GetSystemColums()) { CountryConfig.SystemRow systemRow = (systemColumn.Tag as SystemTreeListTag).GetSystemRow(); CountryConfigFacade.GetDefFunctionInformation(systemRow, ref parameterRowsTUs, DefFun.DefTu, DefPar.DefTu.Name); foreach (CountryConfig.ParameterRow parameterRowsTU in parameterRowsTUs) { if (!selectedComponents.Keys.Contains(parameterRowsTU.Value.ToLower())) { selectedComponents.Add(parameterRowsTU.Value.ToLower(), _componentType_Taxunit); } } } } if (chkIncomelists.Checked) { List <CountryConfig.ParameterRow> parameterRowsILs = null; foreach (TreeListColumn systemColumn in _mainForm.GetTreeListBuilder().GetSystemColums()) { CountryConfig.SystemRow systemRow = (systemColumn.Tag as SystemTreeListTag).GetSystemRow(); CountryConfigFacade.GetDefFunctionInformation(systemRow, ref parameterRowsILs, DefFun.DefIl, DefPar.DefIl.Name); foreach (CountryConfig.ParameterRow parameterRowsIL in parameterRowsILs) { if (!selectedComponents.Keys.Contains(parameterRowsIL.Value.ToLower())) { selectedComponents.Add(parameterRowsIL.Value.ToLower(), _componentType_Incomelist); } } } } if (chkQueries.Checked) { foreach (string queryName in DefinitionAdmin.GetQueryNamesAndDesc(false).Keys) { if (!selectedComponents.Keys.Contains(queryName.ToLower())) { selectedComponents.Add(queryName.ToLower(), _componentType_Query); DefinitionAdmin.GetQueryDefinition(queryName, out DefinitionAdmin.Query queryDef, out string dummy, false); if (queryDef != null) { foreach (string queryAlias in queryDef.aliases) { selectedComponents.Add(queryAlias.ToLower(), _componentType_Query); } } } } } if (txtComponentName.Text != string.Empty && !IsPatternSearchForSingleComponent()) //pattern-search has to be treated differently { if (!selectedComponents.Keys.Contains(txtComponentName.Text.ToLower())) { selectedComponents.Add(txtComponentName.Text.ToLower(), _componentType_Unknown); } } return(selectedComponents); }
void LoadTableContent() { CountryConfig countryConfig = CountryAdministrator.GetCountryConfigFacade(mainForm.GetCountryShortName()).GetCountryConfig(); keepUndoData = false; dataTable.PrimaryKey = new DataColumn[] { dataTable.Columns.Add("ID", typeof(Int16)) }; dataTable.PrimaryKey[0].AutoIncrement = true; dataTable.Columns.Add(colName.Name); List <string> years = new List <string>(); foreach (CountryConfig.IndirectTaxRow itr in countryConfig.IndirectTax) { foreach (string year in DecomposeYearValues(itr.YearValues).Keys) { if (!years.Contains(year)) { years.Add(year); } } } foreach (string year in years) { AddYearColumn(year); } dataTable.Columns.Add(colComment.Name); foreach (CountryConfig.IndirectTaxRow itr in countryConfig.IndirectTax) { DataRow row = dataTable.Rows.Add(); row.SetField(colName.Name, itr.Name); row.SetField(colComment.Name, itr.Comment); foreach (var yv in DecomposeYearValues(itr.YearValues)) { row.SetField(colYear + yv.Key.ToString(), yv.Value); } } dataSet.AcceptChanges(); undoManager.AddDataSet(dataSet); keepUndoData = true; }
internal string GetCopyCountryShortName() { return(_copyCountryForm.GetCountryShortName()); }