@KlausW
My apologies, but I will change my suggestion to using a List<LinkedList<>> instead of a 2 dimensional array. The concept is still pretty much the same, it will just be easier to implement.
You will have to create a struct or class which has a 'layer' property, you will use this property to assign a form to the appropriate part of the List:
-
//MyChildObject is a custom class/struct which has an integer property 'layer'
-
-
List<LinkedList<MyChildObject>> Layers; //List of layers
-
-
LinkedList<MyChildObject> Children; //list of children in each layer
-
-
private void CreateNewChild(MyChildObject newChild)
-
{
-
Layers[newChild.layer].AddFirst(newChild); //This adds the new child object to the correct layer and in the first position
-
}
-
Moving the selected child to the front can be done using the
AddFirst method and then deleting the 'old' entry from the linked list using the
FindLast method of the linked list.
The structure of List<LinkedList<>> will look something like this:
XXX
XXXXXXXX
XX
XXXXXXXXX
XXXXX
X
XXXXXXXXXXXX
If you are unfamiliar with the list and linkedlist data structures, see the below links:
List LinkedList Class Linked list concept
Please feel free to post if you are uncertain of anything.