internal IndirectTaxesForm(EM_UI_MainForm _mainForm)
        {
            InitializeComponent();

            try
            {
                mainForm = _mainForm;

                dataSet.Tables.Add(dataTable);
                table.DataSource = dataSet;
                table.DataMember = "IttDataTable";

                LoadTableContent();

                // only after all the data is loaded, add the row numbers and the refresh listeners
                table.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
                table.RowsAdded   += new DataGridViewRowsAddedEventHandler(table_RefreshRowNumbers);
                table.RowsRemoved += new DataGridViewRowsRemovedEventHandler(table_RefreshRowNumbers);

                table_RefreshRowNumbers(null, null);
                colName.Frozen = true;
                //colComment.Frozen = true; // this can only happen if it is not the last row!
            }
            catch (Exception exception) { UserInfoHandler.ShowException(exception); }
        }
        internal ColumnContextMenuHelper(EM_UI_MainForm mainForm)
        {
            _mainForm = mainForm;

            //additional menu items to menu for system column
            _menuItemsSystemColumn.Add(_menuItemCaption_CopySystem, CopySystem_MenuItemClick);
            _menuItemsSystemColumn.Add(_menuItemCaption_RenameSystem, RenameSystem_MenuItemClick);
            _menuItemsSystemColumn.Add(_menuItemCaption_DeleteSystem, DeleteSystem_MenuItemClick);
            _menuItemsSystemColumn.Add(_menuSeparator1, null);
            _menuItemsSystemColumn.Add(_menuItemCaption_RestoreSystemOrder, RestoreSystemOrder_MenuItemClick);
            _menuItemsSystemColumn.Add(_menuItemCaption_SaveSystemOrder, SaveSystemOrder_MenuItemClick);
            _menuItemsSystemColumn.Add(_menuItemCapiton_MoveToHiddenSystems, null);
            _menuItemsSystemColumn.Add(_subMenuItemCapiton_SelectedSystem, MoveToHiddenSystems_SelectedColumn_MenuItemClick);
            _menuItemsSystemColumn.Add(_subMenuItemCapiton_AllSystemsBut, MoveToHiddenSystems_AllSystemsBut_MenuItemClick);
            _menuItemsSystemColumn.Add(_subMenuItemCapiton_SelectSystems, MoveToHiddenSystems_SelectSystems_MenuItemClick);
            _menuItemsSystemColumn.Add(_subMenuItemCapiton_AllSystemsToTheLeft, MoveToHiddenSystems_AllSystemsToTheLeft_MenuItemClick);
            _menuItemsSystemColumn.Add(_subMenuItemCapiton_AllSystemsToTheRight, MoveToHiddenSystems_AllSystemsToTheRight_MenuItemClick);
            _menuItemsSystemColumn.Add(_subMenuItemCapiton_menuSeparator5, null);
            _menuItemsSystemColumn.Add(_subMenuItemCapiton_UnhideAllSystems, MoveToHiddenSystems_UnhideAllSystems_MenuItemClick);
            _menuItemsSystemColumn.Add(_subMenuItemCapiton_menuSeparator6, null);
            _menuItemsSystemColumn.Add(_subMenuItemCapiton_ShowHiddenSystemsBox, MoveToHiddenSystems_ShowHiddenSystemBox_MenuItemClick);
            _menuItemsSystemColumn.Add(_menuSeparator3, null);
            _menuItemsSystemColumn.Add(_menuItemCaption_ShowMatrixView, ShowMatrixView_MenuItemClick);
            _menuItemsSystemColumn.Add(_menuSeparator4, null);
            _menuItemsSystemColumn.Add(_menuItemCaption_InsertFirstPolicy, InsertFirstPolicy_MenuItemClick);

            //additional menu items to menu for policy column
            _menuItemsPolicyColumn.Add(_menuItemCaption_ExpandAllPolicies, ExpandAllPolicies_MenuItemClick);
            _menuItemsPolicyColumn.Add(_menuItemCaption_CollapseAllPolicies, CollapseAllPolicies_MenuItemClick);
            _menuItemsPolicyColumn.Add(_menuSeparator1, null);
            _menuItemsPolicyColumn.Add(_menuItemCaption_InsertFirstSystem, InsertFirstSystem_MenuItemClick);
        }
 internal void SetPasteInfo(TreeListNode pasteNode, EM_UI_MainForm pasteCountryForm, bool pasteBefore, List <string> hiddenSystems)
 {
     _pasteCountryForm = pasteCountryForm;
     _pasteNode        = pasteNode;
     _pasteBefore      = pasteBefore;
     _hiddenSystems    = hiddenSystems;
 }
Exemplo n.º 4
0
        internal void GenerateInfo(string outputFilePath, List <string> _countries)
        {
            EM_UI_MainForm mainForm = EM_AppContext.Instance.GetActiveCountryMainForm(); if (mainForm != null)

            {
                mainForm.Cursor = Cursors.WaitCursor;
            }

            try
            {
                countries = _countries;
                AssessCountryInfo();
                InitExcelFile(outputFilePath);
                FillExcelFile();
                spreadsheetControl.SaveDocument();
                UserInfoHandler.ShowSuccess(string.Format("Successfully generated Release info file '{0}'.", outputFilePath)); // perhaps open ???
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception, string.Format("Failed to generate Release info file '{0}'.", outputFilePath), false);
            }
            finally { if (mainForm != null)
                      {
                          mainForm.Cursor = Cursors.Default;
                      }
            }
        }
Exemplo n.º 5
0
        internal static void PrepareBrand(EM_UI_MainForm emptyForm)
        {
            try
            {
                string brandName  = GetProjectNameOrDefault();
                string brandTitle = Properties.Resources.ResourceManager.GetString("brand_title_" + brandName);

                if (String.IsNullOrEmpty(brandTitle))
                {
                    brandTitle = brandName = "EUROMOD";
                    // For now, completely go silent if the brand is wrong. To warn, uncomment the line below:
                    //UserInfoHandler.ShowError($"File '{projectSettingsFullPath}' does not contain a valid Project Name.{Environment.NewLine}Alternative brand is ignored.");
                }

                DefGeneral.BRAND_TITLE = brandTitle;
                DefGeneral.BRAND_NAME  = brandName;
                SetBackgroundImage(emptyForm);
                SetIcon(emptyForm);
                emptyForm.btnRun.Caption            = $"Run{Environment.NewLine}{DefGeneral.BRAND_TITLE}";
                emptyForm.barText_PoweredBy.Caption = DefGeneral.IsAlternativeBrand() ? GetPoweredByText() : string.Empty;
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception, "Adapting to alternative Brand failed!", false);
            }
        }
Exemplo n.º 6
0
        //in this method a tooltip for the items of the combo is drawn
        void Editor_DrawItem(object sender, DevExpress.XtraEditors.ListBoxDrawItemEventArgs e)
        {
            ComboBoxEdit   cboEditor = sender as ComboBoxEdit;
            EM_UI_MainForm mainForm  = cboEditor.Parent.Parent as EM_UI_MainForm;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                //search for the Comment, it should go into the tooltip
                var parameterRowComment = from parameterRow in GetParameterRowsILs() where parameterRow.Value.Equals(e.Item.ToString()) select parameterRow;
                if (parameterRowComment.Count() == 0)
                {
                    parameterRowComment = from parameterRow in GetParameterRowsTUs() where parameterRow.Value.Equals(e.Item.ToString()) select parameterRow;
                }
                if (parameterRowComment.Count() == 1)
                {
                    mainForm.lblComboboxEditorToolTip.Text    = GetILTUComment(parameterRowComment.First());
                    mainForm.lblComboboxEditorToolTip.Visible = true;

                    int y = mainForm.treeList.Location.Y + cboEditor.Location.Y + e.Bounds.Bottom + 5;
                    int x = cboEditor.Location.X + e.Bounds.Right + 25;

                    mainForm.lblComboboxEditorToolTip.Location = new Point(x, y);
                    mainForm.lblComboboxEditorToolTip.BringToFront();
                }
                else
                {
                    mainForm.lblComboboxEditorToolTip.Visible = false;
                }
            }
        }
Exemplo n.º 7
0
        //close the ItemTooltip as well
        void Editor_Closed(object sender, DevExpress.XtraEditors.Controls.ClosedEventArgs e)
        {
            ComboBoxEdit   cboEditor = sender as ComboBoxEdit;
            EM_UI_MainForm mainForm  = cboEditor.Parent.Parent as EM_UI_MainForm;

            mainForm.lblComboboxEditorToolTip.Visible = false;
        }
Exemplo n.º 8
0
        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);
            }
        }
 //add policy after/before an existing policy
 internal AddPolicyAction(EM_UI_MainForm mainForm, TreeListNode senderNode, string polType, bool addBeforeSender, List <string> hiddenSystems)
 {
     _mainForm        = mainForm;
     _senderNode      = senderNode;
     _policyType      = polType.Substring(0, 3).ToLower();
     _addBeforeSender = addBeforeSender;
 }
        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());
        }
Exemplo n.º 11
0
        internal static void CleanLogFile()
        {
            string logFile = new EMPath(EM_AppContext.FolderEuromodFiles).GetEmLogFilePath();

            EM_UI_MainForm mainForm = EM_AppContext.Instance.GetActiveCountryMainForm();

            if (mainForm != null)
            {
                mainForm.Cursor = Cursors.WaitCursor;
            }
            string error = AdaptLogFile(logFile);

            if (mainForm != null)
            {
                mainForm.Cursor = Cursors.Default;
            }

            if (error == string.Empty)
            {
                UserInfoHandler.ShowSuccess("Successfully cleaned " + logFile + ".");
            }
            else
            {
                UserInfoHandler.ShowError("Failed to clean " + logFile + ":" + Environment.NewLine + error);
            }
        }
        // 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 PasteFunctionAction(List <TreeListNode> copyNodes, EM_UI_MainForm copyCountryForm)
 {
     _copyFunctions = new List <Dictionary <string, CountryConfig.FunctionRow> >();
     foreach (TreeListNode copyNode in copyNodes)
     {
         _copyFunctions.Add((copyNode.Tag as FunctionTreeListTag).GetFunctionDictionary());
     }
     _copyCountryForm = copyCountryForm;
 }
Exemplo n.º 15
0
        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);
            }
        }
Exemplo n.º 16
0
        private static void SetBackgroundImage(EM_UI_MainForm emptyForm)
        {
            // if a brand logo exists, use it
            object obj = Properties.Resources.ResourceManager.GetObject(BRAND_BACKGROUND_IMAGE_PREFIX + DefGeneral.BRAND_NAME);

            if (obj != null && obj is Image)
            {
                emptyForm.treeList.BackgroundImage = (Image)obj;
            }
        }
Exemplo n.º 17
0
        private static void SetIcon(EM_UI_MainForm emptyForm)
        {
            // if a brand icon exists, use it
            object obj = Properties.Resources.ResourceManager.GetObject(BRAND_ICON_PREFIX + DefGeneral.BRAND_NAME);

            if (obj != null && obj is Icon)
            {
                emptyForm.Icon = (Icon)obj;
            }
        }
Exemplo n.º 18
0
        internal TreeListBuilder(EM_UI_MainForm mainForm, CountryConfigFacade countryConfigFacade)
        {
            _mainForm            = mainForm;
            _countryConfigFacade = countryConfigFacade;

            _fixedColumnsLeft = new List <string>();
            _fixedColumnsLeft.Add(_policyColumnName);
            _fixedColumnsLeft.Add(_groupColumnName);
            _fixedColumnRight = _commentColumnName;
        }
Exemplo n.º 19
0
        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 void UpdateCountryFiles(Dictionary <string, List <Tuple <string, string> > > changesCountryFiles, Form showWaitCursorForm = null)
        {
            try
            {
                if (showWaitCursorForm == null)
                {
                    showWaitCursorForm = EM_AppContext.Instance.GetActiveCountryMainForm();
                }
                showWaitCursorForm.Cursor = Cursors.WaitCursor;
                bool showOpenWarning = true;
                foreach (var ccChange in changesCountryFiles)
                {
                    string         country    = ccChange.Key;
                    EM_UI_MainForm ccMainForm = EM_AppContext.Instance.GetCountryMainForm(country);
                    if (ccMainForm != null)
                    {
                        if (showOpenWarning)
                        {
                            switch (UserInfoHandler.GetInfo(country.ToUpper() + " is open." + Environment.NewLine +
                                                            "Updating exchange rates requires a reset of the undo-functionality." + Environment.NewLine +
                                                            "That means you will not be able to undo any of your changes so far." + Environment.NewLine + Environment.NewLine +
                                                            "Do you still want to update exchange rates of " + country.ToUpper() + "?" + Environment.NewLine + Environment.NewLine +
                                                            "(Press Cancel to not be requested with respect to further open countries.)", MessageBoxButtons.YesNoCancel))
                            {
                            case DialogResult.No: continue;

                            case DialogResult.Cancel: showOpenWarning = false; break;
                            }
                        }
                        ccMainForm.GetUndoManager().Commit(); ccMainForm.GetUndoManager().Reset();
                    }
                    CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country);
                    foreach (var change in ccChange.Value)
                    {
                        ccf.GetSystemRowByName(change.Item1).ExchangeRateEuro = change.Item2;
                    }

                    if (ccMainForm != null)
                    {
                        ccMainForm.GetUndoManager().Commit(); ccMainForm.GetUndoManager().Reset(); ccMainForm.WriteXml();
                    }
                    else
                    {
                        CountryAdministrator.WriteXML(country);
                    }
                }
            }
            catch (Exception)
            {
            }
            finally { showWaitCursorForm.Cursor = Cursors.Default; }
        }
Exemplo n.º 21
0
        internal static bool IsHiddenSystem(string countryShortName, string systemName)
        {
            EM_UI_MainForm openMainForm = (EM_AppContext.Instance.GetCountryMainForm(countryShortName));

            if (openMainForm == null)
            {
                return(countryViewSettings.ContainsKey(countryShortName) &&
                       countryViewSettings[countryShortName].hiddenSystems.Contains(systemName, true));
            }
            TreeListColumn sc = openMainForm.GetTreeListBuilder().GetSystemColumnByName(systemName);

            return(sc == null ? false : !sc.Visible);
        }
 void gridParam_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         btnApply_Click(null, null);
         e.Handled = true;
     }
     if (e.KeyCode == Keys.F5 || e.KeyCode == Keys.F6)
     {
         EM_UI_MainForm mainForm = EM_AppContext.Instance.GetActiveCountryMainForm();
         mainForm.GetTreeListManager().HandleFKeyDown(e.KeyCode == Keys.F5, this);
     }
 }
Exemplo n.º 23
0
        internal PastePolicyAction(TreeListNode copyNode, EM_UI_MainForm copyCountryForm)
        {
            PolicyTreeListTag tag = (copyNode.Tag != null) ? (copyNode.Tag as PolicyTreeListTag) : null;

            if (tag != null)
            {
                _copyPolicyRows = new Dictionary <string, CountryConfig.PolicyRow>();
                foreach (CountryConfig.PolicyRow policyRow in tag.GetPolicyRows())
                {
                    _copyPolicyRows.Add(policyRow.SystemRow.ID, policyRow);
                }
            }
            _copyCountryForm = copyCountryForm;
        }
        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 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);
        }
        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);
            }
        }
        internal static EM_AppContext Create_EM_AppContext(EM_UI_MainForm countryMainForm)
        {
            singleton  = new EM_AppContext(countryMainForm);
            _emptyForm = countryMainForm;

            //show the dialog where the user can set the default pathes, if the folder to the country-xml-files does not exist
            if (!Directory.Exists(EMPath.Folder_Countries(EM_AppContext.FolderEuromodFiles)))
            {
                ConfigurePathsForm configurePathsForm = new ConfigurePathsForm();
                configurePathsForm.ShowDialog();
            }
            singleton.SetBrand();   // allow UI to show another look, i.e. present a brand alternative to EUROMOD

            DefinitionAdmin.Init(); // initialise the common-lib's description of functions and parametes (once for the life-time of the lib)
            return(singleton);
        }
        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));
        }
        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));
        }
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            EM_UI_MainForm mainForm = null;

            if (args.Length == 1)
            {
                mainForm = new EM_UI_MainForm(args[0]);
            }
            else
            {
                mainForm = new EM_UI_MainForm();
            }

            EM_AppContext appContext = EM_AppContext.Create_EM_AppContext(mainForm);

            Application.Run(appContext);
        }