Exemple #1
0
        public void OpenDocument(String fullName, Workplace owner)
        {
            // First: verify if the document isn't already open
            IDockContent[] openDocuments = dockPanel.DocumentsToArray();

            foreach (SinapseDocumentView openDocument in openDocuments)
            {
                if (openDocument.Document != null &&
                    openDocument.Document.File.FullName == fullName)
                {
                    // The document was already open
                    openDocument.DockHandler.Show(); // Activate it
                    return;
                }
            }

            // The document wasn't open, lets open it:
            ISinapseDocument document = DocumentManager.Open(fullName);

            document.Owner = owner; // If we have an owner Workplace, set it

            // Now lets determine the adequate viewer for this document type
            Type viewerType = SinapseDocumentView.GetViewer(Utils.GetExtension(fullName, true));

            // Activate the viewer,
            SinapseDocumentView viewer = Activator.CreateInstance(viewerType, this, document) as SinapseDocumentView;

            // And then lets show the new viewer on the main window.
            viewer.DockHandler.Show(dockPanel, DockState.Document);

            mruDocuments.Insert(fullName);
        }
Exemple #2
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);
        }
Exemple #3
0
        public void OpenDocument(ISinapseDocument document)
        {
            // Now lets determine the adequate viewer for this document type
            Type viewerType = SinapseDocumentView.GetViewer(document);

            // Activate the viewer
            SinapseDocumentView viewer = Activator.CreateInstance(viewerType, this, document) as SinapseDocumentView;

            // And then show the viewer on the main window.
            viewer.DockHandler.Show(dockPanel, DockState.Document);
        }
Exemple #4
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();
            }
        }