Automatic layout with nested shapes/ How to implement StackPanel functionality
-
Saturday, March 10, 2012 4:43 PM
Hi,
I have a DSL with nested Models. I want the parent shape to adjust the child shapes automatically like the StackPanel control in WPF/ WindowsForms. I tried to use BoundsRules but GetCompliantBounds() will be called for adding children and moving parent. I want the same behavior like the DSL Editor.
Thanks,
Thomas
All Replies
-
Thursday, April 12, 2012 3:55 PMOwner
Hi Thomas
I assume you are referring to nesting of shapes, but in that case I don't quite understand the behaviour of the DSL Designer to which you are referring, since the DSL Designer itself does not have any nested shapes. What specific behaviour of the DSL Designer is it that you wish to emulate?
You may find Jean-Marc's blog posting on nested shapes helpful.
Regards
Blair
- Proposed As Answer by Jean-Marc PrieurMicrosoft Employee, Owner Friday, April 13, 2012 9:47 AM
- Marked As Answer by DuncanPMicrosoft Employee, Owner Thursday, April 26, 2012 12:08 PM
- Unmarked As Answer by Thomas Ziegler Tuesday, May 29, 2012 1:24 PM
-
Tuesday, May 29, 2012 1:28 PM
If you create a DSL Language Project Visual Studio 2010 has a build-in Designer for creation DSLs. After Dropping a DomainClass the Designer will organize the shapes like a stackpanel. To change to order you have to select a shape and press ctrl+arrow down/ ctrl+arrow up.
I want this behaviour for my DSL Designer. I'm on this. I found a great post
http://social.msdn.microsoft.com/Forums/en-US/dslvsarchx/thread/0fecd2f3-e38e-473b-b178-c2b0cbd436b4
- Proposed As Answer by Jean-Marc PrieurMicrosoft Employee, Owner Tuesday, June 05, 2012 2:43 PM
- Unproposed As Answer by Jean-Marc PrieurMicrosoft Employee, Owner Tuesday, June 05, 2012 2:54 PM
-
Tuesday, June 05, 2012 2:54 PMOwner
Hi Thomas
Sorry, the DSl Designer is a very complex DSL (50 kloc) with a lot of custom code, which uses Domain elements for the domain concepts but also for a "View Model" that takes care of this stacked layout. There is not simple way to do that with an out of the box DSL.
Regards
Jean-Marc
- Proposed As Answer by Jean-Marc PrieurMicrosoft Employee, Owner Tuesday, June 05, 2012 2:54 PM
- Marked As Answer by Jean-Marc PrieurMicrosoft Employee, Owner Thursday, June 07, 2012 11:06 AM
- Unmarked As Answer by Jean-Marc PrieurMicrosoft Employee, Owner Tuesday, June 12, 2012 8:19 AM
- Marked As Answer by Jean-Marc PrieurMicrosoft Employee, Owner Tuesday, June 12, 2012 8:19 AM
-
Tuesday, June 12, 2012 8:16 AM
I made a easy solution that works for me.
1. Every shape has a public property "OrderIndex" that will be assigned inside the method ElementAdded() a in class AddShapeRule. Create a special StackPanelClass or implement GetNextOrderIndex() in the diagram class.
2. In the method GetCompliantBounds() in class BoundsRules assigned to the shape I call a custom method GetShapeLocation() that returns the calculated location.
3. If the implemented shapes nests shapes they can change the height and width. In GetCompliantBounds() in BoundsRules assigned to the diagram I sort the nested shapes of the diagram by the Property AbsoluteBoundingBox.Top in descanding order. I check if any shape is intersecting another shape with LinkedElementCollection.Intersect(). I assign all shapes that intersect a "fake"-Location to enforce the call of BoundsRules of the shape.- Marked As Answer by Jean-Marc PrieurMicrosoft Employee, Owner Tuesday, June 12, 2012 8:19 AM

