Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm building a simple map interface on a .net component that I need to redistribute around.

Well, my initial thoughts was to create the tools just the way I'm used to do it in ArcMap, inheriting BaseTool and then set the MapControl.CurrentTool = tool in my onclick form events.

What is the best way to accomplish this? This one?

Also, how can I pass the hook to those tools? I'm using this class:

public class CommandPoolManager
{
    public ICommandPool _CommandPool;

    public ICommandPoolEdit GetCommandPoolEdit
    {
        get { return (ICommandPoolEdit)_CommandPool; }
    }

    public ICommandPool GetCommandPool
    {
        get { return this._CommandPool; }
    }

    public CommandPoolManager(object hook)
    {
        this._CommandPool = new CommandPoolClass();
        ICommandPoolEdit commandPoolEdit = (ICommandPoolEdit)this._CommandPool;
        commandPoolEdit.SetHook(hook);
    }

    public void AddCommandToPool(ICommand command)
    {
        ICommandPoolEdit commandPoolEdit = GetCommandPoolEdit;
        commandPoolEdit.AddCommand(command,null);
        commandPoolEdit.CallOnCreate(command);
    }

    public void AddCommandToPool(ICommand command,UID uid)
    {
        ICommandPoolEdit commandPoolEdit = GetCommandPoolEdit;
        commandPoolEdit.AddCommand(command, uid);
        commandPoolEdit.CallOnCreate(command);
    }
}

Would that be the correct way to use CommandPool? I'm without options for testing this, since it's a component to be distributed. The real question is: Am I on the right track?

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

Not sure about the CommandPool stuff, but there is a page on how to work with Tools in your standalone applications in the documentation: How to create a command or tool to work with the controls

share|improve this answer
    
thanks for your answer mathias. I already been to that page, but thanks for reminding me. What I want to do is to actually test this thing. I'm trying to bind simple .NET buttons to these tools. But thanks for sharing. –  George Aug 24 '10 at 17:21
    
Well that's the way we do it, we are building a line-of-business application on top of Microsoft Pattern and practises CAB. Building commands in CAB hosting the ArcGIS Engine Commands and Tools. The only problem we have seen so far is that some of the ArcGIS Engine tools don't work as expected, see my question on MeasureTolControl. But our own custom tools works. –  MathiasWestin Aug 24 '10 at 17:44
    
So you basically creates the ITool object and then calls OnCreate with the specific hook object (in my case, AxMapControl)? Just the way it's listed in that article? –  George Aug 24 '10 at 17:46
1  
Yes, that's the way we do it. –  MathiasWestin Aug 24 '10 at 18:23
add comment

Are you wanting to know how to replicate the existing tool functionality with your own button?

//Create the tool
ICommand _zoomInTool = new ControlsMapZoomInToolClass();
//bind it to the map
_zoomInTool.OnCreate(axMapControl1.Object);

//this bit goes in your own button event handler.
axMapControl1.CurrentTool = (ITool) _zoomInTool;
share|improve this answer
    
Thanks for the answer eldac. I was trying to use ICommandPool to trigger my commands/tools, but I didn't quite have the time to make it work. The way you and other described works just fine! –  George Aug 27 '10 at 14:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.