Two or more resizing tools

Hello,

Is it possible to have two or more custom resizing tools (e.g. separate resizing tool for node and tool for image), and how can they be implemented.
I tried to do it this way:

Custom GoView class:

DefaultTool = new MyToolManager(this);
Tool = DefaultTool;

ReplaceMouseTool(typeof(GoToolResizing), new MyToolResizing(this));

MyToolManager class:

public override void DoMouseDown()
{
GoObject pickedObject = View.PickObject(true, false, LastInput.DocPoint, true) as MyImage;

        if (pickedObject != null)
            View.Tool = new MyToolImageResizing(View);

        base.DoMouseDown();
    }

MyToolImageResizing class:

public class MyToolImageResizing : GoToolResizing
{
public MyToolImageResizing(GoView view) : base(view) { }

    public override void Start()
    {
        GoObject pickedObject = View.PickObject(true, false, LastInput.DocPoint, true) as MyImage;

        if (pickedObject != null)        
            base.Start();
        }
    }

MyToolResizing class:

public class MyToolResizing : GoToolResizing
{
public MyToolResizing(GoView view) : base(view) {}

public override bool CanStart()
{
if (!base.CanStart())
return false;

        GoObject pickedObject = View.PickObject(true, false, LastInput.DocPoint, true) as MyNode;

        // Check if the node is dragged.
        if (pickedObject != null)
            return true;

        return false;
    }

    public override void Start()
    {
        base.Start();
    }

But it is not working. Please point me to the right direction. What I’m doing wrong?

GoToolResizing’s CanStart looks for a Resize handle under the mouse. so… without trying it, I think the CanStart for each of your resizing tools would be something like:



public override bool CanStart() {

if (!base.CanStart())

return false;



IGoHandle handle = PickResizeHandle(this.FirstInput.DocPoint);

return (handle != null &&

handle.HandledObject is GoImage);

}



and… you don’t need MyToolManager. You would ReplaceMouseTool on the first one, and the Add the second one with a view.MouseDownTools.Add.

Great, problem solved.

Thanks again Jake.