ilya.s.solovyev

"New Map File" analog

Discussion created by ilya.s.solovyev on Dec 17, 2012
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?

Outcomes