Special Gonode Suggestions

Hello All,
I thought I might try to harness the collective experience of all the forum members. I need to create a node that does the following things:

  1. It must have rounded edges.
  2. It must have a header for something we call an assignment, similar to the organizational chart example, but underneath each header, i need to list people and equipment much like the multitextnode.
  3. I need to beable to drag a person or piece of equipment from one node to another.
  4. I need to hide or show the people and equipment in a node with a plus minus button on the top left hand side of the node.
    Im still fairly new to go, so any suggestions would be greatly appreciated.
  1. GoMultiTextNode already has a Corner property.
  2. GoMultiTextNode can do this, but you probably want to override CreatePort to return null, if you don’t need any ports per person or per equipment. Maybe the same goes for overriding CreateEndPort.
  3. This is more complicated, but requires replacing the standard dragging tool with a custom one that lets a drop of a person/equipment onto another node remove the item from the original node and add it to the new one.
  4. TreeAppNode, in theTreeApp sample, demonstrates a way to have a plus/minus “button” that isn’t a real object, but is just drawn and has click-handling overridden in order to detect a click in that area. Alternatively, you can just use a subclass of GoRectangle, as GoSubGraph does (GoSubGraphHandle).

Thanks a bunch GoGOD also known as Walter. :)


I’ve had some good luck implementing my design, but I’m having a problem. I changed the nodes to be GoMultiTextNodes, changed each item other than the first gotext object of the node to be selectable. Then I overwrote some of the view code to add the gotext object that i was dragging to the object i dropped it on, and removed it from its previous node. This all worked great, until I set the dragsnode property of those gotext objects that i wanted to drag to false. It looks great, as it drags the gotext as opposed to the entire node, but now its giving me its orginial location in the OnSelectionMoved function of the view. Basically my code looks like this:
if(this.Selection.Primary is GoText)
GoText oSource = this.Selection.Primary as GoText;
PointF oLoc = oSource.Center;
CNewNode oTarget = PickUnselectedGraphNode(oLoc, this.Selection);

where point equals its orginial location as opposed to the location i dropped it to. Im a bit befuddled by this, any suggestions?
To clarify my rant, why would the Selection.Primary.Center Location be at its orginial node as opposed to the one I just dropped it on.

Well, you’re making good progress. I should have mentioned about setting GoObject.DragsNode to false for the items, but you figured it out already.
Also, the primary method to override in your custom tool is GoToolDragging.DoDragging. But you already know that.
The positions of selected objects during a drag depends on whether GoView.DragsRealtime is true or false.
If it’s true, then the selected objects’ positions really change during the drag. However, the LayoutChildren method of GoMultiTextNode will probably be conspiring against you, because it wants to keep all of the items in its list in a column.
But I think you want it to be false, which is how it probably is for you now. So the selected object(s) aren’t being moved, but the DragSelection objects are. So you might want to look at the GoToolDragging.DragSelection instead. The drag selection, by default, consists of two objects: an invisible GoRectangle with the same bounds as the CurrentObject, and a GoImage displaying a rendition of the whole selection.
I believe you will find that the position of this.DragSelection.Primary does indeed change during the repeated calls to DoDragging.

Hey Walter,
I was orginially overriding the OnSelectionMoved function of the view, which I understand is called by the GoToolDragging instance contained within the view. Therefore I had my own implementation of the view as opposed to my own implementation of the GoToolDragging class. So should I create my own GoToolDragging class, and and override the dodragging function, or can I pull the GoToolDragging.DragSelection object out of the views GoToolDragging instance when the OnSelectionMoved is fired?
Thanks a bunch,

I think you can do either.

Alright, I tried to simply get the current instance of the GoToolDragging class from within my custom view. So I wrote
if(this.Tool is GoToolDragging){

PointF oLoc = ((GoToolDragging)Tool).DragSelection.Primary.Center; CNewNode oTarget = PickUnselectedGraphNode(oLoc, ((GoToolDragging)Tool.DragSelection.Primary); if (oTarget != null) {
InsertResource(oTarget.ListGroup, oSource);
} But the dragselection object is coming back as null. Can I only access the dragselection object in a custom GoToolDragging object? And My first born child to walter for all the help. Ryan

Alright, I have it working!!! Now I bypassed the GoToolDragging object, and received my x,y values from the following line:
PointF oLoc = this.LastInput.DocPoint;
I realize that this might be a little cheesy, so Ill still take suggestions, but it works great. I really appreciate all the help Walter,

GoToolDragging.DragSelection is set by the GoToolDragging.MakeDragSelection method, which is called by GoToolDragging.DoDragging when view.DragsRealtime is false.
Did you put that code in an override of GoView.DoInternalDrag?
protected override void DoInternalDrag(DragEventArgs evt) {
DoMouseMove(); // call dragging tool
GoToolDragging tool = this.Tool as GoToolDragging;
if (!this.DragsRealtime)

System.Diagnostics.Debug.Assert(tool != null && tool.DragSelection != null);

Actually no, I left it in my overriden OnSelectionMoved method of my view class. I was thinking that it might not fly.