void VariablesForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (_hasChangedSinceLastSave && !_isReadOnly)
            {
                DialogResult result = Tools.UserInfoHandler.GetInfo("Do you want to save the changes?", MessageBoxButtons.YesNoCancel);

                if (result == DialogResult.Cancel)
                {
                    e.Cancel = true;
                    return;
                }

                if (result == DialogResult.Yes && !SaveChanges())
                {
                    e.Cancel = true;
                    return;
                }
            }

            if (!_isReadOnly)
            {
                InUseFileHandler.ReleaseFile(new EMPath(EM_AppContext.FolderEuromodFiles).GetVarFilePath(true)); //files can now be used by other users again
            }
            EM_AppContext.Instance.ReleaseVarConfigFacade();
        }
 internal void ShowVariablesForm()
 {
     if (_variablesForm == null || _variablesForm.IsDisposed)
     {
         //capture parameter file, to avoid editing by another user
         bool openedReadOnly = false;
         if (!InUseFileHandler.CaptureFile(new EMPath(FolderEuromodFiles).GetVarFilePath(true),
                                           ref openedReadOnly)) //set to true, if another user already captured the file
         {
             return;                                            //file is captured by another user and the user decided to not open in read-only mode
         }
         _variablesForm             = new EM_UI.VariablesAdministration.VariablesForm(GetVarConfigFacade());
         _variablesForm._isReadOnly = openedReadOnly;
     }
     _variablesForm.Show();
     _variablesForm.Activate();
 }
        internal bool CheckForActiveRunsOnLastMainFormClosing()
        {
            //check whether variables form is open to release the lock-file, if necessary
            if (_variablesForm != null && !_variablesForm._isReadOnly)
            {
                InUseFileHandler.ReleaseFile(new EMPath(EM_AppContext.FolderEuromodFiles).GetVarFilePath(true));
            }

            if (_countryMainForms.Count > 1 || _userSettingsAdministrator.Get().CloseInterfaceWithLastMainform == DefPar.Value.NO)
            {
                return(true); //closing MainForm is not the only one open
            }
            //close active runs (after asking user) as well as potentially still open info-windows of terminated runs
            for (int index = _registeredRunManagers.Count - 1; index >= 0; --index)
            {
                if (!_registeredRunManagers.ElementAt(index).Close())
                {
                    return(false); //do not allow closing main form if user does not want to terminate active runs
                }
            }
            return(true);
        }