void OnOpenScript(object sender, string scriptName) { foreach (var doc in documentViews) { if (doc is ScriptView && doc.DocumentName == scriptName) { doc.Activate(); return; } } var view = new ScriptView(scriptName); view.Show(dockPanel, DockState.Document); view.FormClosing += new FormClosingEventHandler(OnDocumentWindowClosing); documentViews.Add(view); }