Group2D inherits from Object2D. It is a container for Object2D's. It is somewhat like an array. You can iterate through all the contents of a Group2D.
An example would be:
in this example, g2D_Draw is a Group2D.
Var lastIndex As Integer lastIndex = g2D_Draw.Count - 1 For nIndex As Integer = 0 To lastIndex g2D_Draw.Item(nIndex).BorderColor = Color.Red Next nIndex
If g2D_Draw contains a bunch of RectShapes and OvalShapes (which are Objects2D's) then they are changed to Red. It is all great.
It is legal for Group2Ds to contain Group2D's. What happens if g2D_Draw contains a bunch of Group2Ds?
If you run the code above, the compiler accepts it but nothing happens. It is legal to apply a BorderColor to a Group2D , but it has no effect.
A real-world example is one in which you have curved lines that are actually made up of many short straight line segments (CurveShapes). These are all brought into a single Group2D. This is legal and sensible. A line created in this way will draw just fine into a canvas. If you have several of these lines, they can be brought into a "parent" Group2D. Lines stored in this way will draw just fine into a canvas, What if you wanted to make all the lines Red?
If you iterate through the "parent" Group2D, each element can have it BorderColor made Red. It is legal as mentioned above, but nothing happens. So somehow, one imagines, you have to iterate through the "parent" Group2D and then iterate through each element in that Group2D which themselves are Group2D's to change their BorderColor to Red. But the compiler objects.
Var lastIndex As Integer lastIndex = g2D_Draw.Count - 1 For nIndex As Integer = 0 To lastIndex Var innerLastIndex As Integer innerLastIndex = g2D_Draw.Item(nIndex).Count Next nIndex
Now g2D_Draw.Item(nIndex) is, in fact a Group2D. That individual element of g2D_Draw is, itself a Group2D. But the compiler objects:
Type "Object2D" has no member named "Count"
Well, many Objects2D's have no member named "Count" but this Object2D, being a Group2D, does have a member named Count.
Var lastIndex As Integer lastIndex = g2D_Draw.Count - 1 For nIndex As Integer = 0 To lastIndex Var someGroup2D As New Group2D someGroup2D = g2D_Draw.Item(nIndex) Next nIndex
That also will not work. You will get an error message that Object2D's are not Group2D's even though in this situation that particular Object2D is a Group2D.
My question is: How do I accomplish what I want. That is to change several curved lines, each individually created as a bunch of CurveShapes living in a Group2D to Red?