Exemple #1
0
        void btnCompareVersions_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(txtFolderVersion.Text))
            {
                UserInfoHandler.ShowError("Please select an existing folder for the version to compare with."); return;
            }

            compareCountryFolder = EMPath.AddSlash(txtFolderVersion.Text) + EMPath.Folder_Countries_withoutPath();
            if (!Directory.Exists(compareCountryFolder))
            {
                UserInfoHandler.ShowError("Folder '" + txtFolderVersion.Text + "' does not contain folder 'Countries'."); return;
            }

            selectedFunction = COMPARE_VERSIONS;
            DialogResult     = System.Windows.Forms.DialogResult.OK;
            Close();
        }
        void btnOK_Click(object sender, EventArgs e)
        {
            bool reload = false;

            if (EMPath.AddSlash(EM_AppContext.Instance.GetUserSettingsAdministrator().Get().EuromodFolder).ToLower() != EMPath.AddSlash(cmbEuromodFolder.Text).ToLower())
            {
                if (!EM_AppContext.Instance.CloseAnythingOpen())
                {
                    return;                                              // if there are any countries/add-ons/variables open, try to close them
                }
                reload = true;
            }

            if (!Directory.Exists(cmbEuromodFolder.Text))
            {
                UserInfoHandler.ShowError(cmbEuromodFolder.Text + " is not a valid path.");
                return;
            }

            if (!Directory.Exists(EMPath.AddSlash(cmbEuromodFolder.Text) + EMPath.Folder_Countries_withoutPath()))
            {
                if (UserInfoHandler.GetInfo($"'{cmbEuromodFolder.Text}' does not (yet) contain the {DefGeneral.BRAND_TITLE} file structure."
                                            + Environment.NewLine + Environment.NewLine + "Do you want to change the 'Project Folder'?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    return;
                }
            }

            if (reload)
            {
                ReloadUserSettings();
                CountryAdministration.CountryAdministrator.ClearCountryList();
                EM_AppContext.Instance.SetBrand();                          // allow UI to show another look, i.e. present a brand alternative to EUROMOD
                EM_AppContext.Instance.UpdateAllCountryMainFormGalleries(); //only the empty main form is open and must be updated
                EM_AppContext.Instance.UpdateMainFormCaption();             //set title (of single open mainform) to "EUROMOD Version (Path)"
                EM_AppContext.Instance.UnloadVarConfigFacade();
                EM_AppContext.Instance.UnloadHICPConfigFacade();
                EM_AppContext.Instance.UnloadExchangeRatesConfigFacade();
                EM_AppContext.Instance.UnloadSwitchablePolicyConfigFacade();
            }

            Close();
        }