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 new to ArcEngine and ArcObjects. I'd like to develop an extension for ArcMap where I have to use IHookHelper instead of AxMapControl. I am looking for the AddShapefile method, which is available for AxMapControl, but apparently missing from the IHookHelper interface.

public partial class conversionRtoP : Form
{
    public IHookHelper phookhelperRtoP;
    public IRaster praster;

    public conversionRtoP()
    {
        InitializeComponent();
    }

    private void conversionRtoP_Load(object sender, EventArgs e)
    {
        for (int i = 0; i < phookhelperRtoP.FocusMap.LayerCount; i++)
        {
            if (phookhelperRtoP.FocusMap.get_Layer(i) is IRasterLayer)
            {
                comboBox1.Items.Add(phookhelperRtoP.FocusMap.get_Layer(i).Name.ToString());
            }
        }
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Geoprocessor gp = new Geoprocessor();
        IConversionOp pconversionop;
        pconversionop = new RasterConversionOpClass();

        for (int i = 0; i < phookhelperRtoP.FocusMap.LayerCount; i++)
        {
            if (phookhelperRtoP.FocusMap.get_Layer(i).Name == comboBox1.Text)
            {
                praster = (IRaster)phookhelperRtoP.FocusMap.get_Layer(i);
            }
        }

        ESRI.ArcGIS.ConversionTools.RasterToPolygon prastertopoly = new RasterToPolygon(praster, outputpathtext);
        ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult gpresult;
        gpresult = (IGeoProcessorResult)gp.Execute(prastertopoly, null);
        int j;
        string gppath;
        gppath = outputpathtext.Text;
        j = gppath.LastIndexOf("\b");
        // this is my problem:
        ***phookhelperRtoP.(where is addshapefile method)***
    }

    private void button3_Click(object sender, EventArgs e)
    {
        SaveFileDialog savedialog = new SaveFileDialog();
        savedialog.CheckFileExists = true;
        savedialog.Filter = "Shapefile (*.shp)|*.shp";
        savedialog.Title = " Save";
        savedialog.RestoreDirectory = true;
        savedialog.FileName = comboBox1.Text;
        DialogResult dr = savedialog.ShowDialog();
        if (dr == System.Windows.Forms.DialogResult.OK)
        {
            outputpathtext.Text = savedialog.FileName;
        }
share|improve this question
3  
(1) Work on your accept rate! (2) Next time, please take the time to select only the relevant bits of code, and format/indent it in a way that makes it easy to read. –  stakx Feb 17 '12 at 14:07
add comment

1 Answer

You seem to work with Windows Forms. Can't you put a MapControl control onto your form? (Check the toolbox in the Windows Forms designer, there should be a category for ESRI controls.)

That control supports the various IMapControl interfaces (e.g. IMapControl4) which have an AddShapeFile method.

share|improve this answer
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.