internal void LoadDocument(string filename) { DocumentWindow window = FindDocumentWindow(filename); if (window != null) { window.Select(); ReloadWindow(window); } else if (!File.Exists(filename)) { Errors.FileNotFound(filename); } else { NAntDocument doc = new NAntDocument(filename, _outputWindow, _options); doc.BuildFinished += _mainForm.SetStateStopped; Settings.Default.OpenScriptDir = doc.Directory; Settings.Default.Save(); window = new DocumentWindow(doc.FullName); SetupWindow(window, doc); RecentItems.Add(doc.FullName); // Parse the file in the background _loader.RunWorkerAsync(); } }