StrataFrame Forum

Add SF User Control as PanelManagerPage

http://forum.strataframe.net/Topic5255.aspx

By Andria Jensen - 12/12/2006

Is there any way that I can use an existing set of user controls as my pages collection of a panel manager?  I see where you can add an existing PanelManagerPage, but this only allows you to add pages that are already included in another PanelManager right?  Is there any way I can add a page as an existing user control??
By StrataFrame Team - 12/13/2006

The designer that allows you to add an existing page is used to add an inherited panel manager page, which inherits from UserControl.  So, if you create a new user control and change the inherits line from UserControl to PanelManagerPage you will be able to add it.  However, if you're wanting to add a UserControl directly to the Pages collection of a panel manager, you cannot... it has to inherit from PanelManagerPage somewhere along the line.  You can, of course, create a PanelManagerPage using that first method and them just drop one of your user controls on it...
By Andria Jensen - 12/13/2006

I get the following errors in the designer when I change the Inherits to PanelManagerPage instead of UserControl....

On these lines it tells me that the two AutoScale variables are not members of my PanelManagerPage class.

Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

Once I comment those out, I get this error:

Object of type 'MicroFour.StrataFrame.UI.Windows.Forms.PanelManagerPage' cannot be converted to type 'MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl'.

Any ideas on what I am doing wrong here or what I can do to fix this?

 

 

By Andria Jensen - 12/13/2006

Also, the main thing I'd like to be able to do is use the BO Translations collection for keeping all of my BOs in sync for all of the different panels.  I would like to dynamically load each panel as I click the menu selection for it, but this would mean I basically have a bunch of blank pages. 

I am right now doing something like the following...is there a way to use the BO Translations outside of the panelmanager to translate between the main form and each user control??  This would solve my problem.

Public Overrides Sub PanelManager_PageActivated(ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.PanelPageEventArgs)
 
MyBase.PanelManager_PageActivated(e)
 
If PanelManager.CurrentPage.Controls.Count = 0 Then ActivateUserControl()
End Sub

Private Sub ActivateUserControl()
 
Dim control As UserControl = GetPageControlInstance()
  Control.Dock = Windows.Forms.DockStyle.Fill
 
PanelManager.CurrentPage.Controls.Add(control)
End Sub

By StrataFrame Team - 12/13/2006

If you're adding the pages manually, then you can translate the business objects manually as well...

MicroFour.StrataFrame.UI.Windows.Forms.BusinessObjectTranslator.TranslateBusinessObjects(MyFormBO, MyUserControlBO, "MyUserControlBO", Me, Me.UserControl1)

You can also call it from within the user control if you want...

However, there is no "untranslate" for this method, so the business objects are translated until the form is disposed.

You can also create a BusinessObjectTranslationCollection and pass it to the BusinessObjectTranslator to perform all of the translations within the collection.  This method also has an Untranslate, so you can reverse the operation if necessary before you dispose of the form.  The first method is easier (since you don't have to create and manage the collection) and you generally don't ever need to untranslate a business object... you just want it to stay the same until you close and dispose of the form.

By Andria Jensen - 12/13/2006

Can you explain a little more what you mean by untranslate?  Is this basically just removing the links that you have set up by the translator? 
By StrataFrame Team - 12/13/2006

Yes, untranslate replaces the "translated" business object instance with the original instance... though, as I look through the code, it doesn't look like anything that we use gets untranslated... because we just wait for the containers to be disposed.  So, I would just stick with the first overload that accepts the actual business object instances you want to translate.
By Andria Jensen - 12/13/2006

Is there any documentation on this feature?  I couldn't find much on the BO Translations or on SharedDataTableKey.  I have used the SharedDataTableKey on several BOs and this seems to work okay.  What is the difference in using this and doing the Translation?  Is the translation like using the same instance, including it in edits/updates etc.?  I know the SharedDataTableKey just allows BOs to share their current data table among each other, but I guess I don't know the difference between the two concepts.  Please enlighten me.
By StrataFrame Team - 12/13/2006

The two concepts are very similar and in some cases, interchangable... you can "share" the data table between business objects if you only want to share the data... you fill one, the other is filled; you add a record to one, the record is added ot the other.  So, essentially, if you take the two business objects and compare the two data tables, they are the same object reference.

Translation was our first attempt to share data between business objects and is still used in the ChildFormDialog and the UserControls... the SharedDataTableKey was created so that you could share data between two completely separated business objects in your application.  The BOTranslations can only be used when the BOs are in a child form dialog or within UserControls.

The reason there isn't any documentation on manually translating business objects is that those methods are really for internal use... they get used within the UserControl and ChildFormDialog...

By Andria Jensen - 12/13/2006

So if I want to call an Edit on my source BO and have it call an Edit on all of the translated destination BOs would a BO translation accomplish this?  I don't believe that the SharedDataTable concept does this does it?