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
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 get these errors:
Here’s the corrected constructor:
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:
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