How to provide a reset workspace kind of functionality?

Topics related to the Krypton Docking.

Moderators: Phil Wright, Chris Porter

How to provide a reset workspace kind of functionality?

Postby StefanKoell » Thu Dec 24, 2009 5:27 am

Hi,

here's my situation: I have a static number of "well known" kryptonpages which are always loaded/instanciated which can dock, auto-hide, float or closed (hidden), one of them is even capable of being in the document workspace.
Then I have a random number of document workspace krypton pages where I don't know how much of them are present and how the cell layout is.

I guess this is quite common for docking enabled applications.

Now here's my question: I was wondering how I can provide some "reset workspace" functionality. The goal is, that regardless where and how my well known pages are docked/hidden/floated/etc., I want to reset the layout of these pages to a default layout.
Something like this: a reset should dock page 1 to the left edge, page 2 and 3 should be docked at the bottom but not tabbed, instead I want them to be in 2 cells vertically split and page 3 should be autohidden at the right edge. The one page which is also able to be a document in the workspace, should show up in the document workspace, regardless where it was before.

The idea is, if the user messes around too much with the pages, he can reset to the default layout (the starting point) at any time.
This reset must not touch any of the random document workspace pages.

I know I could use persistence for this, but I was wondering how I would do that by code.

Thanks,
Stefan

http://www.code4ward.net
Home of Royal TS and LogSmith, of course Kryptonized!
StefanKoell
 
Posts: 88
Joined: Sun Oct 26, 2008 7:15 pm
Location: Austria

Re: How to provide a reset workspace kind of functionality?

Postby StefanKoell » Fri Jan 29, 2010 10:46 pm

Hi Phil,

it's been a month since I asked the above question. Due to the lack of documentation I am solely depnding on your help in this forums. It seems that the stuff I need is not in your sample applications and really need your help implementing your Docking Framework into my app. Some more samples or documentation would be very helpful.

Thanks,
Stefan

http://www.code4ward.net
Home of Royal TS and LogSmith, of course Kryptonized!
StefanKoell
 
Posts: 88
Joined: Sun Oct 26, 2008 7:15 pm
Location: Austria

Re: How to provide a reset workspace kind of functionality?

Postby Phil Wright » Mon Feb 01, 2010 3:13 pm

All you need to do is remove the existing pages...

Code: Select all

    // Remove pages to be repositioned
    kryptonDockingManager1.RemovePages(new KryptonPage[]{page1, page2, page3, page4, page5}, false);



...then add them back using your existing code for the initial setup. So something like this...

Code: Select all

    kryptonDockingManager1.AddDockspace("Control", DockingEdge.Left, new KryptonPage[] { page1 });
    kryptonDockingManager1.AddDockspace("Control", DockingEdge.Bottom, new KryptonPage[] { page2 });
    kryptonDockingManager1.AddDockspace("Control", DockingEdge.Bottom, new KryptonPage[] { page3 });
    kryptonDockingManager1.AddAutoHiddenGroup("Control", DockingEdge.Right, new KryptonPage[] { page4 });
    kryptonDockingManager1.AddToWorkspace("Workspace", new KryptonPage[] { page5 });

Phil Wright
Site Admin
 
Posts: 2720
Joined: Thu Apr 13, 2006 2:55 pm
Location: Melbourne, Australia

Re: How to provide a reset workspace kind of functionality?

Postby StefanKoell » Thu Feb 04, 2010 4:24 am

I tried that already but I get some weird behavior.

I add my dockpages like this:
Code: Select all
            DockingManagerMain.AddDockspace("Control", DockingEdge.Bottom, new KryptonPage[] { BottomPage1 }, new KryptonPage[] { BottomPage2 });
            DockingManagerMain.AddDockspace("Control", DockingEdge.Left, new KryptonPage[] { LeftPage });
            DockingManagerMain.AddDockspace("Control", DockingEdge.Right, new KryptonPage[] { RightPage1 }, new KryptonPage[] { RightPage2 });


then I do this:
Code: Select all
            DockingManagerMain.RemovePages(new KryptonPage[] { BottomPage1 , BottomPage2 , LeftPage , RightPage1 , RightPage2 }, false);
            DockingManagerMain.AddDockspace("Control", DockingEdge.Bottom, new KryptonPage[] { BottomPage1 }, new KryptonPage[] { BottomPage2 });
            DockingManagerMain.AddDockspace("Control", DockingEdge.Left, new KryptonPage[] { LeftPage });
            DockingManagerMain.AddDockspace("Control", DockingEdge.Right, new KryptonPage[] { RightPage1 }, new KryptonPage[] { RightPage2 });


For once, the hierarchy doesn't seem to resemble the initial setup after I do this. In my initial setup the bottom pages are between the left and right page. After resetting all the pages, the bottom pages "overlap" the right page.

If a page was closed, I get in the docking a panel with "(Emtpy)" instead of my previously closed page (my predefined pages are just hiding on close).

Because of this random, weird behavior I tried the approach with loading and saving the hierarchy. I would also prefer a way to do it by code.

cheers,
Stefan
Stefan

http://www.code4ward.net
Home of Royal TS and LogSmith, of course Kryptonized!
StefanKoell
 
Posts: 88
Joined: Sun Oct 26, 2008 7:15 pm
Location: Austria

Re: How to provide a reset workspace kind of functionality?

Postby dbrank0 » Mon Feb 08, 2010 11:39 pm

I had the same problem. After initial setup I just do:
Code: Select all
defaultWindowPositions = dockingManager.SaveConfigToArray();

Then if reset is required:
Code: Select all
dockingManager.LoadConfigFromArray(defaultWindowPositions);

Works good enough for me.
dbrank0
 
Posts: 20
Joined: Tue Sep 29, 2009 5:14 am

Re: How to provide a reset workspace kind of functionality?

Postby StefanKoell » Tue Feb 09, 2010 12:05 am

I tried that too but wasn't able to reinsert my other workspace documents the user was adding during runtime (see this thread: viewtopic.php?f=17&t=2807)

Were you able to do that using the OrphanedPage event? Phil advised me to do it this way but I guess there's still a glitch or a requisite to get it to work.
Stefan

http://www.code4ward.net
Home of Royal TS and LogSmith, of course Kryptonized!
StefanKoell
 
Posts: 88
Joined: Sun Oct 26, 2008 7:15 pm
Location: Austria

Re: How to provide a reset workspace kind of functionality?

Postby dbrank0 » Fri Feb 12, 2010 9:07 pm

StefanKoell wrote:I tried that too but wasn't able to reinsert my other workspace documents the user was adding during runtime (see this thread: viewtopic.php?f=17&t=2807)

Were you able to do that using the OrphanedPage event? Phil advised me to do it this way but I guess there's still a glitch or a requisite to get it to work.


I only have few fixed pages in my application, so it just works for me. I hope you solve the problem by the time I need user-added pages. 8)
dbrank0
 
Posts: 20
Joined: Tue Sep 29, 2009 5:14 am


Return to Krypton Docking

Who is online

Users browsing this forum: No registered users and 0 guests

cron