예제 #1
0
        /// <summary>
        ///   Attempts to close all open documents belonging to the
        ///   given Workplace. If null, all documents will be closed.
        /// </summary>
        /// <param name="workplace">The workplace owning the documents to be closed.</param>
        /// <param name="askForUnsavedChanges">Asks confirmation before closing unsaved documents.</param>
        /// <returns>Returns true if all documents were closed, false if the operation was cancelled by the user.</returns>
        public bool CloseAllDocuments(Workplace workplace, bool askForUnsavedChanges)
        {
            IDockContent[] documents = dockPanel.DocumentsToArray();

            foreach (IDockContent content in documents)
            {
                if (content is SinapseDocumentView)
                {
                    SinapseDocumentView document = content as SinapseDocumentView;
                    if (askForUnsavedChanges && document.HasChanges)
                    {
                        DialogResult r = MessageBox.Show(String.Format("Save changes to {0}?", document.Name),
                                                         "Save changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                        if (r == DialogResult.Yes)
                        {
                            document.Save();
                        }
                        else if (r == DialogResult.Cancel)
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
예제 #2
0
        public void SaveAll()
        {
            IDockContent[] documents = dockPanel.DocumentsToArray();

            foreach (IDockContent content in documents)
            {
                if (content is SinapseDocumentView)
                {
                    SinapseDocumentView document = content as SinapseDocumentView;
                    if (document.HasChanges)
                    {
                        document.Save();
                    }
                }
            }

            if (activeWorkplace != null)
            {
                activeWorkplace.Save();
            }
        }