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 void SetPasteFunctionAction(PasteFunctionAction pasteFunctionAction) { _pasteFunctionAction = pasteFunctionAction; }