private DocumentInfo newDocument(string text, string title = null, bool addProject = true) { mv = this.View as IMainView; var editor = mv.CreateEditor(text); var document = new DocumentInfo(); if (!string.IsNullOrEmpty(title)) { document.Title = title; } if (addProject) { var id = document.DocumentID = InteractiveManager.CreateAndOpenDocument(editor.TextContainer); editor.DocumentID = id; if (string.IsNullOrEmpty(document.Title)) { document.Title = id.ToString(); } } editor.EditorTextChanged += editor_EditorTextChanged; document.Editor = editor; return(document); }