public bool Close(IDocument document)
        {
            if (document == null) { throw new ArgumentNullException("document"); }
            if (!documents.Contains(document))
            {
                throw new ArgumentException("document is not an item of the Documents collection.");
            }

            DocumentsClosingEventArgs eventArgs = new DocumentsClosingEventArgs(new IDocument[] { document });
            OnDocumentsClosing(eventArgs);
            if (eventArgs.Cancel) { return false; }

            if (ActiveDocument == document)
            {
                ActiveDocument = null;
            }
            documents.Remove(document);
            return true;
        }
        public bool CloseAll()
        {
            DocumentsClosingEventArgs eventArgs = new DocumentsClosingEventArgs(Documents);
            OnDocumentsClosing(eventArgs);
            if (eventArgs.Cancel) { return false; }

            ActiveDocument = null;
            while (documents.Any())
            {
                documents.Remove(documents.First());
            }
            return true;
        }
 protected virtual void OnDocumentsClosing(DocumentsClosingEventArgs e)
 {
     if (DocumentsClosing != null) { DocumentsClosing(this, e); }
 }
 private void DocumentManagerDocumentsClosing(object sender, DocumentsClosingEventArgs e)
 {
     IEnumerable<IDocument> modifiedDocuments = e.Documents.Where(d => d.Modified).ToList();
     if (!modifiedDocuments.Any()) { return; }
 }