Kuei-yang Lo

Hi,

when I writedown the following custom code in DSL project:

public partial class FormGeometryShape {
public override void OnDoubleClick(DiagramPointEventArgs e) {
if (this.HasChildren) {
if (this.NestedChildShapes.Count == 0) {
MessageBox.Show("Oh my God!");
}
}
}
}

Why did it keep on showing "Oh my God" message

Why is it HasChildren but NestedChildShape is 0

How can I get the NestedChildShape of a certain Shape

Thanks for your reply!




Re: Visual Studio Extensibility Probem: NestedChildShapes has No Child at all.

DuncanP - MSFT

Hi there,

Child shapes fall into two categories, "nested" and "relative", accessed through the properties ".NestedChildShapes" and ".RelativeChildShapes" respectively.

Nested child shapes are contained entirely within the boundaries of the parent shape; relative child shapes can be outside the parent's boundary.

"HasChildren" returns true if there are children of either type, so you should find that your FormGeometryShape has relative child shapes.

Cheers,

Duncan





Re: Visual Studio Extensibility Probem: NestedChildShapes has No Child at all.

Kuei-yang Lo

Yes, you're right: my FormGeometryShape has relative child shapes.

But, the current situation is that Form has an empeded relationship to Zone called "FormHasZones" , and, in debugging mode, I drop several Zones on Form, and how come did I get NestedChildShapes==0 in FormGeometryShape

Thanks for your reply!






Re: Visual Studio Extensibility Probem: NestedChildShapes has No Child at all.

DuncanP - MSFT

Ok; if I understand you correctly, your model looks something like this:

* Form embeds Zone (FormHasZones)

* Form is represented on the diagram by FormGeometryShape.

* Zone is represented on tre diagram by ZoneGeometryShape.

There is no direct relationship between FormGeometryShape and ZoneGeometryShape; their only purpose is to display a visual representation of the underlying "Form" and "Zone" elements on the diagram.

If you are starting at a FormGeometryShape and want to find out all of the related Zones, you need to get the Form model element that the FormGeometryShape represents first, as in the following code:


Code Snippet

public override void OnDoubleClick(DiagramPointEventArgs e)
{
// Get a ref to the Form represented by this FormGeometryShape
Form form = this.ModelElement as Form;

// Now loop through the zones linked to the Form
foreach (Zone zone in form.Zones)
{
// do stuff...
}

}

Duncan