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've created a small API to wrap ArcEngine controls so I can customize them (my own toolbars, my icons, etc) and I'm having problem with the ControlsEditingSketchToolClass control.

I basically have a command pool that gets initialized against a AxMapControl and if it's a tool and set the tool to be the current map tool. If it's a command i just execute it.

Looks like it works fine for other commands and tools (pan, zoom, select all, unselect, select features) but not for Sketch Control. When I try to activate it, it is always disabled.

According to ESRI docs:

The CLSID of this command is: {13B234E8-3B30-49CA-9967-4C76F7231AD6}.

This command works with the ToolbarControl, PageLayoutControl and MapControl.

If the ArcGIS Engine application using this command is initialized with an ArcGIS Engine Runtime license or an ArcView license, this command can be used to edit shapefiles and personal geodatabases.

If the ArcGIS Engine application using this command is initialized with an ArcGIS Engine GeoDatabase Editing license, or ArcEditor or ArcInfo, this command can be used to edit data within an enterprise geodatabase.

The edit session is in place and it's using my map and my workspace for sure!

In my command pool I'm also sure that I call the OnCreate method using ICommandPoolEdit.CallOnCreate()

Here's the method I use for activating the tool/command:

    public virtual void Activate(IExecutionContext context)
    {
        System.Diagnostics.Debug.Assert(context != null);

        if (Checker != null)
            if (!Checker.HasPermission(context, this))
                throw new NotAllowedException("This command cannot be execute using this execution context");

        if (TargetType == typeof(AxMapControl))
        {
            var map = (AxMapControl)_registry.Hook;

            if (_innerCommand is ITool && _innerCommand.Enabled)
            // this tool is ALWAYS DISABLED
            {
                map.CurrentTool = ((ITool)_innerCommand);
                return;
            }

            if (_innerCommand is ICommand && _innerCommand.Enabled)
            {
                _innerCommand.OnClick();
                return;
            }
        }

        if (TargetType == typeof(AxPageLayoutControl))
        {
            var map = (AxPageLayoutControl)_registry.Hook;

            if (_innerCommand is ITool && _innerCommand.Enabled)
            {
                map.CurrentTool = ((ITool)_innerCommand);
                return;
            }

            if (_innerCommand is ICommand && _innerCommand.Enabled)
            {
                _innerCommand.OnClick();
                return;
            }
        }

        _stats.SessionUsageCount++;
    }

Any tips?

share|improve this question
    
Have you set a target layer on the editor (IEngineEditLayers)? Have you set a current task on the editor (IEngineEditor)? –  Stefan Dec 13 '11 at 8:19
    
Yes I had both. I managed to figure this one out. I need to pass along to my Hook the actual IMapDefault interface instead of AxMapControl. –  George Dec 16 '11 at 19:19

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.