The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Show / hide pages in multi folder project
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

StefanS

Sweden
3 Posts

Posted - 09/05/2011 :  11:58:52 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: V 8.0 Pro SR4
Operating System: Win XP

Hi,
for a project with several spreadsheets, graphs and layouts located in different subfolders I would like to hide or show all graphs or layouts, etc. residing the subfolders.

What would be the best approach ?

Method 'GetWindow' and 'ShowWindow' seem to work only for the current subfolder. Furthermoe, the workspace still shows hidden pages as shown.

Thanks a lot !

Stefan Schütte

Penn

China
644 Posts

Posted - 09/06/2011 :  04:41:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Stefan,

You can use the Show property to show/hide a window. For example, the following code will hide all the graphs and layouts in project.

void showHideWindow() {
	foreach(GraphPage gp in Project.GraphPages) {
		gp.Show = false;		
	}
	foreach(LayoutPage lp in Project.LayoutPages) {
		lp.Show = false;		
	}
}


Penn
Go to Top of Page

StefanS

Sweden
3 Posts

Posted - 09/07/2011 :  04:30:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Penn,
thanks a lot for your prompt reply. Below you will find the code I am running as an X-Function. It seems to me that there is a problem with setting the 'Show' property to 'False'. I observed that only worksheets, graphs or layout in the active subfolder are hidden but not in the parent or siblings folders. In contrast setting the 'Show' property to 'true' seems to work correctly.

Do you have any idea why ?

Cheers, Stefan

X-Function Code:
void ManageGraph(const int& nSheetFlag, const int& nGraphFlag, const int& nLayoutFlag)
{

// Show or hide all workbooks in the current project
if( nSheetFlag == 0 )
foreach( WorksheetPage wp in Project.WorksheetPages )
{
out_str(wp.GetName());
wp.Show = false;
}
else
foreach( WorksheetPage wp in Project.WorksheetPages )
{
out_str(wp.GetName());
wp.Show = true;
}


// Show or hide all graphs pages in the current project
if( nGraphFlag == 0 )
foreach( GraphPage gp in Project.GraphPages )
{
out_str(gp.GetName());
gp.Show = false;
}
else
foreach( GraphPage gp in Project.GraphPages )
{
out_str(gp.GetName());
gp.Show = true;
}


// Show or hide all layout pages in the current project
if( nLayoutFlag == 0 )
foreach( LayoutPage lp in Project.LayoutPages )
{
out_str(lp.GetName());
lp.Show = false;
}
else
foreach( LayoutPage lp in Project.LayoutPages )
{
out_str(lp.GetName());
lp.Show = true;
}

}



Stefan Schütte
Go to Top of Page

Penn

China
644 Posts

Posted - 09/08/2011 :  02:40:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Stefan,

It is a bug, sorry for the inconvenience. Now, you can hide graphs/layouts in a folder, and then loop over all the folders in project. Please refer to the example below.

void showHideWindow() {
	Folder rootFld = Project.RootFolder;  // get the root folder
	loopAllFolders(rootFld);
}

// this function is used to hide all the graphs and layouts in the specified 
// folder, including subfolders, recursively
void loopAllFolders(Folder fld) {
	if(!fld)
		return;
	
	fld.Activate();  // activate the folder
	
	// hide graph and layout
	foreach(PageBase pb in fld.Pages) {
		int iType = pb.GetType();
		if(iType == EXIST_GRAPH || iType == EXIST_LAYOUT) {
			pb.Show = false;			
		}
	}
	
	// subfolders recursion
	foreach(Folder subFld in fld.Subfolders) {
		loopAllFolders(subFld);		
	}
}


Penn
Go to Top of Page

StefanS

Sweden
3 Posts

Posted - 09/13/2011 :  07:59:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Penn,
thanks a lot for your help. I guessed so and changed my function - it works now.

Cheers,

Stefan

Stefan Schütte
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000