Resizing nodes inside a LimitingSubgraph

I have a LimitingSubgraph that is coded such that the nodes inside are bound by the border of the LimitingSubgraph. It behaves as I want it to when the nodes are moved to edge and are limited to the border. However, if I try to resize the node the behavior is not exactly what I want. I cannot stretch the resizing node to the right or bottom edges. The node’s size is shortened, either the width or height. The reason seems to be the normalizing of the bounds. Do you know a

way to make it bound for both moving and resizing? I would like to be able to resize a node to the very edge of the border but not lose the behavior on a move. See code below from the SnapPoint method.
Thanks,
John
public PointF SnapPoint(PointF p, GoObject obj, GoView view){
// normalize the object's Bounds as if the Location were always the Position
PointF loc = obj.Location; RectangleF b = obj.Bounds; b.X += (p.X - loc.X); b.Y += (p.Y - loc.Y);

GoToolResizing.DoResizing calls GoView.SnapPoint with the current mouse point.
GoView.SnapPoint finds an IGoDragSnapper (if any) and calls IGoDragSnapper.SnapPoint on it.

So a subgraph class that implements IGoDragSnapper will be able to control both the movement and the resizing of nodes that are in the subgraph. But it seems the LimitingSubgraph’s SnapPoint isn’t appropriate for resizing.

You might want to customize the resizing tool. Here’s the definition of DoResizing:

public virtual void DoResizing(GoInputState evttype) { if (this.CurrentObject == null) return; GoInputEventArgs last = this.LastInput; last.DocPoint = this.View.SnapPoint(last.DocPoint, this.CurrentObject); last.ViewPoint = this.View.ConvertDocToView(last.DocPoint); GoObject obj = this.CurrentObject; RectangleF oldBounds = obj.Bounds; obj.DoResize(this.View, this.OriginalBounds, last.DocPoint, this.ResizeHandle.HandleID, evttype, this.MinimumSize, this.MaximumSize); }
Instead of calling SnapPoint, and instead of setting DocPoint and ViewPoint, you can call obj.DoResize with a point that stays within the bounds of the LimitingSubGraph’s InsideMargins.

Walter, Thanks for your response. Where do you recommend this code be placed? I thought it should go into the View code, but I get several errors. The one I have not been able to overcome is “GraphView does not contain a definition for ResizeHandle”. What object should ResizeHandle.HandleID belong? Thanks.

GoToolResizing

I am assuming that GoToolResizing is the answer to my second question, right?
I have tried to create my own class that would inherit from GoToolRisizing and override the DoResizing method. I cannot get it to compile. Here's the code:
class EntityResizingTool : GoToolResizing { private GoView myGoView = new GoView(); public EntityResizingTool(): base(GoView v) { myGoView = v; } public override void DoResizing(GoInputState evttype) { if (this.CurrentObject == null) return; GoInputEventArgs last = this.LastInput; // last.DocPoint = this.View.SnapPoint(last.DocPoint, this.CurrentObject); // last.ViewPoint = this.View.ConvertDocToView(last.DocPoint); GoObject obj = this.CurrentObject; RectangleF oldBounds = obj.Bounds; obj.DoResize(this.View, this.OriginalBounds, last.DocPoint, this.ResizeHandle.HandleID, evttype, this.MinimumSize, this.MaximumSize); } }

I get these errors:

") expected" at base(GoView v)
"} expected" at the end of the constructor.
How do I inherit and override this method? Thanks.

Here’s the corrected constructor:

public EntityResizingTool(GoView view) : base(view) { myGoView = view; }

I added the GoTool to my view but it never fires. Code is:

class GraphView : GoView, IGoTool
{
EntityResizingTool myEntityResizingTool;
public GraphView()
{
this.DragsRealtime = true;
this.ExternalDragDropsOnEnter = true;
myEntityResizingTool = new EntityResizingTool(this);
Tool = myEntityResizingTool;
}
What am I missing? Please help.

The general procedure for replacing standard tool behavior with customized behavior is something like:

[Serializable] public class CustomTool : GoToolXYZing { public CustomTool(GoView v) : base(v) {} public override ... ...() { ... } }

During initialization, replace the standard tool in your GoView by:

  goView1.ReplaceMouseTool<span ="highlight"></span>(typeof(GoToolXYZing), new CustomTool(goView1));

I replaced the standard tool in my MainForm constructor and the custom resizing tool is now firing. Thanks Walter. The code if anyone cares:

goView1.ReplaceMouseTool(typeof(GoToolResizing), new EntityResizingTool(goView1));

You should be able to use the debugger to examine the GoView and see if your tool is being installed correctly.







Note the separate MouseDown, MouseMove and MouseUp lists.



If that all looks good, check your CanStart, see if it is being called.

Jake, Thanks for info. I have everything working now. I am capturing the resize event and containing the GoNodes in the LimitingSubGraph with the look and feel I want. Thanks