1.9.1 Managing Projects
Origin C provides the Project class for opening, saving, and appending projects and for accessing the various objects contained in a project. The Project class contains collections for all the page types and loose data sets. There are methods to get the active objects such as the active curve, layer, and folder.
Open and Save a Project
The code below demonstrates saving a project, starting a new project, and opening a saved project.
string strPath = "c:\\abc.opj"; // Project path and name
Project.Save(strPath); // Save current project
Project.Open(); // Start a new project
Project.Open(strPath); // Open saved project
Append One Project to Another
You can append a project to the current project by using the optional second argument of the Project::Open method. The appended project's folder structure will be put into the current project's active folder.
The Modified Flag
When a project is modified, the IsModified flag is set internally by Origin. Origin C allows setting and clearing the IsModified flag. When a project is being closed, this flag is checked. If the flag is set then Origin will ask the user if they want to save their changes. If your Origin C code made changes that you know should not be saved, then you may want to clear the flag to prevent Origin from prompting the user.
if( Project.IsModified() )
// Set the active project as not modified. We do this when we know
// we do not want to save the changes and want to prevent Origin
// from prompting the user about unsaved changes.
// Start a new project, knowing the user will not be prompted about
// unsaved changes in the active project.