Identification of objects within layers

We have a data model that is representative of base objects and their layers of inheritance for creating derived values of the data.
It is my intent to use a GoDiagram to represent these various layers. For my first prototype I am just doing hardcoded coding of the layers. I start with the parent node which is in the parent document of my goView object.
MvpLayerBox layerID = new MvpLayerBox(“Base Layer”);
layerID.Position = new System.Drawing.PointF(LayerXPos, LayerYPos);
layerGraph.Document.Add(layerID);

This parent layer is always present and as such it does not get created on a layer. Next when it is clicked it will show three new objects which are populated on a new layer.
I have an ExpandChildren method passing the node that was clicked. I create a new layer and place all children on that layer with their links living on that layers LinkLayer. I create the layer as such:
this.layerGraph.Document.Layers.CreateNewLayerAfter(this.layerGraph.Document.Layers.Top);
I then set newLayer.Identifier=“LayerIDOne” or some such thing. When I click on either the parent node or the lower layer node, I display the node.Layer.Identifier.ToString() and it is ALWAYS returning a value 0. It is never returning the layer identifier I am programmatically setting. Why?

GoDocument.Add is defined as:
public virtual void Add(GoObject obj) {
this.DefaultLayer.Add(obj);
}
So I’m wondering if you really put each node on the GoLayer that you intended.
By the way, you might want to look at the TreeApp sample.

Well…that was not exactly a usefull reply.
I looked at the TreeNode application and it is completely different from what I want to do.
As I understand what little documentation you supply, the document DefaultLayer is where objects that are not in a layer get placed. But you cannot create a layer unless you provide it a layer. I created my layers from the Document.Layers.Top which – according to your documentation, is the topmost layer in the document.
What I’m trying to do is each time I expand one of the layers, I want the objects and the linkLayer on a different layer. I am getting a display and I cannot find anything else in your documentation which indicates another way of doing layering other than the code I already have done.
So if my understanding is wrong, I’d like a little more information that telling me to look at a sample app. Looking at someones code in a complex tool without documentation is not helpful.

Well, I’m sorry it wasn’t a useful reply. I did not understand your post.
Are you trying to change the layers of the existing objects when you do an expansion? Or could you just change the values of GoDocument.DefaultLayer and GoDocument.LinksLayer to refer to the new GoLayers you just created? I still don’t understand what you want to do–there are so many possible reasonable behaviors.

Walter, Please…it is okay. It is difficult to explain in words what we are doing and having someone understand it first pass.
This is what I am trying to do:
The upper portion of the screen is a GoView which is prepopulated with a Base node. (Beneath this is any data ‘records’ that exist in the metadata that satisfies this layer) This Base node basically represents all base metadata (which should be none). When I get an Object_Click event on the Base node, the application will display all possible layers that exist beneath the Base node. (Let’s say it is Auto, MotorCycle, Boat)
When I build this layer I want the links and nodes to live on a separate layer. These nodes come and go based on what the user does. For example :
Click on Base node: display Auto, MotorCycle, Boat in small rectangular nodes with the layer name in the box. Display all records that exist in the clicked node (Base – which is still none) Place the nodes in a layer named Type.
Click on Base node again: destroy all children (ie. named layers above the DefaultLayer).
Since I am destroying everything, it made sense that the displayed nodes be managed within a layer. The links are then built using a LinksLayer built off of the new layers’ document object. This also makes it simple to navigate through all layers within the parent. Also if a user clicks on a node in an upper layer (with all layers being built using the CreateLayerAfter()) then all children of that node are on their own layer…and all children of another node at that layer is again on a separate layer.
In other words: If I click on Auto, I will see nodes for 48 states on their Layer.Identity=“Type.Auto.State” layer (and I will display all metadata records that satisfy the node value of Auto). If I click on MotorCycle, I see layers for the 20 states it is offered in on the Layer.Identity=“Type.MotorCycle.State” layer (and all metadata records that satisfy the node value of Motorcycle). If I click on the MotorCycle node (which now is in the IsExpanded state) I Remove() the Type.MotorCycle.State layer from the default.Document.Layers collection.
I understand that the parent node ends up on the default layer. That is fine. But each subsequent layer of nodes I construct would be on unique layers with unique ID’s. From the layerID I know which node on the higher layer owns it and I can easily and programmatically find each layer owned by a given node.
The intellisense for LayerCollection and the methods exposed for Document.Layers, and the intellisense for Layer.Identity as well as the rudimentary help file object properties and methods suggests that this should all work.
When I build the new layer and that layers’ linklayer, and add that object to the document, I get (almost) the display I want. But when I click on a node, I do not get the identity of the layer that owns that node. (Which is what the intellisense and help file says that I should be getting)
BTW: The part of the display that does NOT work is the construction of the link from the parent node to it’s children. The link appears. But I am trying to get the link to draw an “L” from the parent down to the child (positioned a bit right of center of the parent). I attempted to do this display by adding a point to the link. What I get drawn is the “L” but with a third line drawn between the two points. I create the link with the following algorithm:
Create a layer from the Top layer in the Document for the GoView.
Create a LinksLayer from the Document in the new layer.
Add the nodes for the new layer.
Foreach node added, Create a new link. Add Parent BottomPort to DestinationLink. Add Child LeftPort to SourceLink. Add point whose Point() is Parent.Center and Child.Ycoordinate. Add link to linkLayer.
Reposition the nodes in the owning layer (move).
From the documentation that exists…it APPEARS that when I click on the MotorCycle node, I should be able to cast the passed node to an MvpLinkLayerBox and then see node.Layer.Identity.ToString() to see that the value of the object I set in this layer is “Type”. And if I click on a node that is one of the 20 state nodes beneath MotorCycle, then I should se node.Layer.Identity.ToString() equal to “Type.MotorCycle.State”. But in both cases (as well as the object on the default layer) I am seeing the value “0”.

OK, I’m starting to get an idea of what you want, but I’m still fuzzy on a lot of issues. A screenshot or two would have saved you a lot of trouble trying to describe things in words. You know the old saying: “A picture is worth a thousand words”.
In any case, it appears you are using “layer” in two different ways simultaneously: as GoLayers in the document, to segregate collections of objects in the Z-order, and as columns of details. (This is consistent with GoDiagram’s dual use of the term, since the layered-digraph autolayout also uses “layer” in the second sense.)
So I created a trivial application that exhibits some of the behaviors I think you’re looking for. Please examine it and see if you can adapt it to what you want to do.
http://www.nwoods.com/forum/uploads/MultiLayerApp.zip
It only took me a few minutes to create this application, and it worked the first time.

Yes that is basically what I’m doing. Of course, I plan on doing movement of the nodes that live beneath the clicked node. But that is what I’m trying to achieve.

Thanks. I’ll dig into the code.

Walter,
I am getting things working quite well using your implementation. But I am still left with questions. I have seen you post in this forum several times that your control is “just another windows form control” and yet I failed when attempting to code your control in a standard fashion.
Why handle the click events within the control rather than having it delegated to the click event handler? Why can’t I deal with layer-specific code at that level?
The access to layers doing lookups seems to work fine. Yet if I have a layer and access that layers’ Document object, I get every object on the form, not every object isolated just within this layer. Why?
Granted, I get alot of simplified code by having each layer collapse it’s owned layers. I am also gaining some value with expanding and collapsing parent tree objects as well in this method. I just want to get in your head to understand why you implemented code this way.

I’m not sure I understand your questions. In .NET, all Controls handle their own events, and by convention, also invoke all registered delegates as event handlers. The first part is done by calls to the On method, which is virtual so that you can override it. The second part is done by defining an event named on the control on which programmers can add delegates as event handlers and by having the default implementation of On invoke those delegates.
This lets programmers implement event-handling functionality either in the Control itself or in delegates. GoDiagram’s GoView follows this convention fully. In VS.NET’s Form designer you should be able to select a GoView and, looking at its list of events in the Properties window, be able to double-click on one of its events such as ObjectSingleClicked to define an event handler for that event on that GoView in the Form.
Perhaps some of your confusion is that GoDiagram uses a model-view-controller architecture. GoDocument is the container that holds GoLayers which hold GoObjects. A GoDocument can be shared by multiple GoViews. GoLayer.Document is a reference to the GoDocument. GoObject.Layer is a reference to the GoLayer. By the way, layers cannot contain layers, so it isn’t possible to add a layer to a layer.
GoDocument and GoLayer both implement IGoCollection: a collection of GoObjects. Of course when people iterate over the objects in a GoDocument, they expect to get all of the objects in the document, not just those that belong to a particular GoLayer.
You might want to read the first view chapters of the User Guide to get a better idea of all of these concepts. You can also look at the diagram generated by the ObjectBrowser sample application.

Hi Walter,

I stumble on this thread and would like to take a look at the example you provided (http://www.nwoods.com/forum/uploads/MultiLayerApp.zip). However, all attempts to download the file seem to redirect me to the forum’s main page. Can you make that file available or I am doing something wrong? Thanks!

In the almost 13 years since that topic, we have moved to this new forum service, rather than hosting our own forum. All of the files are still there, but due to our automatic forwarding of links to topics, you can only get them at through the “forumFiles/uploads/…” path. For your case, that would be:

http://www.nwoods.com/forumFiles/uploads/MultiLayerApp.zip

Thank you, Walter.