Select to view content in your preferred language

"New Map File" analog

554
0
12-17-2012 11:58 PM
IlyaSolovyev
Occasional Contributor
I have a simple code to create new document in ArcMap and add one layer from file (.lyr). Code runs on a click of add-in button.
If I run this code, ArcMap always shows "Do you want to save..?" dialog.

Here is the code:
    public class TestNewDoc : ESRI.ArcGIS.Desktop.AddIns.Button
    {
        protected override void OnClick()
        {
            ArcMap.Application.OpenDocument("Normal.mxt");

            IGxLayer gxLayer = new GxLayerClass();
            IGxFile gxFile = (IGxFile)gxLayer;
            gxFile.Path = "C:\\temp\\layer.lyr";

            ArcMap.Document.AddLayer(gxLayer.Layer);
        }
     }


In fact, I want to have a code, which acts the same as "New Map File" ArcMap command.
Any ideas?
0 Kudos
0 Replies