/* Constructor */ public ScriptHost(Form hostForm, ScriptBase script) { HostForm = hostForm; Script = script; Script.Host = this; MacroPlayer = new MacroPlayer(); MacroPlayer.LapEnter += (sender) => { Script.OnMacroLapEnter(sender); }; var scriptForm = Script.ScriptForm; if (scriptForm != null) { // Intercept form closing scriptForm.FormClosing += (_sender, _e) => { if (_e.CloseReason == CloseReason.UserClosing) { _e.Cancel = true; scriptForm.Hide(); } }; } }