Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 每次打开地图文档时运行函数_C#_Arcobjects_Opendocument - Fatal编程技术网

C# 每次打开地图文档时运行函数

C# 每次打开地图文档时运行函数,c#,arcobjects,opendocument,C#,Arcobjects,Opendocument,我正在使用C和ArcObjects。每次打开地图文档.mxd或任何其他类型的地图文件时,我都需要运行一些函数。不过,我不知道实现这一点所需的代码 例如,每次加载或打开地图文档时,都会显示一个消息框,上面会说:地图文档加载成功您需要创建一个扩展来执行此操作,并为事件添加一个处理程序-中有一个很好的示例,其中包含您所需的一切: public class LogExtension : ESRI.ArcGIS.Desktop.AddIns.Extension { public LogExte

我正在使用C和ArcObjects。每次打开地图文档.mxd或任何其他类型的地图文件时,我都需要运行一些函数。不过,我不知道实现这一点所需的代码


例如,每次加载或打开地图文档时,都会显示一个消息框,上面会说:地图文档加载成功

您需要创建一个扩展来执行此操作,并为事件添加一个处理程序-中有一个很好的示例,其中包含您所需的一切:

public class LogExtension : ESRI.ArcGIS.Desktop.AddIns.Extension
  {
    public LogExtension()
    {
    }

    protected override void OnStartup()
    {
      ArcMap.Events.OpenDocument += new ESRI.ArcGIS.ArcMapUI.IDocumentEvents_OpenDocumentEventHandler(Events_OpenDocument);
    }

    void Events_OpenDocument()
    {
      System.Windows.Forms.MessageBox.Show("I opened a document.");
    }
}

我已经编辑了你的标题。请看,如果共识是否定的,他们就不应该。@JohnSaunders对此表示抱歉。谢谢你的编辑。