基于C#的AE二次开发布局视图与主视图的同步

基于C#的AE二次开发布局视图与主视图的同步

我的开发环境为ArcGIS Engine 10.2与Visual studio2010。主地图名称为axMapControl1,布局视图名称为axPageLayoutControl1。如果名称变动则需要修改(注意相关事件的添加与动态链接库的导入)!

实现代码:

#region 布局视图与主地图同步
private void axMapControl1_OnAfterScreenDraw(object sender, IMapControlEvents2_OnAfterScreenDrawEvent e)
{
     
    IActiveView pActiveView = (IActiveView)this.axPageLayoutControl1.ActiveView.FocusMap;
    IDisplayTransformation displayTransformation = pActiveView.ScreenDisplay.DisplayTransformation;
    displayTransformation.VisibleBounds = this.axMapControl1.Extent;
    axPageLayoutControl1.ActiveView.Refresh();
    //布局视图与数据视图的同步
    IObjectCopy pObjectCopy = new ObjectCopy() as IObjectCopy;
    object copyFromMap = this.axMapControl1.Map;
    object copiedMap = pObjectCopy.Copy(copyFromMap);//复制地图到copiedMap中
    object copyToMap = axPageLayoutControl1.ActiveView.FocusMap;
    pObjectCopy.Overwrite(copiedMap, ref copyToMap); //复制地图
    axPageLayoutControl1.ActiveView.Refresh();

}
#endregion

你可能感兴趣的:(#,AE二次开发,C#,组件GIS)