Example to use Zoneworkspace

Topics: CAB & Smart Client Software Factory
Dec 8, 2005 at 6:29 AM
originally posted by: SUBATBLOOMINGTON


Are there any tutorials to use zoneworkspace ??
Dec 10, 2005 at 11:29 AM
originally posted by: headlam

I don't have a turotial or a sample I can share, but using the ZoneWorkspace should not be much different from using the other workspaces. However, with a ZoneWorkspace you should add a container (i.e., splitter, panel, etc.) onto the ZoneWorkspace to create zones. Give each zone a Name using the ZoneName property (i.e., topZone, leftZone, myZone, etc.). You can then add a zone using code similar to the following (assume we have a reference to the zone workspace called workspace. In the WorkItem you could add code like so (this is just one example)

// Add the view to the workitem items collection
IMyView view = this.Items.AddNew<MyView>();

// create a reference to a ZoneSmartPartInfo. You can specify the zone name here
ZoneSmartPartInfo info = new ZoneSmartPartInfo("topZone");

// show the view (MyView) in the zone workspace topZone workspace.Show(view, info);
Dec 11, 2005 at 9:12 AM
originally posted by: VickiV

I got this much working - a ZoneWorkspace with a SplitContainer and a control in each panel within the splitContainer. Now what I want to do is add a third control within my ZoneWorkspace, by splitting the right container a second time. I tried just putting a second splitContainer inside the panel on the right and giving zonenames to the two panels within. At this point I am not even adding the extra control, in fact the only code change I made was to reference the new zonename in newing the ZoneSmartPartInfo for my control in what would be the middle panel, but I am getting an exception raised in may main form's InitializeComponents call. The exception says "Collection is read only."

What is the right way to create 3 sections in my zone, preferably with splitters to allow the user to grow and shrink them?

Also is there a way to determine the number of panels at runtime rather than design time? Say I am loading out of a profile catalog which has 3 controls, but this particular user only has rights to 2 of them, I would rather not have a blank third section. This is all theoretical at this point, don't have a need yet, just trying to understand what is possible
Dec 11, 2005 at 5:55 PM
originally posted by: headlam

Adding two or more zones should be the same. So you should be able to add multiple splitters, assign a zone name to the panels and add a view to each zone by name. I tested this and it worked. Note that if you add the same insatnce to multiple zones, the last zone you assign it to will win, so you must add a unique instance to see the same vise class appear more that once (i.e., multiple instances). Can you provide more specific on the exception – can you provide some code? If you are trying to add spliters ar runtime vs. design time that is also doable. Take a look at the code that gets generated in the shell’s designer.cs file to get an idea. However, you should carefully think this through since you do not what to couple your uses case (i.e., SmartPart/Presenter/WorkItem combinatiuon)to a particular shell. Typically the shell determines the layout. But you can, and should, consider delegating the layour to a separate use case (i.e., module). You could then expose the capability from this module to allow for dynamic chnages to the layout. But you must do this in a loosly coupled way. Anothet solution would be to load a different layout module based on the user role. So in the case where all you need are two panel, load the layout module with two panels, for three do the same, etc. This has some advantagies, but is not as flexible and perhaps will end up causing the number of modules you support (with similar code) to get out of hand with the different purmutation. So I like the ability to have a layout module and to be able to hide and show different panel at runtime. And this is doable.
Dec 13, 2005 at 7:46 AM
originally posted by: VickiV

I have a splitContainer1 (orientation horizontal), the bottom half has a grid, and in the top half I put my ZoneWorkspace with name= ZoneWorkspaceUpper. On that I added splitContainer2 (orientation veritical) and gave it a zone name of UpperZone, SplitContainer2.panel1.zonename = UpperLeft, SplitContainer2.panel2.zonename=UpperRight. Then I added put SplitContainer3 in SplitContainer2.panel2 gave it ZoneName=UpperRightZone, SplitContainer3.Panel1.zonename=UpperMiddle SplitContainer3.Panel2.zonename=UpperFarRight. I set one of my views in UpperLeft and one in UpperMiddle.

After playing around, I found I could get something that works if I added a second ZoneWorkspace to SplitContainer2.panel2, then put my splitContainer3 in that zoneworkspace. But this seems like it should not be necessary.