GH_DocumentServer

References
Manages and maintains a collection of GH_Documents.

Properties

DocumentCount

#
public int DocumentCount { get; }
Gets the number of documents stored in the global list.

DocumentNames

#
public List<string> DocumentNames { get; }
Gets a string collection containing all the names of the documents in the global list.

ModifiedDocumentCount

#
public int ModifiedDocumentCount { get; }
Gets the total number of modified (unsaved) documents.

Indexers

Document

#
public GH_Document this[int index] { get; }
Gets the document at the given index.
index (int)Index of document to retrieve.

Methods

AddDocument

#
public GH_Document AddDocument(string filepath, bool makeActive)
Add a new document to the global list. If there already is a document with the given path, it will be made active.
filepath (string)Filepath to document.
makeActive (bool)If true, the document will be loaded into the main canvas.
The document that was added or activated, or null on failure.

AddDocument

#
public void AddDocument(GH_Document document, ref bool success)
Add a new document to the global list. If the document is already registered nothing will happen. This also applies to a different document which points to the same file path
document (GH_Document)Document to add.
success (ref bool)
ArgumentNullExceptionThrown when the document is a null reference.
InvalidOperationExceptionThrown when the document doesn't have top-level rank.

AddDocument

#
public void AddDocument(GH_Document document)
Add a new document to the global list. If the document is already registered nothing will happen. This also applies to a different document which points to the same file path
document (GH_Document)Document to add.
ArgumentNullExceptionThrown when the document is a null reference.
InvalidOperationExceptionThrown when the document doesn't have top-level rank.

AddNewDocument

#
public GH_Document AddNewDocument()
Adds a new document to the global list. If a template file has been set, this document will be based on the template.
The document thaw was added.

Contains

#
public bool Contains(GH_Document doc)
Gets a value indicating whether or not the given document is inside the list.
doc (GH_Document)

GetEnumerator

#
public IEnumerator GetEnumerator()

GetEnumerator_Generic

#
public IEnumerator<GH_Document> GetEnumerator_Generic()

IndexOf

#
public int IndexOf(GH_Document doc)
Gets the index of the given document.
doc (GH_Document)Document to search for.
The index of the given document or -1 if the document is not in the global list.

IndexOf

#
public int IndexOf(string filepath)
Gets the index of the document that matches the filepath.
filepath (string)File path URI to match.
The index of the document that matches the given path or -1 if no document match is found.

IndexOfAutoSave

#
public int IndexOfAutoSave(string autoSavePath)
Gets the document index that is associated with the specified autosave location.
autoSavePath (string)The full path (directory, filename and extension) of the autosave file to test against.
The index of the document that matches the given autosave path or -1 if no document match is found.

NextAvailableDocument

#
public GH_Document NextAvailableDocument()
Gets the most important, non-active document.

PromoteDocument

#
public void PromoteDocument(GH_Document document)
Push a document to the top of the list, meaning it will be first in line when a new default document needs to be selected.
document (GH_Document)Document to promote.

RemoveAllDocuments

#
public void RemoveAllDocuments()
Remove all documents in the global list.

RemoveDocument

#
public void RemoveDocument(GH_Document document)
Removes a specific document from the global list. If the document isn't registered nothing will happen. If the document is owned by an IGH_DocumentOwner, the owner will be informed of the removal.
document (GH_Document)Document to remove.

SafeRemoveDocument

#
public bool SafeRemoveDocument(GH_Document document)
Remove a document correctly from the server. This method shows user-interface prompts if there is unsaved data and will also save if needed.
document (GH_Document)Document to remove.
True if the document was removed, false if otherwise.

Events

DocumentAdded

#
public event GH_DocumentServer.DocumentAddedEventHandler DocumentAdded

DocumentRemoved

#
public event GH_DocumentServer.DocumentRemovedEventHandler DocumentRemoved